Skip to content

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.

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.

To use the Genkit MCP Server, you first need to have the Genkit CLI installed. If you haven’t already, install it globally:

Terminal window
npm install -g genkit-cli

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 to true allows tools to execute commands from this server without requiring explicit user confirmation for each action.

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.

Watch this video tutorial to see how to set up and use the Genkit MCP Server with the Gemini CLI:

Once configured, your MCP-aware tool can interact with the Genkit MCP Server. Here are some of the available operations:

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" }

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"]}

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."
]
}

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.