@@ -87,12 +87,14 @@ async fn stream_to_multiplex() {
8787 ) ;
8888
8989 let ctr = client
90- . call_tool ( rmcp:: model:: CallToolRequestParams {
91- meta : None ,
92- task : None ,
93- name : "mcp_echo" . into ( ) ,
94- arguments : serde_json:: json!( { "hi" : "world" } ) . as_object ( ) . cloned ( ) ,
95- } )
90+ . call_tool (
91+ rmcp:: model:: CallToolRequestParams :: new ( "mcp_echo" ) . with_arguments (
92+ serde_json:: json!( { "hi" : "world" } )
93+ . as_object ( )
94+ . cloned ( )
95+ . unwrap ( ) ,
96+ ) ,
97+ )
9698 . await
9799 . unwrap ( ) ;
98100 assert_eq ! (
@@ -101,12 +103,14 @@ async fn stream_to_multiplex() {
101103 ) ;
102104
103105 let ctr = client
104- . call_tool ( rmcp:: model:: CallToolRequestParams {
105- meta : None ,
106- task : None ,
107- name : "sse_echo" . into ( ) ,
108- arguments : serde_json:: json!( { "hi" : "world" } ) . as_object ( ) . cloned ( ) ,
109- } )
106+ . call_tool (
107+ rmcp:: model:: CallToolRequestParams :: new ( "sse_echo" ) . with_arguments (
108+ serde_json:: json!( { "hi" : "world" } )
109+ . as_object ( )
110+ . cloned ( )
111+ . unwrap ( ) ,
112+ ) ,
113+ )
110114 . await
111115 . unwrap ( ) ;
112116 assert_eq ! (
@@ -117,12 +121,14 @@ async fn stream_to_multiplex() {
117121 // No target set...
118122 assert ! (
119123 client
120- . call_tool( rmcp:: model:: CallToolRequestParams {
121- meta: None ,
122- task: None ,
123- name: "echo" . into( ) ,
124- arguments: serde_json:: json!( { "hi" : "world" } ) . as_object( ) . cloned( ) ,
125- } )
124+ . call_tool(
125+ rmcp:: model:: CallToolRequestParams :: new( "echo" ) . with_arguments(
126+ serde_json:: json!( { "hi" : "world" } )
127+ . as_object( )
128+ . cloned( )
129+ . unwrap( ) ,
130+ ) ,
131+ )
126132 . await
127133 . is_err( )
128134 ) ;
@@ -158,12 +164,14 @@ async fn stream_to_stream_single_tls() {
158164 . await ;
159165 let client = mcp_streamable_client ( io) . await ;
160166 let ctr = client
161- . call_tool ( rmcp:: model:: CallToolRequestParams {
162- meta : None ,
163- task : None ,
164- name : "echo_http" . into ( ) ,
165- arguments : serde_json:: json!( { "hi" : "world" } ) . as_object ( ) . cloned ( ) ,
166- } )
167+ . call_tool (
168+ rmcp:: model:: CallToolRequestParams :: new ( "echo_http" ) . with_arguments (
169+ serde_json:: json!( { "hi" : "world" } )
170+ . as_object ( )
171+ . cloned ( )
172+ . unwrap ( ) ,
173+ ) ,
174+ )
167175 . await
168176 . unwrap ( ) ;
169177 assert_eq ! (
@@ -197,12 +205,14 @@ async fn authorization_denied_returns_unknown_tool_error() {
197205
198206 // Attempt to call a tool - should fail with "Unknown tool" error
199207 let result = client
200- . call_tool ( rmcp:: model:: CallToolRequestParams {
201- meta : None ,
202- task : None ,
203- name : "echo" . into ( ) ,
204- arguments : serde_json:: json!( { "hi" : "world" } ) . as_object ( ) . cloned ( ) ,
205- } )
208+ . call_tool (
209+ rmcp:: model:: CallToolRequestParams :: new ( "echo" ) . with_arguments (
210+ serde_json:: json!( { "hi" : "world" } )
211+ . as_object ( )
212+ . cloned ( )
213+ . unwrap ( ) ,
214+ ) ,
215+ )
206216 . await ;
207217
208218 // The call should fail
@@ -214,22 +224,23 @@ async fn authorization_denied_returns_unknown_tool_error() {
214224 let err = result. unwrap_err ( ) ;
215225
216226 // Verify error code is INVALID_PARAMS (-32602) and message format
217- match & err {
218- rmcp:: ServiceError :: McpError ( mcp_error) => {
219- assert_eq ! (
220- mcp_error. code. 0 , -32602 ,
221- "Expected INVALID_PARAMS error code (-32602), got: {}" ,
222- mcp_error. code. 0
223- ) ;
224- assert_eq ! (
225- mcp_error. message. as_ref( ) ,
226- "Unknown tool: echo" ,
227- "Expected error message 'Unknown tool: echo', got: {}" ,
228- mcp_error. message
229- ) ;
230- } ,
227+ let mcp_error = match & err {
228+ rmcp:: ServiceError :: McpError ( mcp_error) => mcp_error,
229+ // rmcp::ServiceError::TransportSend(d) => d.downcast::(),
231230 other => panic ! ( "Expected ServiceError::McpError, got: {:?}" , other) ,
232- }
231+ } ;
232+
233+ assert_eq ! (
234+ mcp_error. code. 0 , -32602 ,
235+ "Expected INVALID_PARAMS error code (-32602), got: {}" ,
236+ mcp_error. code. 0
237+ ) ;
238+ assert_eq ! (
239+ mcp_error. message. as_ref( ) ,
240+ "Unknown tool: echo" ,
241+ "Expected error message 'Unknown tool: echo', got: {}" ,
242+ mcp_error. message
243+ ) ;
233244}
234245
235246/// Test that getting a prompt denied by MCP authorization policy returns proper JSON-RPC error
@@ -256,11 +267,7 @@ async fn authorization_denied_returns_unknown_prompt_error() {
256267
257268 // Attempt to get a prompt - should fail with "Unknown prompt" error
258269 let result = client
259- . get_prompt ( rmcp:: model:: GetPromptRequestParams {
260- meta : None ,
261- name : "example_prompt" . into ( ) ,
262- arguments : None ,
263- } )
270+ . get_prompt ( rmcp:: model:: GetPromptRequestParams :: new ( "example_prompt" ) )
264271 . await ;
265272
266273 // The call should fail
@@ -314,10 +321,9 @@ async fn authorization_denied_returns_unknown_resource_error() {
314321
315322 // Attempt to read a resource - should fail with "Unknown resource" error
316323 let result = client
317- . read_resource ( rmcp:: model:: ReadResourceRequestParams {
318- meta : None ,
319- uri : "memo://insights" . into ( ) ,
320- } )
324+ . read_resource ( rmcp:: model:: ReadResourceRequestParams :: new (
325+ "memo://insights" ,
326+ ) )
321327 . await ;
322328
323329 // The call should fail
@@ -449,19 +455,10 @@ async fn authorization_deny_with_request_header_filters_per_agent() {
449455 let config = StreamableHttpClientTransportConfig :: with_uri ( format ! ( "http://{addr}/mcp" ) )
450456 . custom_headers ( headers) ;
451457 let transport = StreamableHttpClientTransport :: from_config ( config) ;
452- let client_info = ClientInfo {
453- meta : None ,
454- protocol_version : Default :: default ( ) ,
455- capabilities : ClientCapabilities :: default ( ) ,
456- client_info : Implementation {
457- name : format ! ( "test-{agent_name}" ) ,
458- version : "0.0.1" . to_string ( ) ,
459- title : None ,
460- website_url : None ,
461- icons : None ,
462- description : None ,
463- } ,
464- } ;
458+ let client_info = ClientInfo :: new (
459+ ClientCapabilities :: default ( ) ,
460+ Implementation :: new ( format ! ( "test-{agent_name}" ) , "0.0.1" ) ,
461+ ) ;
465462 client_info
466463 . serve ( transport)
467464 . await
@@ -526,12 +523,14 @@ async fn standard_assertions(client: RunningService<RoleClient, InitializeReques
526523 . collect_vec ( ) ;
527524 assert_eq ! ( t, vec![ "decrement" . to_string( ) , "echo" . to_string( ) ] ) ;
528525 let ctr = client
529- . call_tool ( rmcp:: model:: CallToolRequestParams {
530- meta : None ,
531- task : None ,
532- name : "echo" . into ( ) ,
533- arguments : serde_json:: json!( { "hi" : "world" } ) . as_object ( ) . cloned ( ) ,
534- } )
526+ . call_tool (
527+ rmcp:: model:: CallToolRequestParams :: new ( "echo" ) . with_arguments (
528+ serde_json:: json!( { "hi" : "world" } )
529+ . as_object ( )
530+ . cloned ( )
531+ . unwrap ( ) ,
532+ ) ,
533+ )
535534 . await
536535 . unwrap ( ) ;
537536 assert_eq ! (
@@ -593,19 +592,10 @@ pub async fn mcp_streamable_client(
593592 use rmcp:: transport:: StreamableHttpClientTransport ;
594593 let transport =
595594 StreamableHttpClientTransport :: < reqwest:: Client > :: from_uri ( format ! ( "http://{s}/mcp" ) ) ;
596- let client_info = ClientInfo {
597- meta : None ,
598- protocol_version : Default :: default ( ) ,
599- capabilities : ClientCapabilities :: default ( ) ,
600- client_info : Implementation {
601- name : "test client" . to_string ( ) ,
602- version : "0.0.1" . to_string ( ) ,
603- title : None ,
604- website_url : None ,
605- icons : None ,
606- description : None ,
607- } ,
608- } ;
595+ let client_info = ClientInfo :: new (
596+ ClientCapabilities :: default ( ) ,
597+ Implementation :: new ( "test client" . to_string ( ) , "0.0.1" . to_string ( ) ) ,
598+ ) ;
609599
610600 client_info
611601 . serve ( transport)
@@ -661,6 +651,7 @@ async fn mock_streamable_http_server(stateful: bool) -> MockServer {
661651 sse_retry : None ,
662652 sse_keep_alive : None ,
663653 stateful_mode : stateful,
654+ json_response : false ,
664655 cancellation_token : Default :: default ( ) ,
665656 } ,
666657 ) ;
@@ -842,10 +833,10 @@ mod mockserver {
842833 "This is an example prompt with your message here: '{}'" ,
843834 args. message
844835 ) ;
845- Ok ( vec ! [ PromptMessage {
846- role : PromptMessageRole :: User ,
847- content : PromptMessageContent :: text( prompt) ,
848- } ] )
836+ Ok ( vec ! [ PromptMessage :: new (
837+ PromptMessageRole :: User ,
838+ PromptMessageContent :: text( prompt) ,
839+ ) ] )
849840 }
850841
851842 /// Analyze the current counter value and suggest next steps
@@ -873,30 +864,26 @@ mod mockserver {
873864 ) ,
874865 ] ;
875866
876- Ok ( GetPromptResult {
877- description : Some ( format ! (
878- "Counter analysis for reaching {} from {}" ,
879- args. goal, current_value
880- ) ) ,
881- messages,
882- } )
867+ Ok ( GetPromptResult :: new ( messages) . with_description ( format ! (
868+ "Counter analysis for reaching {} from {}" ,
869+ args. goal, current_value
870+ ) ) )
883871 }
884872 }
885873
886874 #[ tool_handler]
887875 #[ prompt_handler]
888876 impl ServerHandler for Counter {
889877 fn get_info ( & self ) -> ServerInfo {
890- ServerInfo {
891- protocol_version : ProtocolVersion :: V_2025_06_18 ,
892- capabilities : ServerCapabilities :: builder ( )
878+ ServerInfo :: new (
879+ ServerCapabilities :: builder ( )
893880 . enable_prompts ( )
894881 . enable_resources ( )
895882 . enable_tools ( )
896883 . build ( ) ,
897- server_info : Implementation :: from_build_env ( ) ,
898- instructions : Some ( "This server provides counter tools and prompts." . to_string ( ) ) ,
899- }
884+ )
885+ . with_protocol_version ( ProtocolVersion :: V_2025_06_18 )
886+ . with_instructions ( "This server provides counter tools and prompts." )
900887 }
901888
902889 async fn list_resources (
@@ -922,15 +909,15 @@ mod mockserver {
922909 match uri. as_str ( ) {
923910 "str:////Users/to/some/path/" => {
924911 let cwd = "/Users/to/some/path/" ;
925- Ok ( ReadResourceResult {
926- contents : vec ! [ ResourceContents :: text ( cwd, uri) ] ,
927- } )
912+ Ok ( ReadResourceResult :: new ( vec ! [ ResourceContents :: text (
913+ cwd, uri,
914+ ) ] ) )
928915 } ,
929916 "memo://insights" => {
930917 let memo = "Business Intelligence Memo\n \n Analysis has revealed 5 key insights ..." ;
931- Ok ( ReadResourceResult {
932- contents : vec ! [ ResourceContents :: text ( memo, uri) ] ,
933- } )
918+ Ok ( ReadResourceResult :: new ( vec ! [ ResourceContents :: text (
919+ memo, uri,
920+ ) ] ) )
934921 } ,
935922 _ => Err ( McpError :: resource_not_found (
936923 "resource_not_found" ,
0 commit comments