Back to MCP Catalog

Firebase Genkit MCP Server

Developer ToolsTypeScript
Create and consume Model Context Protocol servers with Genkit
Available Tools

list_resources

Lists available resources from the MCP server

read_resource

Reads a specific resource from the MCP server by its resource ID

Firebase Genkit MCP provides seamless integration between Genkit and the Model Context Protocol (MCP), an open standard for building servers that provide tools, resources, and prompts to clients. This plugin enables developers to both consume MCP tools as a client and expose Genkit functionality as an MCP server. With Genkit MCP, you can connect to existing MCP servers to access their tools and resources, or create your own MCP server that exposes your Genkit tools and prompts to other applications. The plugin supports multiple transport methods including stdio, SSE, and WebSocket connections.

Overview

Firebase Genkit MCP is an experimental plugin that bridges Genkit with the Model Context Protocol (MCP). This integration allows you to:

  1. Use Genkit as an MCP client - Connect to existing MCP servers and use their tools, prompts, and resources
  2. Expose Genkit as an MCP server - Make your Genkit tools and prompts available to other applications via the MCP standard

Installation

To get started with Genkit MCP, install both Genkit and the MCP plugin:

npm i genkit genkitx-mcp

Using as an MCP Client

The MCP client functionality allows you to connect to any MCP server and use its tools, prompts, and resources within your Genkit application.

Basic Client Setup

import { genkit } from 'genkit';
import { mcpClient } from 'genkitx-mcp';

// Create an MCP client for a local server
const myMcpClient = mcpClient({
  name: 'myserver',  // This name will namespace all tools and prompts
  serverProcess: {
    command: 'npx',
    args: ['-y', '@some/mcp-server', '--option', 'value'],
  },
});

// Add the client to your Genkit instance
const ai = genkit({
  plugins: [
    myMcpClient,
    // other plugins...
  ],
});

Connection Options

You can connect to MCP servers in several ways:

  1. Local Process (stdio) - Launch a server as a subprocess:

    mcpClient({
      name: 'local',
      serverProcess: {
        command: 'npx',
        args: ['-y', '@some/package'],
        env: { KEY: 'value' },  // Optional environment variables
      },
    });
    
  2. Remote Server (SSE) - Connect to a remote server via Server-Sent Events:

    mcpClient({
      name: 'remote',
      serverUrl: 'https://example.com/mcp',
    });
    
  3. WebSocket Connection - Connect via WebSocket:

    mcpClient({
      name: 'websocket',
      serverWebsocketUrl: 'wss://example.com/mcp',
    });
    

Using MCP Tools and Prompts

Once connected, all MCP server tools and prompts are automatically registered with Genkit and namespaced under the client name you provided:

// Using an MCP tool
const result = await ai.tools.myserver.some_tool({ param1: 'value' });

// Using an MCP prompt
const response = await ai.generate({
  prompt: ai.prompts.myserver.some_prompt({ input: 'value' }),
  model: 'your-model',
});

Accessing MCP Resources

MCP resources are accessible through special tools that are automatically registered:

// List available resources
const resources = await ai.tools.myserver.list_resources();

// Read a specific resource
const content = await ai.tools.myserver.read_resource({ 
  resource_id: 'some-resource-id' 
});

Creating an MCP Server

You can expose your Genkit instance as an MCP server, making all your tools and prompts available to other applications.

Basic Server Setup

import { genkit, z } from 'genkit';
import { mcpServer } from 'genkitx-mcp';

// Create a Genkit instance
const ai = genkit({});

// Define tools and prompts
ai.defineTool(
  {
    name: 'calculate',
    description: 'Perform a calculation',
    inputSchema: z.object({ 
      expression: z.string() 
    }),
    outputSchema: z.number(),
  },
  async ({ expression }) => {
    return eval(expression);
  }
);

// Start the MCP server
mcpServer(ai, { 
  name: 'my_calculation_server', 
  version: '1.0.0' 
}).start();

By default, the server uses the stdio transport, which is suitable for local subprocess communication. You can specify a different transport when starting the server.

Limitations

When working with Genkit MCP, be aware of these limitations:

  • MCP prompts only support string parameters, so input schemas must be objects with string property values
  • Only user and model message types are supported in prompts; system messages are not supported
  • MCP prompts can only have a single content type per message (can't mix media and text)
  • The plugin is experimental and APIs may change in future versions

Testing Your MCP Server

You can test your MCP server using the official MCP inspector:

npx @modelcontextprotocol/inspector path/to/your/server.js

The inspector provides a UI to explore and test your server's tools and prompts.

Related MCPs

Apple Shortcuts
Developer ToolsJavaScript

Control Apple Shortcuts automations from AI assistants

Clojars Dependency Lookup
Developer ToolsJavaScript

Fetch dependency information from Clojars, the Clojure community's artifact repository

Simple Timeserver
Developer ToolsPython

Provides Claude with current time and timezone information

About Model Context Protocol

Model Context Protocol (MCP) allows AI models to access external tools and services, extending their capabilities beyond their training data.

Generate Cursor Documentation

Save time on coding by generating custom documentation and prompts for Cursor IDE.