genkit-tools-cli
Installation
SKILL.md
Genkit Tools CLI & MCP Guide
1. CLI Commands (cli/src/commands/)
- Naming: Use
noun:verborcategory:actionin kebab-case (e.g.flow:run,eval:run,trace:get). Use camelCase for code arguments and<argName>in help text. - Runtime lifecycle: Use
runWithManager(projectRoot, async (manager) => ...)from../utils/manager-utils.js(withfindProjectRoot()from@genkit-ai/tools-common/utils) for commands that interact with a project runtime (seecli/src/commands/flow-run.ts). - Output & flags: Log via
loggerfrom@genkit-ai/tools-common/utils; support--output(file/JSON output) and--streamwhere appropriate. - Registration: Register new commands in the
commandsarray incli/src/cli.ts.
2. MCP Tools (cli/src/mcp/)
- Naming: Use
verb_nounin snake_case (e.g.list_flows,run_flow,get_trace). - Static vs. runtime tools:
- Static tools (e.g.
defineDocsTool(server, projectRoot?)incli/src/mcp/docs.ts): Require no running Genkit runtime. - Runtime tools (
defineFlowTools,defineTraceTools,defineRuntimeToolstaking(server, options: McpToolOptions)): Interact with a project runtime viaoptions.manager.getManager(rootOrError).
- Static tools (e.g.
- Schema & project root: Always wrap tool inputs with
getCommonSchema(options.explicitProjectRoot, { ... })and resolve the root withresolveProjectRoot(options.explicitProjectRoot, opts, options.projectRoot)before accessingoptions.manager(seecli/src/mcp/flows.ts). - Analytics & errors: Record invocations with
record(new McpRunToolEvent('<tool_name>')). Catch errors and return`{ isError: true, content: [{ type: 'text', text: `Error: ${formatMcpError(e)}` }] }`instead of throwing. - Registration: Wire new tool groups into
startMcpServer()(and update serverinstructionsif user-facing) incli/src/mcp/server.ts.