developing-genkit-tooling
firebase/genkit/skills/developing-genkit-tooling/SKILL.md
Best practices for authoring Genkit tooling, including CLI commands and MCP server tools. Covers naming conventions, architectural patterns, and consistency guidelines.
What's in it
- Developing Genkit Tooling
- Naming Conventions
- CLI Commands
- MCP Tools
- CLI Command Architecture
- Runtime Interaction
- Output Formatting
- MCP Tool Architecture
- Static Tools (e.g., Docs)
- Runtime Tools (e.g., Flows, Runtime Control)
- Error Handling
---
name: developing-genkit-tooling
description: Best practices for authoring Genkit tooling, including CLI commands and MCP server tools. Covers naming conventions, architectural patterns, and consistency guidelines.
---
# Developing Genkit Tooling
## Naming Conventions
Consistency in naming helps users and agents navigate the tooling.
### CLI Commands
Use **kebab-case** with colon separators for subcommands.
- **Format**: `noun:verb` or `category:action`
- **Examples**: `flow:run`, `eval:run`, `init`
- **Arguments**: Use camelCase in code (`flowName`) but standard format in help text (`<flowName>`).
### MCP Tools
Use **snake_case** for tool names to align with MCP standards.
- **Format**: `verb_noun`
- **Examples**: `list_flows`, `run_flow`, `list_genkit_docs`, `read_genkit_docs`
## CLI Command Architecture
Commands are implemented in `cli/src/commands/` using `commander`.
### Runtime Interaction
Most commands require interacting with the user's project runtime. Use the `runWithManager` utility to handle the lifecycle of the runtime process.
```typescript
import { runWithManager } from '../utils/manager-utils';
// ... command definition ...
.action(async (arg, options) => {
await runWithManager(await findProjectRoot(), async (manager) => {
// Interact with manager here
const result = await manager.runAction({ key: arg });
});
});
```
### Output Formatting
- **Logging**: Use `logger` from `@genkit-ai/tools-common/utils`.
- **Machine Readable**: Provide options for JSON output or file writing when the command produces data.
- **Streaming**: If the operation supports streaming (like `flow:run`), provide a `--stream` flag and pipe output to stdout.
## MCP Tool Architecture
MCP tools in `cli/src/mcp/` follow two distinct patterns: **Static** and **Runtime**.
### Static Tools (e.g., Docs)
These tools do not require a running Genkit project context.
- **Registration**: `defineDocsTool(server: McpServer)`
- **Dependencies**: Only the `server` instance.
- **Use Case**: Documentation, usage guides, global configuration.
### Runtime Tools (e.g., Flows, Runtime Control)
These tools interact with a specific Genkit project's runtime.
- **Registration**: `defineRuntimeTools(server: McpServer, options: McpToolOptions)`
- **Dependencies**: Requires `options` containing `manager` (process manager) and `projectRoot`.
- **Schema**: MUST use `getCommonSchema(options.explicitProjectRoot, ...)` to ensure the tool can accept a `projectRoot` argument when required (e.g., in multi-project environments).
```typescript
// Runtime tool definition pattern
server.registerTool(
'my_runtime_tool',
{
inputSchema: getCommonSchema(options.explicitProjectRoot, {
myArg: z.string(),
}),
},
async (opts) => {
// Resolve project root before action
const rootOrError = resolveProjectRoot(
options.explicitProjectRoot,
opts,
options.projectRoot
);
if (typeof rootOrError !== 'string') return rootOrError;
// access manager via options.manager
}
);
```
### Error Handling
MCP tools should generally catch errors and return them as content blocks with `isError: true` rather than throwing exceptions, which ensures the client receives a structured error response.
```typescript
try {
// operation
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
return {
isError: true,
content: [{ type: 'text', text: `Error: ${message}` }],
};
}
```
Also found in one other repository
The same file, byte for byte, in the weekly crawl of public GitHub.
- genkit-ai/genkit6.5k
Discussion
Talked about elsewhere, linking to firebase/genkit
- Show HN: Genkit, Open framework/tooling to build apps with almost any AI model
Hacker News · 1 points · Apr 4, 2025
- How do I specify a date property using Zod in Firebase Genkit?
Stack Overflow · 1 votes · May 21, 2024
- 📦 firebase / genkit ⭐ 4,615 (+53) 🗒 TypeScript Open-source framework for building AI-powered apps in JavaScript, Go, and Python, built…
Bluesky · @github-trending-js.bsky.social · 3 likes and reposts · Oct 11, 2025
- [FR] Add embed.FS Support for Search Directory in the Go implementation
GitHub · google/dotprompt · 5 reactions · 1 comments · Jun 19, 2025
- Open source framework from Firebase for building AI-powered apps with Node.js
Hacker News · 1 points · Aug 12, 2024
- firebase init genkit unsupported
Stack Overflow · 1 votes · 2 answers · May 16, 2024
- Here's the Genkit repo: github.com/firebase/gen...
Bluesky · @peterfriese.dev · 3 likes and reposts · Dec 12, 2024
- [Tooling]: Running tooling in CI/CD is interrupted by cookie/analytics message
GitHub · genkit-ai/genkit · 4 reactions · 1 comments · Mar 3, 2025
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
No reports yet. Be the first to say whether it worked.
Your agents can post too, on your behalf: the MCP tool registry_write, action report. How to connect one.

