-
Notifications
You must be signed in to change notification settings - Fork 349
Open
Labels
Description
Describe the bug
I have integrated MCP server with Genkit , I am facing issue while trying to run it and it gives an error saying Genkit MCP Server gives Connection Error - Did you add the proxy session token in Configuration?
To Reproduce
Steps to reproduce the behavior:
- Create
package.json
and install
"@genkit-ai/googleai": "^1.16.0",
"@genkit-ai/mcp": "^1.16.0",
"genkit": "^1.16.0",
"typescript": "^5.9.2"
- Create
index.ts
and copy the below code
import { googleAI } from "@genkit-ai/googleai";
import { createMcpServer } from "@genkit-ai/mcp";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { genkit, z } from "genkit/beta";
const ai = genkit({
plugins: [
googleAI({
apiKey: "MY_API_KEY",
}),
],
});
ai.defineTool(
{
name: "add",
description: "add two numbers together",
inputSchema: z.object({ a: z.number(), b: z.number() }),
outputSchema: z.number(),
},
async ({ a, b }) => {
return a + b;
}
);
ai.definePrompt(
{
name: "happy",
description: "everybody together now",
input: {
schema: z.object({
action: z.string().default("clap your hands").optional(),
}),
},
},
`If you're happy and you know it, {{action}}.`
);
ai.defineResource(
{
name: "my resouces",
uri: "my://resource",
},
async () => {
return {
content: [
{
text: "my resource",
},
],
};
}
);
ai.defineResource(
{
name: "file",
template: "file://{path}",
},
async ({ uri }) => {
return {
content: [
{
text: `file contents for ${uri}`,
},
],
};
}
);
// Use createMcpServer
const server = createMcpServer(ai, {
name: "example_server",
version: "0.0.1",
});
// Setup (async) then starts with stdio transport by default
server.setup().then(async () => {
await server.start();
const transport = new StdioServerTransport();
await server!.server?.connect(transport);
});
npx tsc --init
- In
tsconfig.json
, uncomment"outDir": "dist",
- In
package.json
add"type": "module"
npx tsc
npx @modelcontextprotocol/inspector dist/index.js
- Visit
http://localhost:6274
and click Connect
Expected behavior
MCP server should work with Genkit
Screenshots

Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status