modelcontextprotocol/typescript-sdk

Tool calls missing `sessionId` from ToolCallback `extra` parameter are hanging

Closed this issue · 3 comments

Describe the bug
When using Claude I noticed some tool calls failing or timing out, since Claude would just hang. Since I was using the extra.sessionId to pass dynamic data to the tools, I noticed that extra.sessionId was missing on these requests, but logging the full extra object, I would see that the sessionId was in the request info:

{
signal: {},
requestId: 4,
requestInfo: {
headers: {
host: "...",
"user-agent": "Claude-User",
"content-length": "155",
accept: "application/json, text/event-stream",
"accept-encoding": "gzip, deflate, br",
"content-type": "application/json",
"mcp-protocol-version": "2025-06-18",
"mcp-session-id": "1b505b13-665b-4061-bcd0-091e77f81d05",
traceparent: "00-d62d5dfcf35b8b459c63012315fb10eb-717883b60bb01835-00",
"x-cloud-trace-context": "d62d5dfcf35b8b459c63012315fb10eb/8176429941394511925;o=0",
"x-forwarded-for": "...",
"x-forwarded-host": "...",
"x-forwarded-proto": "https"
}
}
};

This seems to happen though only when using it with ChatGPT, at least that's how it happens to me. So asking both Claude and ChatGPT some questions, not necessarily the same, in parallel.

To Reproduce
Steps to reproduce the behavior don't seem to be consistent but:

  1. I would ask either Claude or ChatGPT something
  2. Ask the same to the other one.
  3. Continue this and in 2-3 questions this would happen with Claude's requests hanging and noticing this difference of sessionId missing from extra while still being in requestInfo

Expected behavior
The tools to be called without any interruptions

Logs
I think the useful log is the full extra log from above for any relevant data.

Additional context
The ChatGPT parallel issue. I thought that maybe ChatGPT was deleting the session id (and somehow it had the same one as Claude), but logging I don't see the session id from Claude being used. Besides, I have checks in place that if a session id comes that is not in memory, I return an error.

Hi @Ncifra , would you please be able to provide a self-contained reproductible test case?

Hi @ochafik. Okay, I will try to reproduce minimally and test if it behaves erratically. Thanks

Okay, it seems not only can I not reproduce this with a minimal case, but also the previous issue I had doesn't seem to happen again. Could be intermittent issues from Claude, since I had before with ChatGPT too issues understanding the responses if I used a single server instance. Closing