Skip to content

Conversation

@MengqinShen
Copy link
Contributor

@MengqinShen MengqinShen commented Jan 7, 2026

This big changes aims to add mcp plugin to mirror all the functionalities in js/plugins/mcp in JS SDK.
CHANGELOG:

  1. Added a plugin to enable Genkit applications to interact with the Model Context Protocol, allowing them to function as both clients and servers.
  2. MCP Client Implementation: Provided a client that can connect to external MCP servers, list their tools, prompts, and resources, and execute them within a Genkit application.
  3. MCP Server Implementation: Developed a server that exposes Genkit's registered tools, prompts, and resources to external MCP clients, facilitating interoperability.
  4. Included extensive unit and integration tests for the MCP plugin, covering client-server communication, resource handling, and conversion utilities.

@github-actions github-actions bot added docs Improvements or additions to documentation python Python config labels Jan 7, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @MengqinShen, 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 integrates the Model Context Protocol (MCP) into the Python Genkit SDK by adding a new plugin. This plugin allows Genkit applications to seamlessly connect to and utilize services from external MCP servers, as well as to expose their own defined tools, prompts, and resources as an MCP server. The changes also include improvements to Genkit's core resource definition mechanism for greater adaptability and are accompanied by comprehensive examples and tests to ensure robust functionality.

Highlights

  • New MCP Plugin: Introduced a new Python plugin for the Model Context Protocol (MCP), enabling Genkit to interact with external MCP servers and expose its own capabilities.
  • Flexible Resource Definition: The define_resource function now supports direct keyword arguments for resource options (like name, uri, template), offering more flexibility in defining resources.
  • Dynamic Resource Function Handling: The resource block's wrapped_fn was enhanced to dynamically inspect the signature of the provided ResourceFn, allowing it to accept 0, 1, or 2 arguments.
  • Comprehensive MCP Components: The plugin includes client-side functionality (McpClient, McpHost) to connect to and manage external MCP servers, and server-side functionality (McpServer) to expose Genkit's tools, prompts, and resources.
  • Examples and Tests: New example files demonstrate how to set up and use both MCP clients and servers, alongside a suite of unit and integration tests covering conversion utilities and core plugin functionality.

🧠 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 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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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

  1. 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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 a new MCP (Model Context Protocol) plugin for Python, along with comprehensive examples and tests. The implementation is well-structured and largely mirrors the existing JavaScript SDK, which is great for consistency.

I've identified a few areas for improvement:

  • A potential runtime error in define_resource due to an optional function argument that is required by a downstream call.
  • A missing input_schema when registering tools from an MCP client, which is important for Genkit's tool-use capabilities.
  • Some minor maintainability issues like local imports and brittle string-based lookups.

Overall, this is a great addition. Addressing these points will make the new plugin more robust and maintainable.

@MengqinShen MengqinShen marked this pull request as ready for review January 7, 2026 05:37
@MengqinShen MengqinShen merged commit 885c6b0 into main Jan 7, 2026
10 checks passed
@MengqinShen MengqinShen deleted the elisa/feat(py)/mcp-plugin branch January 7, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config docs Improvements or additions to documentation python Python

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants