diff --git a/crates/rmcp/CHANGELOG.md b/crates/rmcp/CHANGELOG.md index f80104a5..73d25ce6 100644 --- a/crates/rmcp/CHANGELOG.md +++ b/crates/rmcp/CHANGELOG.md @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- *(oauth)* support suffixed and preffixed well-knonw paths ([#459](https://github.com/modelcontextprotocol/rust-sdk/pull/459)) +- *(oauth)* support suffixed and prefixed well-known paths ([#459](https://github.com/modelcontextprotocol/rust-sdk/pull/459)) - generate default schema for tools with no params ([#446](https://github.com/modelcontextprotocol/rust-sdk/pull/446)) ### Other diff --git a/crates/rmcp/src/transport/streamable_http_client.rs b/crates/rmcp/src/transport/streamable_http_client.rs index 86b9b3a1..65ac3435 100644 --- a/crates/rmcp/src/transport/streamable_http_client.rs +++ b/crates/rmcp/src/transport/streamable_http_client.rs @@ -173,6 +173,7 @@ struct StreamableHttpClientReconnect { pub client: C, pub session_id: Arc, pub uri: Arc, + pub auth_header: Option, } impl SseStreamReconnect for StreamableHttpClientReconnect { @@ -182,10 +183,11 @@ impl SseStreamReconnect for StreamableHttpClientReconne let client = self.client.clone(); let uri = self.uri.clone(); let session_id = self.session_id.clone(); + let auth_header = self.auth_header.clone(); let last_event_id = last_event_id.map(|s| s.to_owned()); Box::pin(async move { client - .get_stream(uri, session_id, last_event_id, None) + .get_stream(uri, session_id, last_event_id, auth_header) .await }) } @@ -324,10 +326,12 @@ impl Worker for StreamableHttpClientWorker { let client = self.client.clone(); let session_id = session_id.clone(); let url = config.uri.clone(); + let auth_header = config.auth_header.clone(); tokio::spawn(async move { ct.cancelled().await; - let delete_session_result = - client.delete_session(url, session_id.clone(), None).await; + let delete_session_result = client + .delete_session(url, session_id.clone(), auth_header.clone()) + .await; match delete_session_result { Ok(_) => { tracing::info!(session_id = session_id.as_ref(), "delete session success") @@ -376,7 +380,12 @@ impl Worker for StreamableHttpClientWorker { if let Some(session_id) = &session_id { match self .client - .get_stream(config.uri.clone(), session_id.clone(), None, None) + .get_stream( + config.uri.clone(), + session_id.clone(), + None, + config.auth_header.clone(), + ) .await { Ok(stream) => { @@ -386,6 +395,7 @@ impl Worker for StreamableHttpClientWorker { client: self.client.clone(), session_id: session_id.clone(), uri: config.uri.clone(), + auth_header: config.auth_header.clone(), }, self.config.retry_config.clone(), ); @@ -468,6 +478,7 @@ impl Worker for StreamableHttpClientWorker { client: self.client.clone(), session_id: session_id.clone(), uri: config.uri.clone(), + auth_header: config.auth_header.clone(), }, self.config.retry_config.clone(), ); @@ -704,7 +715,7 @@ impl StreamableHttpClientTransportConfig { /// /// # Arguments /// - /// * `value` - The value to set + /// * `value` - A bearer token without the `Bearer ` prefix pub fn auth_header>(mut self, value: T) -> Self { // set our authorization header self.auth_header = Some(value.into());