Connect: Genkit¶
Recipe · through our MCP server · their docs checked 2026-10-30
Genkit's @genkit-ai/mcp plugin runs an MCP host inside your Genkit app. It connects to
our server and offers our tools to ai.generate.
Our side¶
def public_app(tools: Registry, host: str, agent_token: str, reviewer_token: str) -> Any:
"""REST at /, MCP at /mcp, one bearer check for both: for a host on the internet."""
from mcp.server.transport_security import TransportSecuritySettings
from agent_adapter.server import create_app
tokens = {
agent_token: Principal("hosted-agent"), # the token the remote framework sends
reviewer_token: Principal("reviewer@example.com", scopes=frozenset({APPROVER_SCOPE})),
}
security = TransportSecuritySettings(allowed_hosts=[host], allowed_origins=[f"https://{host}"])
return create_app(
tools,
authenticate=bearer_auth(tokens),
host="0.0.0.0", # a public bind: the public-host checks apply
allowed_hosts=[host], # REST: any other Host header gets 421
mcp_options={"transport_security": security}, # MCP: the same rule
)
hosted = registry.subset(tags=["hosted"]) # no confirm tools: hosted runtimes cannot resume them
Serve public_app(hosted, …): Genkit has no approval step to resume ours. In development
on one machine, local_app() is enough.
Their side¶
npm i genkit @genkit-ai/mcp:
import { genkit } from "genkit";
import { createMcpHost } from "@genkit-ai/mcp";
const ai = genkit({ plugins: [/* your model plugin */] });
const mcpHost = createMcpHost({
name: "agentAdapter",
mcpServers: {
shopTools: {
url: "https://tools.example.com/mcp",
requestInit: { headers: { Authorization: `Bearer ${process.env.AA_AGENT_TOKEN}` } },
},
},
});
const { text } = await ai.generate({
prompt: "What is the shipping rate to the US?",
tools: await mcpHost.getActiveTools(ai),
});
| Key | Meaning |
|---|---|
createMcpHost({ name, mcpServers }) |
one host for many servers |
mcpServers.<name>.url |
our /mcp endpoint (Streamable HTTP config) |
requestInit |
the transport's request options: carries the bearer header |
disabled |
stops a server without removing it |
getActiveTools(ai) |
the tools of every connected server |
This page covers Genkit JS. Genkit Go has its own MCP plugin, and a Python MCP client is landing (PR 6365); point either at the same URL with the same header.
Checklist¶
| Check | Why |
|---|---|
serve hosted |
Genkit does not send our resume keys back; a confirm tool would never run |
| the token stays on the server | process.env, never in a browser bundle |
| everything on the public-host checklist |
Sources¶
- Genkit MCP plugin: https://genkit.dev/docs/model-context-protocol/
- Genkit Python MCP client: https://github.com/genkit-ai/genkit/pull/6365