Skip to content

Fix StreamableHttp example for tool calls - have a separate option for testing notifications resumption #534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025

Conversation

ihrpr
Copy link
Contributor

@ihrpr ihrpr commented May 22, 2025

#530
#396

Testing

Connecting to http://localhost:3000/mcp...
Transport created with session ID: f70902b5-0284-44f8-979b-bc24516cf19d
Connected to MCP server

Available commands:
  connect [url]              - Connect to MCP server (default: http://localhost:3000/mcp)
  disconnect                 - Disconnect from server
  terminate-session          - Terminate the current session
  reconnect                  - Reconnect to the server
  list-tools                 - List available tools
  call-tool <name> [args]    - Call a tool with optional JSON arguments
  greet [name]               - Call the greet tool
  multi-greet [name]         - Call the multi-greet tool with notifications
  start-notifications [interval] [count] - Start periodic notifications
  run-notifications-tool-with-resumability [interval] [count] - Run notification tool with resumability
  list-prompts               - List available prompts
  get-prompt [name] [args]   - Get a prompt with optional JSON arguments
  list-resources             - List available resources
  help                       - Show this help
  quit                       - Exit the program

>  run-notifications-tool-with-resumability
Starting notification stream with resumability: interval=2000ms, count=10
Using resumption token: none
Updated resumption token: c93ab4a9-dc8e-482d-8975-a235df9bdb0c_1747906592986_dudcdt6h

Notification #1: info - Periodic notification #1 at 2025-05-22T09:36:32.986Z
> Updated resumption token: c93ab4a9-dc8e-482d-8975-a235df9bdb0c_1747906594987_ojylxu03

Notification #2: info - Periodic notification #2 at 2025-05-22T09:36:34.987Z
> 
ESC key pressed. Disconnecting from server...
Error starting notification stream: McpError: MCP error -32000: Connection closed
Disconnected from MCP server

> Disconnected. Press Enter to continue.
> Client error: Error: SSE stream disconnected: AbortError: This operation was aborted
    at processStream (/Users/inna/code/mcp/typescript-sdk/src/client/streamableHttp.ts:319:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) 
Client error: Error: SSE stream disconnected: AbortError: This operation was aborted
    at processStream (/Users/inna/code/mcp/typescript-sdk/src/client/streamableHttp.ts:319:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) 


>  run-notifications-tool-with-resumability
Not connected to server.

> connect
Connecting to http://localhost:3000/mcp...
Transport created with session ID: f70902b5-0284-44f8-979b-bc24516cf19d
Connected to MCP server

>  run-notifications-tool-with-resumability
Starting notification stream with resumability: interval=2000ms, count=10
Using resumption token: c93ab4a9-dc8e-482d-8975-a235df9bdb0c_1747906594987_ojylxu03

Notification #3: info - Periodic notification #3 at 2025-05-22T09:36:36.988Z
> 
Notification #4: info - Periodic notification #4 at 2025-05-22T09:36:38.989Z
> 
Notification #5: info - Periodic notification #5 at 2025-05-22T09:36:40.991Z
> 
Notification #6: info - Periodic notification #6 at 2025-05-22T09:36:42.993Z
> 
Notification #7: info - Periodic notification #7 at 2025-05-22T09:36:44.996Z
> 
Notification #8: info - Periodic notification #8 at 2025-05-22T09:36:46.998Z
> 
Notification #9: info - Periodic notification #9 at 2025-05-22T09:36:49.000Z
> 
Notification #10: info - Periodic notification #10 at 2025-05-22T09:36:51.001Z
> Tool result:
  Started sending periodic notifications every 2000ms

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

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

@ihrpr ihrpr requested a review from bhosmer-ant May 22, 2025 09:48
@ihrpr ihrpr merged commit c69168c into main May 22, 2025
5 checks passed
@ihrpr ihrpr deleted the ihrpr/fix-example-shttp branch May 22, 2025 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants