feat: add support for custom HTTP headers in StreamableHttpClient (#655)

* feat: add support for custom HTTP headers in StreamableHttpClient

* feat: implement reserved header checks for custom HTTP headers in StreamableHttpClient
This commit is contained in:
Arc 2026-02-14 01:28:55 +08:00 • committed by GitHub
commit 016b7d3bfa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -16,6 +16,8 @@ use thiserror::Error;
use tokio::sync::{Mutex, RwLock};
use tracing::{debug, error, warn};
use crate::transport::common::http_header::HEADER_MCP_PROTOCOL_VERSION;
const DEFAULT_EXCHANGE_URL: &str = "http://localhost";
/// Stored credentials for OAuth2 authorization
@ -1068,7 +1070,7 @@ impl AuthorizationManager {
let response = match self
.http_client
.get(discovery_url.clone())
.header("MCP-Protocol-Version", "2024-11-05")
.header(HEADER_MCP_PROTOCOL_VERSION, "2024-11-05")
.send()
.await
{
@ -1188,7 +1190,7 @@ impl AuthorizationManager {
let response = match self
.http_client
.get(url.clone())
.header("MCP-Protocol-Version", "2024-11-05")
.header(HEADER_MCP_PROTOCOL_VERSION, "2024-11-05")
.send()
.await
{
@ -1241,7 +1243,7 @@ impl AuthorizationManager {
let response = match self
.http_client
.get(resource_metadata_url.clone())
.header("MCP-Protocol-Version", "2024-11-05")
.header(HEADER_MCP_PROTOCOL_VERSION, "2024-11-05")
.send()
.await
{