Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions src/adapters/mcp/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,24 +137,6 @@ impl McpStdioClient {
self.transport.kill_and_wait(timeout).await
}

pub async fn take_tool_list_changed(&mut self) -> bool {
let notifications = self.transport.drain_notifications().await;
let mut tool_list_changed = false;

for notification in notifications {
if notification.method == "notifications/tools/list_changed" {
tool_list_changed = true;
} else {
tracing::debug!(
method = %notification.method,
"Ignoring unsupported MCP stdio notification"
);
}
}

tool_list_changed
}

pub async fn drain_notifications(&mut self) -> Vec<JsonRpcNotification> {
self.transport.drain_notifications().await
}
Expand Down
19 changes: 16 additions & 3 deletions src/adapters/mcp/http_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ pub enum ProbeAuthFailureCode {
pub struct McpHttpTransport {
/// HTTP client
client: Client,
/// Dedicated client for the long-lived SSE event stream so it does not
/// contend with regular JSON-RPC POST requests on the same session.
event_stream_client: Client,
/// Server URL
server_url: String,
/// Request ID counter
Expand Down Expand Up @@ -159,9 +162,14 @@ impl McpHttpTransport {

let client =
build_resilient_http_client(std::time::Duration::from_secs(30), "MCP HTTP transport")?;
let event_stream_client = build_resilient_http_client(
std::time::Duration::from_secs(LEGACY_SSE_STREAM_TIMEOUT_SECS),
"MCP HTTP event stream",
)?;

Ok(Self {
client,
event_stream_client,
server_url: url,
next_id: Arc::new(Mutex::new(1i64)),
session_id: Arc::new(Mutex::new(None)),
Expand Down Expand Up @@ -1012,8 +1020,6 @@ impl McpHttpTransport {
}

pub async fn subscribe_resource(&self, uri: &str) -> Result<()> {
self.ensure_event_stream().await?;

let params = serde_json::json!({
"uri": uri
});
Expand Down Expand Up @@ -1151,7 +1157,7 @@ impl McpHttpTransport {
let resolved = Self::resolve_request_auth("GET", &self.server_url, profile.as_ref())?;

let mut req = self
.client
.event_stream_client
.get(&resolved.url)
.header("Accept", "text/event-stream");
if let Some(session_id) = session_id {
Expand Down Expand Up @@ -1789,6 +1795,13 @@ impl McpRemoteTransport {
}
}

pub async fn ensure_notification_stream(&self) -> Result<()> {
match self {
Self::Streamable(transport) => transport.ensure_event_stream().await,
Self::Legacy(_) => Ok(()),
}
}

pub async fn unsubscribe_resource(&self, uri: &str) -> Result<()> {
match self {
Self::Streamable(transport) => transport.unsubscribe_resource(uri).await,
Expand Down
Loading
Loading