-
Notifications
You must be signed in to change notification settings - Fork 630
feat(js/plugins/anthropic): add MCP tools support #4045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add MCP server and toolset configuration schemas (McpServerConfigSchema, McpToolsetSchema) - Enable mcp-client-2025-11-20 beta header for MCP support - Add handlers for mcp_tool_use and mcp_tool_result response blocks - Update request body to include mcp_servers and mcp_toolsets configuration - Add comprehensive documentation with usage examples in README - Add 7 new tests covering MCP functionality and configuration
Summary of ChangesHello @amondnet, 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! This pull request significantly enhances the Anthropic plugin by integrating Model Context Protocol (MCP) tools. This allows Claude models to leverage external, server-managed tools, expanding their capabilities beyond their inherent functions. The changes involve defining new configuration schemas, updating the request and response handling logic to support MCP-specific blocks, and activating the necessary beta API header. This feature provides developers with greater flexibility in building applications that require Claude to interact with external services through a standardized protocol. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe 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 by creating a comment using either
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 Limitations & Feedback Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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. Footnotes
|
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 adds support for Model Context Protocol (MCP) tools to the Anthropic plugin. The changes are well-structured, including new type definitions for MCP configuration, handlers for MCP-related response blocks, and updates to the request body generation. The feature is also well-documented in the README and thoroughly tested.
My main feedback is to refactor some duplicated code to improve maintainability. Overall, this is a great addition to the plugin.
…dling - Add logging for MCP tool errors (is_error: true) - Add [ERROR] prefix to MCP tool result text when execution fails - Add URL HTTPS validation to McpServerConfigSchema - Add MCP server name uniqueness validation - Add mcp_server_name reference validation (toolset must reference existing server) - Add runtime type checks for MCP content block fields - Add edge case tests for streaming, fallback scenarios - Document anthropicMcpToolResult structure in README
701b1a2 to
d27eae3
Compare
|
/gemini review |
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 effectively adds support for MCP tools to the Anthropic plugin, including new type definitions, request/response handlers, and comprehensive validation. The code is well-structured, and the addition of extensive unit tests is commendable. I have a few suggestions for improvement: one to simplify an example in the documentation, another to enhance type safety in the response handling, and a final one to make the new tests more robust by mocking the correct logger. Overall, this is a great contribution.
Extract duplicated config and tools preparation logic into a private helper method to improve maintainability (DRY principle).
… one toolset Per Anthropic MCP Connector documentation, each MCP server must be referenced by exactly one MCPToolset in the tools array. - Add validation: server not referenced by any toolset → error - Add validation: server referenced by multiple toolsets → error - Add 7 new tests for MCP configuration validation - Update README with new validation rule Co-authored-by:
…docs Update MCP schemas to use Zod .describe() for consistency with codebase: - name: clarify must be referenced by exactly one MCPToolset - authorization_token: specify OAuth token - mcp_server_name: clarify must match server in mcp_servers array - defer_loading: explain tool description behavior - default_config/configs: clarify override precedence Co-authored-by:
d27eae3 to
9217649
Compare
- Simplify conditional check in README.md (find already ensures truthy) - Add typeof check for tool_use_id type safety - Use logger.warn mock instead of console.warn in tests
Code Review Suggestions AppliedApplied suggestions from @gemini-code-assist in 3f63fae75: 1. README.md - Simplify conditional check✅ Changed 2. beta.ts - Type safety for tool_use_id✅ Added 3. beta_runner_test.ts - Use logger mock✅ Changed from |
|
Thanks for implementing the suggestions, @amondnet! It's great to see these improvements incorporated into the pull request. The changes you've made, especially regarding the conditional check simplification, type safety for |
Description
This PR adds Model Context Protocol (MCP) tools support to the Anthropic plugin, enabling the use of MCP servers and toolsets with Claude models in the Genkit framework.
Key Features
McpServerConfigSchema,McpToolsetSchema) for type-safe configurationmcp_tool_useandmcp_tool_resultresponse blocksmcp_serversandmcp_toolsetsconfigurationmcp-client-2025-11-20beta header for MCP protocol supportMCP Server Configuration
Based on the Anthropic MCP Connector documentation:
type"url"is supportedurlhttps://nameauthorization_tokenExample Usage
Checklist (if applicable):