Skip to content

Commit efb7689

Browse files
committed
Fix handling response when sending notifications in examples/streamable_http_client.rb
Even though the 'tools/call' request to 'notification_tool' is successful and an 'MCP::Tool::Response' is returned, the logger still prints 'Error:'. ``` % ruby examples/streamable_http_client.rb === MCP SSE Test Client === [CLIENT] INFO 15:41:04.696 - Initializing session... [CLIENT] INFO 15:41:04.698 - Session initialized: SESSION_ID [CLIENT] INFO 15:41:04.698 - Server info: {"name" => "sse_test_server", "version" => "0.1.0"} [CLIENT] INFO 15:41:04.698 - Connecting to SSE stream... [CLIENT] INFO 15:41:04.698 - SSE stream connected successfully === Available Actions === 1. Send custom notification 2. Test echo 3. List tools 0. Exit Choose an action: 1 Enter notification message: notification test Enter delay in seconds (0 for immediate): [CLIENT] INFO 15:41:11.248 - SSE data: {"jsonrpc":"2.0","id":"0f657eeb-3e05-47bb-b7b4-898e2cb503af","result":{"content":[{"type":"text","text":"Notification: notification test (timestamp: 2025-06-21T15:41:11+09:00)"}],"isError":false}} [CLIENT] ERROR 15:41:11.249 - Error: === Available Actions === 1. Send custom notification 2. Test echo 3. List tools 0. Exit ``` It is probably trying to output an MCP::Tool::Response, but these appear in the SSE stream. Therefore, the response it is handling this time should either be accepted or an error. I modified it so that it could handle them.
1 parent 0fe0289 commit efb7689

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

examples/streamable_http_client.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,8 @@ def main
163163
},
164164
},
165165
)
166-
167-
if response[:body]["result"]
168-
logger.info("Notification tool response: #{response[:body]["result"]["content"]}")
166+
if response[:body]["accepted"]
167+
logger.info("Notification was sent successfully")
169168
else
170169
logger.error("Error: #{response[:body]["error"]}")
171170
end

0 commit comments

Comments
 (0)