@@ -157,6 +157,7 @@ fn error_to_user_message(error: &rmcp::RmcpError) -> String {
157157 }
158158 _ => format ! ( "Service error: {}" , err) ,
159159 } ,
160+ _ => format ! ( "Error: {}" , error) ,
160161 }
161162}
162163
@@ -1852,7 +1853,7 @@ async fn spawn_server(
18521853
18531854 logger. log ( "[info] MCP: Using Streaming HTTP transport" . to_string ( ) ) ;
18541855 let transport = rmcp:: transport:: StreamableHttpClientTransport :: with_client (
1855- crate :: ai:: mcp:: http_client:: McpHttpClient ( client. http_client ) ,
1856+ crate :: ai:: mcp:: http_client:: McpHttpClient ( client) ,
18561857 rmcp:: transport:: streamable_http_client:: StreamableHttpClientTransportConfig :: with_uri (
18571858 sse_server. url . clone ( ) ,
18581859 ) ,
@@ -1869,7 +1870,9 @@ async fn spawn_server(
18691870 let client = if headers. is_empty ( ) {
18701871 crate :: ai:: mcp:: http_client:: McpHttpClient :: default ( )
18711872 } else {
1872- crate :: ai:: mcp:: http_client:: McpHttpClient ( build_client_with_headers ( & headers) ?)
1873+ crate :: ai:: mcp:: http_client:: McpHttpClient ( build_client_with_headers (
1874+ & headers,
1875+ ) ?)
18731876 } ;
18741877 rmcp:: transport:: StreamableHttpClientTransport :: with_client (
18751878 client,
@@ -1890,7 +1893,9 @@ async fn spawn_server(
18901893 let client = if headers. is_empty ( ) {
18911894 crate :: ai:: mcp:: http_client:: McpHttpClient :: default ( )
18921895 } else {
1893- crate :: ai:: mcp:: http_client:: McpHttpClient ( build_client_with_headers ( & headers) ?)
1896+ crate :: ai:: mcp:: http_client:: McpHttpClient ( build_client_with_headers (
1897+ & headers,
1898+ ) ?)
18941899 } ;
18951900 rmcp:: transport:: StreamableHttpClientTransport :: with_client (
18961901 client,
@@ -1955,7 +1960,7 @@ async fn spawn_server(
19551960/// The transport to use for MCP.
19561961enum Transport {
19571962 /// The HTTP transport, with an optional authenticated client.
1958- Http ( Option < rmcp :: transport :: auth :: AuthClient < crate :: ai :: mcp :: http_client :: McpHttpClient > > ) ,
1963+ Http ( Option < reqwest :: Client > ) ,
19591964 /// Legacy SSE transport (server responded with 404 to HTTP transport check).
19601965 LegacySse ,
19611966}
@@ -1991,18 +1996,15 @@ async fn determine_transport(
19911996 let spawner = auth_context. spawner . clone ( ) ;
19921997 // Go through the OAuth flow to get an authenticated client.
19931998 // This will first attempt to use cached credentials before starting interactive OAuth.
1994- let ( client, did_require_login) = oauth:: make_authenticated_client ( url, auth_context)
1995- . boxed ( )
1996- . await
1997- . map_err ( rmcp:: RmcpError :: transport_creation :: < ReqwestHttpTransport > ) ?;
1998- let mcp_client = rmcp:: transport:: auth:: AuthClient :: new (
1999- crate :: ai:: mcp:: http_client:: McpHttpClient ( client. http_client ) ,
2000- client. auth_manager . lock ( ) . await . clone ( ) ,
2001- ) ;
2002- let transport = match send_initialize_request ( url, headers, Some ( & mcp_client) ) . await ? {
2003- StatusCode :: OK => Ok ( Transport :: Http ( Some ( client) ) ) ,
1999+ let ( auth_client, did_require_login) =
2000+ oauth:: make_authenticated_client ( url, auth_context)
2001+ . boxed ( )
2002+ . await
2003+ . map_err ( rmcp:: RmcpError :: transport_creation :: < ReqwestHttpTransport > ) ?;
2004+ let transport = match send_initialize_request ( url, headers, Some ( & auth_client) ) . await ? {
2005+ StatusCode :: OK => Ok ( Transport :: Http ( Some ( auth_client. http_client . clone ( ) ) ) ) ,
20042006 StatusCode :: NOT_FOUND | StatusCode :: METHOD_NOT_ALLOWED => {
2005- Ok ( Transport :: Http ( Some ( client ) ) )
2007+ Ok ( Transport :: Http ( Some ( auth_client . http_client . clone ( ) ) ) )
20062008 }
20072009 other => Err ( unexpected_error ( other) ) ,
20082010 } ;
@@ -2034,7 +2036,7 @@ async fn determine_transport(
20342036async fn send_initialize_request (
20352037 url : & str ,
20362038 headers : & std:: collections:: HashMap < String , String > ,
2037- auth_client : Option < & rmcp:: transport:: auth:: AuthClient < crate :: ai :: mcp :: http_client :: McpHttpClient > > ,
2039+ auth_client : Option < & rmcp:: transport:: auth:: AuthClient < reqwest :: Client > > ,
20382040) -> Result < reqwest:: StatusCode , rmcp:: RmcpError > {
20392041 use rmcp:: transport:: common:: http_header:: { EVENT_STREAM_MIME_TYPE , JSON_MIME_TYPE } ;
20402042
0 commit comments