@@ -1660,6 +1660,9 @@ def test_send_request_answers_unregistered_server_request_with_method_not_found
16601660 end
16611661
16621662 def test_send_request_answers_raising_handler_with_internal_error
1663+ original_verbose = $VERBOSE
1664+ $VERBOSE = false
1665+
16631666 request = {
16641667 jsonrpc : "2.0" ,
16651668 id : "test_id" ,
@@ -1671,7 +1674,7 @@ def test_send_request_answers_raising_handler_with_internal_error
16711674 jsonrpc : "2.0" ,
16721675 id : 9 ,
16731676 method : "elicitation/create" ,
1674- params : { } ,
1677+ params : { message : "boom \r \n \e [31m" } ,
16751678 }
16761679 tool_result = { jsonrpc : "2.0" , id : "test_id" , result : { content : [ ] } }
16771680 sse_body = "event: message\n data: #{ server_request . to_json } \n \n " \
@@ -1688,20 +1691,24 @@ def test_send_request_answers_raising_handler_with_internal_error
16881691 expected_error_response = {
16891692 jsonrpc : "2.0" ,
16901693 id : 9 ,
1691- error : { code : -32603 , message : "Internal error handling elicitation/create request: boom " } ,
1694+ error : { code : -32603 , message : "Internal error" } ,
16921695 }
16931696 error_stub = stub_request ( :post , url ) . with (
16941697 body : expected_error_response . to_json ,
16951698 ) . to_return (
16961699 status : 202 , body : "" ,
16971700 )
16981701
1699- client . on_server_request ( "elicitation/create" ) { raise "boom" }
1702+ client . on_server_request ( "elicitation/create" ) { | params | raise params [ "message" ] }
17001703
1701- response = client . send_request ( request : request )
1704+ assert_output ( "" , "MCP::Client::HTTP: error handling elicitation/create request: RuntimeError: \" boom\\ r\\ n\\ e[31m\" \n " ) do
1705+ response = client . send_request ( request : request )
17021706
1703- assert_equal ( { "content" => [ ] } , response [ "result" ] )
1704- assert_requested ( error_stub )
1707+ assert_equal ( { "content" => [ ] } , response [ "result" ] )
1708+ assert_requested ( error_stub )
1709+ end
1710+ ensure
1711+ $VERBOSE = original_verbose
17051712 end
17061713
17071714 def test_send_request_answers_server_request_error_with_its_code
0 commit comments