Skip to content

examples/client/simpleStreamableHttp.js hangs on second tool call #530

Closed
@bhosmer-ant

Description

@bhosmer-ant

Describe the bug
When connected to src/server/simpleStreamableHttp.ts, src/client/simpleStreamableHttp.ts will hang on the second tool call.

The proximate cause is the global notificationsToolLastEventId not being reset between tool calls, and can be fixed by adding the following to src/client/simpleStreamableHttp.ts:

diff --git a/src/examples/client/simpleStreamableHttp.ts b/src/examples/client/simpleStreamableHttp.ts
index 4bcaf94..353e952 100644
--- a/src/examples/client/simpleStreamableHttp.ts
+++ b/src/examples/client/simpleStreamableHttp.ts
@@ -552,6 +552,9 @@ async function callTool(name: string, args: Record<string, unknown>): Promise<vo
         console.log(`  ${item.type} content:`, item);
       }
     });
+
+    notificationCount = 0;
+    notificationsToolLastEventId = undefined;
   } catch (error) {
     console.log(`Error calling tool ${name}: ${error}`);
   }

But the real fix is properly handling the client mistakenly sending a resumption token on a fresh tool request.

To Reproduce
Steps to reproduce the behavior:
in terminal 1 (server):

$ npx tsx src/examples/server/simpleStreamableHttp.ts

in terminal 2 (client):

$ npx tsx src/examples/client/simpleStreamableHttp.ts

> greet me
Calling tool 'greet' with args: { name: 'me' }
Tool result:
  Hello, me!

> greet me
Calling tool 'greet' with args: { name: 'me' }

...hangs there until timeout.

Expected behavior
Some sort of "resumption of completed tool request" error.

Logs
Server output:

Logging on server is
MCP Streamable HTTP Server listening on port 3000
Received MCP request: {
  method: 'initialize',
  params: {
    protocolVersion: '2025-03-26',
    capabilities: {},
    clientInfo: { name: 'example-client', version: '1.0.0' }
  },
  jsonrpc: '2.0',
  id: 0
}
Session initialized with ID: 506946fa-89ba-4f33-ac81-713f3c95d0e6
Received MCP request: { method: 'notifications/initialized', jsonrpc: '2.0' }
Establishing new SSE stream for session 506946fa-89ba-4f33-ac81-713f3c95d0e6
Received MCP request: {
  method: 'tools/call',
  params: { name: 'greet', arguments: { name: 'me' } },
  jsonrpc: '2.0',
  id: 1
}
Client reconnecting with Last-Event-ID: cbd79d0f-f8fd-4a83-b42f-3e019ebe2714_1747864424092_k15f32kn

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions