Genkit MCP Server
The Genkit MCP (Model Context Protocol) Server enables seamless integration of your Genkit projects with various development environments and AI tools. By exposing Genkit functionalities through the Model Context Protocol, it allows LLM agents and IDEs to discover, interact with, and monitor your Genkit flows and other components.
What is the MCP Server?
Section titled “What is the MCP Server?”The Genkit MCP Server acts as a bridge between your Genkit application and external tools that understand the Model Context Protocol. This allows these tools to:
- Discover Genkit flows: Tools can list all available flows defined in your project, along with their input schemas, enabling them to understand how to call them.
- Run Genkit flows: External tools can execute your Genkit flows, providing inputs and receiving outputs.
- Access trace details: The server allows for retrieval and analysis of execution traces for your Genkit flows, providing insights into their performance and behavior.
- Look up Genkit documentation: Integrated tools can access Genkit documentation directly through the MCP server, aiding in development and debugging.
Getting Started
Section titled “Getting Started”To use the Genkit MCP Server, you first need to have the Genkit CLI installed. If you haven’t already, install it globally:
npm install -g genkit-cli
Configuring the MCP Server
Section titled “Configuring the MCP Server”The Genkit MCP Server is typically configured within an MCP-aware IDE or tool. The configuration details often include:
serverName
: A unique name for the server (e.g., “genkit”).command
: The command to execute the MCP server (e.g.,genkit
).args
: Arguments to pass to the command (e.g.,["mcp"]
to run the Genkit MCP server).cwd
: The current working directory where the command should be executed.timeout
: The maximum time (in milliseconds) the server is allowed to start.trust
: A boolean indicating whether to automatically trust the server. Setting this totrue
allows tools to execute commands from this server without requiring explicit user confirmation for each action.
Integration with AI Development Tools
Section titled “Integration with AI Development Tools”To integrate the Genkit MCP Server with the Gemini CLI, you can add a configuration entry to your .gemini/settings.json
file. This file is typically located in your project root or your user’s home directory.
{ "mcpServers": { "genkit": { "command": "genkit", "args": ["mcp"], "cwd": "", "timeout": 30000, "trust": false } }}
After adding this configuration, restart your Gemini CLI session for the changes to take effect. You can then interact with your Genkit flows and tools directly from the Gemini CLI.
Video Tutorial
Section titled “Video Tutorial”Watch this video tutorial to see how to set up and use the Genkit MCP Server with the Gemini CLI:
Cursor AI IDE provides a built-in MCP client that supports an arbitrary number of MCP servers.
To add the Genkit MCP Server in Cursor:
- Open Cursor Settings by navigating to File > Preferences > Cursor Settings or by using the command palette.
- Select the MCP option in the settings.
- Click on the ”+ Add New MCP Server” button.
- Provide the configuration details. You can set the
Type
tostdio
and theCommand
togenkit mcp
. Remember to specify the correctcwd
if your Genkit project is not in the default directory. - Configuration can be stored globally (
~/.cursor/mcp.json
) or locally (project-specific,.cursor/mcp.json
).
Once configured, Cursor’s AI assistant will automatically invoke the server’s tools when needed.
Claude Code functions as both an MCP server and client and can connect to external tools via MCP.
To add the Genkit MCP Server to Claude Code:
-
You can configure MCP servers in Claude Code through:
- Project configuration (available when running Claude Code in that directory).
- Global configuration (available in all projects).
- A checked-in
.mcp.json
file (shared with everyone in the project).
-
From the command line, use the
claude mcp add
command:Terminal window claude mcp add --transport stdio genkit genkit mcp --cwd <path/to/your/genkit/project> --scope <scope>- Replace
<path/to/your/genkit/project>
with the actual path to your Genkit project. - Choose a
<scope>
:local
(default, only available to you in the current project),project
(shared with everyone via.mcp.json
), oruser
(available to you across all projects).
- Replace
Claude Code will then be able to leverage Genkit’s functionalities.
Windsurf, an AI-enhanced IDE built on VS Code, also supports MCP servers to extend its capabilities.
To set up the Genkit MCP Server in Windsurf:
- Open Windsurf Settings by clicking the Windsurf - Settings button (bottom right) or by hitting
Cmd+Shift+P
(Mac) /Ctrl+Shift+P
(Windows/Linux) and searching for “Open Windsurf Settings”. - Navigate to the Cascade section in Advanced Settings and look for the MCP option to enable it.
- You can add a new MCP server directly through the settings UI or by manually editing the
~/.codeium/windsurf/mcp_config.json
file. - Provide the
stdio
transport command:genkit mcp
. Ensure the working directory (cwd
) is correctly set to your Genkit project.
After configuration, Windsurf’s AI assistant (Cascade) can interact with your Genkit components.
Cline, an AI assistant for your CLI and Editor, can also extend its capabilities through custom MCP tools.
To configure the Genkit MCP Server in Cline:
-
Click the “MCP Servers” icon in the top navigation bar of the Cline pane.
-
Select the “Installed” tab.
-
Click the “Configure MCP Servers” button at the bottom of the pane.
-
You can then add a new server configuration using JSON. An example configuration would be:
{"mcpServers": {"genkit": {"command": "genkit","args": ["mcp"],"cwd": "","timeout": 30000,"trust": false}}}The settings for all installed MCP servers are located in the
cline_mcp_settings.json
file. -
Alternatively, you can ask Cline directly to “add a tool” and it can guide you through creating and installing a new MCP server.
Once configured, Cline will automatically detect and leverage the tools provided by the Genkit MCP Server.
Using the MCP Server
Section titled “Using the MCP Server”Once configured, your MCP-aware tool can interact with the Genkit MCP Server. Here are some of the available operations:
Look up Genkit Documentation
Section titled “Look up Genkit Documentation”You can use the lookup_genkit_docs
tool to retrieve documentation for the Genkit AI framework. You can specify a language and particular files to look up.
Example: To get a list of available documentation files for JavaScript:
@genkit:lookup_genkit_docs { "language": "js" }
List Genkit Flows
Section titled “List Genkit Flows”The list_flows
tool allows you to discover all defined Genkit flows in your project and inspect their input schemas.
Example:
@genkit:list_flows {}
This will return a list of flows with their descriptions and input schemas, similar to:
- Flow name: recipeGeneratorFlow Input schema: {"type":"object","properties":{"ingredient":{"type":"string"},"dietaryRestrictions":{"type":"string"}},"required":["ingredient","dietaryRestrictions"]}
Run Genkit Flows
Section titled “Run Genkit Flows”You can execute a specific Genkit flow using the run_flow
tool. You’ll need to provide the flowName
and any required input
as a JSON string conforming to the flow’s input schema.
Example:
To run a recipeGeneratorFlow
with specific ingredients and dietary restrictions:
@genkit:run_flow { "flowName": "recipeGeneratorFlow", "input": "{\"ingredient\": \"avocado\", \"dietaryRestrictions\": \"vegetarian\"}" }
The output will be the result of the flow execution, for example:
{ "cookTime": "5 minutes", "description": "A quick and easy vegetarian recipe featuring creamy avocado.", "ingredients": [ "1 ripe avocado", "1/4 cup chopped red onion", "1/4 cup chopped cilantro", "1 tablespoon lime juice", "1/4 teaspoon salt", "1/4 teaspoon black pepper" ], "instructions": [ "Halve the avocado and remove the pit.", "Scoop the avocado flesh into a bowl.", "Add the red onion, cilantro, lime juice, salt, and pepper.", "Mash everything together with a fork until it is mostly smooth but still has some chunks.", "Stir in the red onion, cilantro, lime juice, salt, and pepper.", "Serve immediately with tortilla chips or as a topping for tacos or salads." ], "prepTime": "5 minutes", "servings": 1, "title": "Simple Avocado Mash", "tips": [ "For a spicier dish, add a pinch of cayenne pepper.", "If you don't have fresh cilantro, you can use parsley instead." ]}
Get Trace Details
Section titled “Get Trace Details”After running a flow, you can retrieve its detailed execution trace using the get_trace
tool and the traceId
returned from the flow execution.
Example:
@genkit:get_trace { "traceId": "ecf38e20f418b2964f7ab472b799" }
The output will provide a breakdown of the trace, including details about each span, such as input, output, and execution time.
Local Development and Documentation Bundle
Section titled “Local Development and Documentation Bundle”The Genkit MCP Server includes a pre-built documentation bundle. If you need to update this bundle or work with custom documentation, the server can download and serve an experimental bundle from http://genkit.dev/docs-bundle-experimental.json
.
The documentation bundle is stored locally in ~/.genkit/docs/<version>/bundle.json
.