Skip to content

Conversation

yoheimuta
Copy link
Owner

@yoheimuta yoheimuta commented May 8, 2025

This pull request introduces significant enhancements to protolint, including the addition of Model Context Protocol (MCP) server functionality, a new MCP reporter, and related documentation updates. These changes enable protolint to integrate with AI tools like Claude Desktop and provide structured linting results in MCP-friendly formats.

New MCP Server Functionality:

  • Added support for the Model Context Protocol (MCP), allowing protolint to act as an MCP server for AI model integration (internal/cmd/cmd.go, mcp/README.md, README.md). [1] [2] [3]
  • Introduced the --mcp flag to start the MCP server and handle requests via stdin/stdout (internal/cmd/cmd.go). [1] [2] [3]

New MCP Reporter:

  • Implemented an MCPReporter to output linting results in a JSON format compatible with MCP (internal/linter/report/reporters/mcpReporter.go).
  • Updated the reporter selection logic to include the mcp reporter (internal/cmd/subcmds/lint/reporterFlag.go). [1] [2]

Code Refactoring and Extensibility:

  • Refactored the linting logic to use a pluggable LintRunner interface, enabling better modularity and testability (lib/lint.go, lib/lint_test_runner.go, internal/cmd/lint_runner.go). [1] [2] [3]

Documentation Updates:

  • Added detailed documentation for the MCP server, including usage, integration with Claude Desktop, and protocol implementation details (mcp/README.md, README.md). [1] [2]

Testing:

  • Added comprehensive unit tests for the MCPReporter to validate its JSON output and ensure compatibility with MCP clients (internal/linter/report/reporters/mcpReporter_test.go).

- Add protocol definitions in `mcp/protocol.go` for JSON-RPC requests and responses.
- Create unit tests for protocol handling in `mcp/protocol_test.go`.
- Develop the MCP server logic in `mcp/server.go`, including request handling and tool execution.
- Implement tools interface and linting functionality in `mcp/tools.go`, with a specific tool for linting Proto files.
- Add tests for the linting tool in `mcp/tools_test.go`.
- Create a new executable file `protolint` for running the MCP server.
@yoheimuta yoheimuta requested a review from Copilot May 8, 2025 12:26
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds support for the Model Context Protocol (MCP) server mode in protolint, enabling direct interaction with AI models.

  • Implements a new MCP server with corresponding tools and reporters.
  • Integrates a new --mcp flag in the command-line interface and updates the README and MCP documentation.
  • Enhances the codebase with a LintRunner interface and registers a new CmdLintRunner for CMD operations.

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.

Show a summary per file
File Description
mcp/tools.go Introduces the LintFilesTool with Execute method for MCP tooling.
mcp/server.go Implements the MCP server and request handling for MCP methods.
mcp/protocol.go & mcp/protocol_test.go Defines JSON-RPC protocol types and tests their correct (un)marshaling.
mcp/README.md Adds documentation describing MCP usage and integration with Claude.
internal/cmd/cmd.go & related files Integrates the new --mcp flag to start the MCP server.
lib/lint.go & lib/lint_test_runner.go Sets a flexible LintRunner interface and registers a mock/test runner.
internal/linter/report/reporters/mcpReporter* Implements and tests the MCPReporter for formatting lint results in JSON.
Comments suppressed due to low confidence (1)

mcp/tools.go:115

  • Verify whether the JSON output from the MCP reporter is expected to be written to stderr. If the reporter writes to stdout, consider using outputBuffer instead of errorBuffer for JSON unmarshalling.
if err := json.Unmarshal(errorBuffer.Bytes(), &result); err != nil {

yoheimuta added 2 commits May 9, 2025 12:40
- Added usage instructions for MCP clients in README.md.
- Introduced a new demo GIF for Claude Desktop integration.
- Updated MCP server implementation to support JSON-RPC 2.0 communication.
- Revised server capabilities and instructions for clarity.
- Modified tool interface to use 'any' type for better flexibility.
- Improved lint-files tool descriptions and added user guidance for fixing errors.

Close #468
@yoheimuta yoheimuta linked an issue May 9, 2025 that may be closed by this pull request
@yoheimuta yoheimuta merged commit 213d329 into master May 9, 2025
6 checks passed
@yoheimuta yoheimuta deleted the mcp/468 branch May 9, 2025 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implementation Plan for MCP Server
1 participant