-
Notifications
You must be signed in to change notification settings - Fork 0
feat(mcp): M1 - Setup basic MCP client connection and stub server #32
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @ipv1337, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request implements Milestone 1 of the MCP integration plan. It introduces the chuk-mcp dependency, sets up a basic stub MCP server, and refactors the CLI code to connect to this stub server via MCP. The MCP development workflow documentation has also been updated. The primary goal is to establish a foundational MCP client-server connection for future development.
Highlights
- Dependency Injection: The pull request adds
chuk-mcpas a dependency, which will be used for MCP client-server communication. - Stub MCP Server: A basic stub MCP server is implemented to simulate MCP interactions during development. It listens on
127.0.0.1:8999and logs/acknowledges messages. - CLI Code Refactoring: The CLI code is refactored to connect to the stub MCP server, replacing direct model access with MCP communication. The
list_modelsfunction is temporarily disabled in the client, as model listing is now intended to be requested from the MCP server. - Workflow Documentation: The MCP development workflow in
docs/mcp_integration_plan.mdis updated to reflect the new process, including steps for local testing, unit tests, linting, and CI pipeline verification.
Changelog
Click here to see the changelog
- docs/mcp_integration_plan.md
- Updated the milestone workflow to include more detailed steps for development, testing, and CI.
- Added steps for local testing, unit tests & coverage, and linting.
- Clarified the process for creating feature branches and merging pull requests.
- Added steps to verify the CI pipeline on both the PR and the main branch.
- mcp_stub_server.py
- Introduced a basic MCP server using
asyncioandchuk-mcp. - Implemented a
StubMCPServerProtocolclass to handle MCP messages. - The server logs received messages and sends simple acknowledgements for
user_messageandtool_resulttypes. - Configured logging for the server to provide information about received and sent messages.
- The server listens on host
127.0.0.1and port8999.
- Introduced a basic MCP server using
- pyproject.toml
- Added
chuk-mcpas a dependency. - Reordered dependencies for better readability.
- Added
- src/cli_code/main.py
- Added imports for
asyncio,logging,os,sys,time, anduuid. - Added imports for
MCPClientProtocol,MCPError,MCPMessage,decode_mcp_message, andencode_mcp_messagefromchuk_mcp. - Removed direct imports of
GeminiModelandOllamaModel. - Modified
start_interactive_sessionto use the MCP protocol for communication. - Implemented
run_mcp_sessionas an async function to handle the MCP client connection and interaction loop. - Disabled the
list_modelsfunction in the client, indicating that model listing should now be requested from the MCP server. - Added MCP server host and port configuration constants.
- Added logic to send user messages to the MCP server and receive/process responses.
- Added basic error handling for connection and protocol errors.
- Added imports for
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A server stands, a stub so grand,
With MCP, it lends a hand.
Messages flow,
A gentle show,
For milestones in command.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
Code Coverage Report📊 Current Coverage: 16.30% Detailed coverage analysis is available in SonarCloud Coverage Change DetailsThis shows code coverage for changes in this PR. To improve coverage, consider adding tests for new or modified code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces the basic setup for the MCP client connection and a stub server, which is a significant step towards integrating the Model Context Provider (MCP) protocol. The changes include adding the chuk-mcp dependency, creating a stub MCP server, refactoring the CLI code to connect to the stub server, and updating the MCP development workflow. Overall, the implementation seems well-structured, but there are a few areas that could be improved for clarity and robustness.
Summary of Findings
- Error Handling in
run_mcp_session: Therun_mcp_sessionfunction includes multipletry...exceptblocks, but some exceptions are caught and logged without properly handling the error, potentially leading to silent failures. Ensure that all caught exceptions are appropriately handled, either by retrying, exiting gracefully, or providing informative error messages to the user. - Temporary Disabling of Model Listing: The
list_modelsfunction is temporarily disabled due to the MCP refactor. While this is acceptable for a milestone, ensure that the functionality is restored in a subsequent milestone and that the UI clearly indicates that model listing is unavailable and will be re-enabled. - TODO Comment in
run_mcp_session: Therun_mcp_sessionfunction contains aTODOcomment regarding more detailed help. Implement a more comprehensive help message to guide users on available commands and their usage. - Inconsistent use of f-strings: In the
mcp_stub_server.pyfile, f-strings are used for logging messages. Ensure consistency by using f-strings throughout the codebase for logging and other string formatting purposes.
Merge Readiness
The pull request introduces essential infrastructure for MCP integration. However, the identified issues related to error handling and temporary disabling of features should be addressed before merging. I am unable to directly approve this pull request, and recommend that the author address the above points before merging. Ensure that other reviewers also approve this code before merging.
| # TODO: Implement more detailed help if needed | ||
| console.print("[bold]Available commands:[/bold]") | ||
| console.print(" /exit - Quit the session") | ||
| console.print(" /help - Show this help message") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding more details to the help message, such as a list of available tools and their descriptions. This will provide users with a better understanding of the system's capabilities.
| # TODO: Implement more detailed help if needed | |
| console.print("[bold]Available commands:[/bold]") | |
| console.print(" /exit - Quit the session") | |
| console.print(" /help - Show this help message") | |
| # TODO: Implement more detailed help if needed | |
| console.print("[bold]Available commands:[/bold]") | |
| console.print(" /exit - Quit the session") | |
| console.print(" /help - Show this help message") | |
| # Example of more detailed help: | |
| # console.print(" /tool <tool_name> - Execute a specific tool") | |
| continue |
Code Coverage Report📊 Current Coverage: 16.30% Detailed coverage analysis is available in SonarCloud Coverage Change DetailsThis shows code coverage for changes in this PR. To improve coverage, consider adding tests for new or modified code. |
…ove dependency, implement direct asyncio/JSON comms, refactor run_mcp_session, update tests, add pytest-asyncio, fix Python requirements.
Code Coverage Report📊 Current Coverage: 20.77% Detailed coverage analysis is available in SonarCloud Coverage Change DetailsThis shows code coverage for changes in this PR. To improve coverage, consider adding tests for new or modified code. |
|


This PR implements Milestone 1 of the MCP Integration Plan:\n\n- Adds dependency.\n- Creates a basic stub MCP server ().\n- Refactors to connect to the stub server via MCP.\n- Updates the MCP development workflow in .\n\nNext step is M2: Basic Server Implementation.