Repository navigation
Replies: 2 comments
|
The transport specification defines an MCP session between a client and server; it does not promise one session per chat conversation. That does not explain the Claude Desktop change, but it means the transport session ID alone is a fragile key for your application's run. A workaround would be to pass an explicit application ID:
Scope each lookup to the authenticated owner. Keep the normal session-header handling; the application ID is an additional correlation key. The SDK documents a similar stable view-ID pattern, including passing the ID back to app-only tools. Applying it to your run mapping is a suggested workaround; I have not reproduced the Claude Desktop regression. |
|
I think the issue comes from treating the MCP transport session as if it represents the entire application conversation. From your example, the model and the app iframe aren't necessarily using the same transport lifecycle. The model calls Both requests can be valid individually, but the mapping fails because you're storing the automation run against the transport session ID. I wouldn't try to force those sessions to match. Even if that restores the behavior in the current Claude Desktop version, it could break again when the host reconnects or creates another client connection. I'd separate the two identifiers. Keep For example: When the app view is created, generate a When Then have the iframe call The storage relationship becomes: For a Next.js backend, I'd keep this mapping in a shared database or Redis rather than an in-memory variable. Otherwise, separate serverless instances could introduce a second problem where the mapping exists on one instance but not another. I'd also add a TTL, verify ownership on every lookup, and make repeated start requests idempotent so reconnects don't accidentally launch the same automation twice. To confirm whether this is the actual issue, I'd log the MCP session ID, application view ID, run ID, and authenticated user for each relevant request. You should be able to see whether both transport sessions are referring to the same application view. One additional point: the newer MCP protocol revision removes protocol-level sessions altogether, which makes application-owned correlation IDs a better long-term design. I haven't reproduced the specific Claude Desktop behavior, so I'd still consider the unexpected extra initialization worth reporting separately. But I wouldn't rely on one session ID per conversation as the foundation for run tracking. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
initializeis being called multiple times within a single conversation, resulting in multipleMcp-Session-Idvalues. My server relies onMcp-Session-Idto link requests together (per the spec), and this was working ~3 days ago — but something changed and now it's broken.What I'm seeing
sequenceDiagram participant Host as Host (Claude Desktop) participant Server as MCP Server Note over Host,Server: Before conversation starts Host->>Server: POST initialize Server-->>Host: Mcp-Session-Id: aaa-111 Host->>Server: POST resources/read<br/>Mcp-Session-Id: aaa-111 Server-->>Host: HTML (app UI) Host->>Server: POST tools/call (discover_run)<br/>Mcp-Session-Id: aaa-111 Server-->>Host: { runId: null } (no run yet, expected) Note over Host,Server: User types prompt... Note over Host,Server: Second initialize — unexpected! Host->>Server: POST initialize Server-->>Host: Mcp-Session-Id: bbb-222 Host->>Server: POST tools/call (run_web_automation)<br/>Mcp-Session-Id: bbb-222 Note over Server: Stores run under bbb-222 ✅ Host->>Server: POST tools/call (discover_run)<br/>Mcp-Session-Id: aaa-111 Note over Server: Looks up aaa-111 → null ❌<br/>(run is under bbb-222)My server stores a session→run mapping on
run_web_automation, then the MCP App iframe callsdiscover_runto find that run. Becausediscover_runstill uses the first session (aaa-111) but the run was stored under the second session (bbb-222), the lookup fails and the app can't show live status/screenshots.What I'd expect
One
initializeper conversation → oneMcp-Session-Idshared across model and app tool calls.Happy to share server logs and more details if helpful.
Environment
@modelcontextprotocol/ext-appsAll reactions