Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save LyalinDotCom/1590c6690a413abf6f0235d181ffb872 to your computer and use it in GitHub Desktop.

Select an option

Save LyalinDotCom/1590c6690a413abf6f0235d181ffb872 to your computer and use it in GitHub Desktop.
Draft: Genkit MCP server documentation
This feature enables you to enhance your local development workflow by integrating your Genkit project with the Gemini CLI. This integration allows the Gemini CLI to discover and use your locally defined Genkit tools and flows, enabling you to build, test, and interact with your code in a single, conversational interface.
This works via the Model Context Protocol (MCP), a standard that allows LLM clients to discover and interact with local tools and context.
### Prerequisites
- You have a working Genkit project.
- You have installed the Genkit CLI: `npm install -g genkit-cli`
- You have installed the Gemini CLI: `npm install -g @google/gemini-cli`
### Configuration
The Gemini CLI uses a configuration file located at `.gemini/settings.json` in your project's root directory. To enable the Genkit integration, create this file (and the `.gemini` directory if it doesn't exist) and add the `mcpServers` configuration:
```json:.gemini/settings.json
{
"mcpServers": {
"genkit": {
"command": "npx",
"args": ["genkit", "mcp"],
"timeout": 30000,
"trust": false
}
}
}
```
Let's break down this configuration:
- `"genkit"`: This is a name you give to the server connection.
- `"command": "npx"` and `"args": ["genkit", "mcp"]`: This tells the Gemini CLI how to start the Genkit MCP server. When you interact with Gemini, it will run `npx genkit mcp` in the background, which exposes your project's tools and flows.
- `"trust": false`: This is a crucial security setting. When set to `false`, the Gemini CLI will prompt you for confirmation before executing any tool or command suggested by the model (e.g., writing a file, running a shell command).
### Usage
With the configuration in place, you can start a conversational development session.
1. **Start the Gemini CLI** in your project's root directory:
```bash
gemini
```
2. **Ask Gemini to perform a task** related to your Genkit project. Because the Genkit MCP server is running, Gemini now has context about Genkit and access to its tools.
For example, you can ask it to create a new flow:
```prompt
> implement a recipe generator flow. check genkit documentation first
```
Gemini will now:
- Use the `lookup_genkit_docs` tool (provided by the MCP server) to understand how to build flows.
- Propose a plan that involves creating files and installing dependencies.
- Prompt you for permission to execute shell commands like `mkdir src` and to write the code for `src/index.ts`.
![Gemini CLI prompting to execute a shell command.](/_astro/gemini-cli-shell-prompt.png)
3. **Interact with your running code.** After Gemini has created the files, you need to run your Genkit code in a separate terminal. For example, if it created `src/index.ts`:
```bash
npx tsx --watch src/index.ts
```
Now, your flow is running locally. The Genkit MCP server (managed by the Gemini CLI) will automatically discover the running flows. You can go back to the Gemini CLI and ask it to run the flow:
```prompt
> run the recipe generator flow with avocado and vegetarian restrictions
```
Gemini will use the `run_flow` tool from the Genkit MCP server to interact with your running code, passing the specified input and showing you the result. It can even help you debug by analyzing traces:
```prompt
> analyze the trace
```
This tight loop between conversational commands, code generation, and execution makes the Gemini CLI with Genkit a powerful tool for rapid development and iteration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment