developing-genkit-tooling

Bewährte Vorgehensweisen für die Erstellung von Genkit-Tooling, einschließlich CLI-Befehlen und MCP-Server-Tools. Behandelt Namenskonventionen, Architekturmuster und Konsistenz…

npx skills add https://github.com/firebase/genkit --skill developing-genkit-tooling

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.

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).
// 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.

try {
  // operation
} catch (err) {
  const message = err instanceof Error ? err.message : String(err);
  return {
    isError: true,
    content: [{ type: 'text', text: `Error: ${message}` }],
  };
}

Mehr Skills von firebase

firebase-remote-config-basics
firebase
Umfassender Leitfaden für Firebase Remote Config, einschließlich Vorlagenverwaltung und SDK-Nutzung. Verwenden Sie diese Fähigkeit, wenn der Benutzer Hilfe bei der Einrichtung von Remote Config, der Verwaltung von Feature-Flags oder der dynamischen Aktualisierung des App-Verhaltens benötigt.
officialdevelopmentapi
developing-genkit-dart
firebase
Einheitliches AI SDK für Dart, das Codegenerierung, strukturierte Ausgaben, Tools, Flows und Agents ermöglicht. Bietet Kern-APIs für Generierung, Tool-Definition, Flow-Orchestrierung, Embeddings und Streaming mit einer einzigen Schnittstelle. Enthält 8+ Plugins für LLM-Anbieter (Google Gemini, Anthropic Claude, OpenAI GPT), Firebase AI, Model Context Protocol, Chrome-Browser-Integration und HTTP-Server-Hosting über Shelf. Integrierte CLI mit lokaler Entwicklungs-UI für Flow-Ausführung, Tracing, Modellexperimentierung und...
official
developing-genkit-go
firebase
Entwickeln Sie KI-gestützte Anwendungen mit Genkit in Go. Verwenden Sie dies, wenn der Benutzer darum bittet, KI-Funktionen, Agents, Flows oder Tools in Go mit Genkit zu erstellen, oder wenn Sie mit…
official
developing-genkit-js
firebase
Erstellen Sie KI-gestützte Node.js/TypeScript-Anwendungen mit Genkit-Flows, Tools und Multi-Modell-Unterstützung. Genkit ist anbieterneutral; unterstützt Google AI, OpenAI, Anthropic, Ollama und andere LLM-Anbieter über Plugins. Definieren Sie Flows mit typsicheren Schemas mit Zod, führen Sie Generierungsanfragen aus und erstellen Sie mehrstufige KI-Workflows in TypeScript. Erfordert Genkit CLI v1.29.0+; aufgrund aktueller größerer API-Änderungen müssen Sie die Genkit-Dokumentation:read und common-errors.md für aktuelle Muster konsultieren, nicht auf früherem Wissen basieren...
official
developing-genkit-python
firebase
Entwickeln Sie KI-gestützte Anwendungen mit Genkit in Python. Verwenden Sie dies, wenn der Benutzer nach Genkit, KI-Agenten, Flows oder Tools in Python fragt oder wenn er auf Genkit stößt…
official
firebase-ai-logic
firebase
We need to translate the given English text into German, preserving the name "firebase-ai-logic" but it's not in the text. The instruction says: "Do not include the name unless it appears in the source text." The name does not appear in the source text, so we don't include it. We just translate the text inside <text>. Also preserve product names, protocol names, URLs, numbers, technical terms. So "Gemini", "Gemini Nano", "Chrome", "Cloud Storage", "App Check" should remain as is. Translate the rest naturally. Let me translate: "Client-side Gemini integration for web apps with multimodal inference, streaming, and on-device hybrid execution." -> "Clientseitige Gemini-Integration für Web-Apps mit multimodaler Inferenz, Streaming und hybrider Ausführung auf dem Gerät." "Supports text-only and multimodal inputs (images, audio, video, PDFs); files over 20 MB route through Cloud Storage" -> "Unterstützt reine Texteingaben und multim
official
firebase-ai-logic-basics
firebase
Offizielle Fähigkeit zur Integration von Firebase AI Logic (Gemini API) in Webanwendungen. Behandelt Einrichtung, multimodale Inferenz, strukturierte Ausgabe und Sicherheit.
official
firebase-app-hosting-basics
firebase
Bereitstellen und Verwalten von Full-Stack-Web-Apps mit Firebase App Hosting unter Verwendung von Next.js, Angular und anderen unterstützten Frameworks. Erfordert ein Firebase-Projekt im Blaze-Tarif; unterstützt Server-Side Rendering (SSR) und Incremental Static Regeneration (ISR)-Workflows. Bereitstellung über firebase.json-Konfiguration mit optionaler apphosting.yaml für das Backend-Setup oder aktiviertes automatisiertes "git push to deploy" durch GitHub-Integration. Enthält Geheimnisverwaltung über CLI-Befehle für sicheren Zugriff auf sensible Schlüssel...
official