Genkit MCP is a plugin in the js/plugins/mcp directory of the Genkit project, used to connect Genkit with the Model Context Protocol (MCP). MCP is an open standard that allows developers to build "servers" that provide tools, resources, and prompts to clients. This plugin allows Genkit developers to use MCP in both directions.
Purpose and main capabilities
Consume MCP as a client: connect to one or more MCP servers via createMcpHost or createMcpClient, and discover and use their tools, prompts, and resources.
Expose capabilities as an MCP server: use createMcpServer to expose tools and prompts registered in a Genkit instance as an MCP server.
Usage
Before use, you need to install Genkit and the MCP plugin. When connecting to multiple MCP servers, use createMcpHost, which returns a GenkitMcpHost instance responsible for managing the lifecycle and communication of the configured MCP servers. Its options include: name (optional, default genkitx-mcp), version (optional, default 1.0.0), rawToolResponses (optional, default false; when true, tool responses are returned in raw MCP format), mcpServers (required; keys are client namespaces, values are server configurations). Each server configuration can include disabled (optional, default false), and one of the following connection configurations: stdio local process parameters (command required, args optional, env optional), url for a remote server (Streamable HTTP transport), an existing transport object.
When connecting to only a single MCP server or when you want to manage client instances separately, you can use createMcpClient. It accepts McpClientOptions: name (required, used as the namespace for tools and prompts), version (optional, default 1.0.0), and supports all options of McpServerConfig (such as disabled, rawToolResponses, and transport configuration).
GenkitMcpHost and GenkitMcpClient can all discover available tools on connected and enabled servers via getActiveTools(); these tools are standard Genkit ToolAction instances and can be provided to Genkit models. MCP prompts can be obtained via McpHost.getPrompt(serverName, promptName) or mcpClient.getPrompt(promptName), returning an ExecutablePrompt. All MCP actions (tools, prompts, resources) are namespaced: createMcpHost uses the keys configured in mcpServers (such as localFs/read_file), and createMcpClient uses its name (such as myFileSystemClient/list_resources).
MCP tools return content arrays rather than structured responses, and the plugin attempts to parse and convert them: when the text is valid JSON, it is parsed into a JSON object; when the text is not valid JSON, the raw text is returned; when it contains only a single non-text part (such as an image), that part is returned directly; when it contains multiple or mixed parts (such as text plus an image), the full content response array is returned.
createMcpServer returns a GenkitMcpServer instance. Its start() method starts the MCP server using stdio transport by default, exposing all registered Genkit tools and prompts; you can also pass another transport instance to start() (such as server.start(customMcpTransport)). Its options include name (required, the server name used for MCP checks) and version (optional, default 1.0.0).
Applicable scenarios and limitations
Applicable to scenarios where you need to connect external MCP tools and resources in a Genkit agent application, or provide the Genkit tool ecosystem to other clients in MCP form. Known limitations: MCP prompts can only accept string parameters, so schema input must be an object containing only string property values; MCP prompts only support user and model messages, not system messages; a single message supports only one type and cannot mix media and text. You can use the official inspector to test an MCP server, for exampleAfter the server code is compiled to dist/index.js, the inspector can be run; after startup, it can list prompts and actions and be manually tested.