Repository navigation
Closed as not planned
Description
I'm trying to better understand the MCP lifecycle better and I've noticed something in the Claude Desktop logs that confuse me a bit. I have a barebones server:
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
const server = new McpServer({
name: "Demo",
version: "1.0.0",
});
server.tool("add", { a: z.number(), b: z.number() }, async ({ a, b }) => ({
content: [{ type: "text", text: String(a + b) }],
}));
const transport = new StdioServerTransport();
await server.connect(transport);When I connect to this server Claude desktop, the logs show two distinct initialization instances:
// FIRST INSTANCE HERE
2025-03-10T17:03:18.749Z [demo] [info] Initializing server...
2025-03-10T17:03:18.762Z [demo] [info] Server started and connected successfully
2025-03-10T17:03:18.764Z [demo] [info] Message from client: {"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"claude-ai","version":"0.1.0"}},"jsonrpc":"2.0","id":0}
2025-03-10T17:03:18.829Z [demo] [info] Message from server: {"jsonrpc":"2.0","id":0,"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}},"serverInfo":{"name":"Demo","version":"1.0.0"}}}
2025-03-10T17:03:18.842Z [demo] [info] Message from client: {"method":"notifications/initialized","jsonrpc":"2.0"}
2025-03-10T17:03:18.845Z [demo] [info] Message from client: {"method":"tools/list","params":{},"jsonrpc":"2.0","id":1}
2025-03-10T17:03:18.851Z [demo] [info] Message from server: {"jsonrpc":"2.0","id":1,"result":{"tools":[{"name":"add","inputSchema":{"type":"object","properties":{"a":{"type":"number"},"b":{"type":"number"}},"required":["a","b"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}}]}}
2025-03-10T17:03:18.892Z [demo] [info] Message from client: {"method":"tools/list","params":{},"jsonrpc":"2.0","id":2}
2025-03-10T17:03:18.893Z [demo] [info] Message from server: {"jsonrpc":"2.0","id":2,"result":{"tools":[{"name":"add","inputSchema":{"type":"object","properties":{"a":{"type":"number"},"b":{"type":"number"}},"required":["a","b"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}}]}}
2025-03-10T17:03:19.503Z [demo] [info] Message from client: {"method":"resources/list","params":{},"jsonrpc":"2.0","id":3}
2025-03-10T17:03:19.504Z [demo] [info] Message from server: {"jsonrpc":"2.0","id":3,"error":{"code":-32601,"message":"Method not found"}}
2025-03-10T17:03:19.525Z [demo] [info] Message from client: {"method":"resources/list","params":{},"jsonrpc":"2.0","id":4}
2025-03-10T17:03:19.526Z [demo] [info] Message from server: {"jsonrpc":"2.0","id":4,"error":{"code":-32601,"message":"Method not found"}}
2025-03-10T17:03:19.526Z [demo] [info] Message from client: {"method":"tools/list","params":{},"jsonrpc":"2.0","id":5}
2025-03-10T17:03:19.527Z [demo] [info] Message from server: {"jsonrpc":"2.0","id":5,"result":{"tools":[{"name":"add","inputSchema":{"type":"object","properties":{"a":{"type":"number"},"b":{"type":"number"}},"required":["a","b"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}}]}}
2025-03-10T17:03:19.589Z [demo] [info] Message from client: {"method":"prompts/list","params":{},"jsonrpc":"2.0","id":6}
2025-03-10T17:03:19.589Z [demo] [info] Message from server: {"jsonrpc":"2.0","id":6,"error":{"code":-32601,"message":"Method not found"}}
2025-03-10T17:03:19.603Z [demo] [info] Message from client: {"method":"prompts/list","params":{},"jsonrpc":"2.0","id":7}
// SECOND INSTANCE HERE
2025-03-10T17:03:19.601Z [demo] [info] Initializing server...
2025-03-10T17:03:19.610Z [demo] [info] Message from server: {"jsonrpc":"2.0","id":7,"error":{"code":-32601,"message":"Method not found"}}
2025-03-10T17:03:19.629Z [demo] [info] Server started and connected successfully
2025-03-10T17:03:19.707Z [demo] [info] Message from client: {"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"claude-ai","version":"0.1.0"}},"jsonrpc":"2.0","id":0}
2025-03-10T17:03:20.134Z [demo] [info] Message from server: {"jsonrpc":"2.0","id":0,"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}},"serverInfo":{"name":"Demo","version":"1.0.0"}}}
2025-03-10T17:03:20.134Z [demo] [info] Message from client: {"method":"notifications/initialized","jsonrpc":"2.0"}
2025-03-10T17:03:20.139Z [demo] [info] Message from client: {"method":"resources/list","params":{},"jsonrpc":"2.0","id":1}
2025-03-10T17:03:20.139Z [demo] [info] Message from client: {"method":"tools/list","params":{},"jsonrpc":"2.0","id":2}
2025-03-10T17:03:20.141Z [demo] [info] Message from server: {"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"Method not found"}}
2025-03-10T17:03:20.141Z [demo] [info] Message from client: {"method":"prompts/list","params":{},"jsonrpc":"2.0","id":3}
2025-03-10T17:03:20.142Z [demo] [info] Message from server: {"jsonrpc":"2.0","id":2,"result":{"tools":[{"name":"add","inputSchema":{"type":"object","properties":{"a":{"type":"number"},"b":{"type":"number"}},"required":["a","b"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}}]}}
2025-03-10T17:03:20.143Z [demo] [info] Message from server: {"jsonrpc":"2.0","id":3,"error":{"code":-32601,"message":"Method not found"}}
2025-03-10T17:03:20.200Z [demo] [info] Message from client: {"method":"resources/list","params":{},"jsonrpc":"2.0","id":4}
2025-03-10T17:03:20.200Z [demo] [info] Message from client: {"method":"tools/list","params":{},"jsonrpc":"2.0","id":5}
2025-03-10T17:03:20.201Z [demo] [info] Message from server: {"jsonrpc":"2.0","id":4,"error":{"code":-32601,"message":"Method not found"}}
2025-03-10T17:03:20.201Z [demo] [info] Message from client: {"method":"prompts/list","params":{},"jsonrpc":"2.0","id":6}
2025-03-10T17:03:20.202Z [demo] [info] Message from server: {"jsonrpc":"2.0","id":5,"result":{"tools":[{"name":"add","inputSchema":{"type":"object","properties":{"a":{"type":"number"},"b":{"type":"number"}},"required":["a","b"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}}]}}
2025-03-10T17:03:20.202Z [demo] [info] Message from server: {"jsonrpc":"2.0","id":6,"error":{"code":-32601,"message":"Method not found"}}
Why is this? Is this something about the way that Claude Desktop connects to MPC servers?
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Server Initialized twice[/-][+]Request for info - server Initialized twice?[/+]dunward commentedon Mar 23, 2025
Same here issue. I can't use MCP as server.
caasi commentedon Apr 2, 2025
@dunward I use
kill-portto make sure the first one shutdown properly. But I still have to useCommand+Rto reload Claude Desktop to load my MCP server.KKonstantinov commentedon Nov 16, 2025
Seems Claude related and not mcp server related. Please open a new issue if you experience any issues. Closing as 8m old.