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
11 changes: 11 additions & 0 deletions assets/settings/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -2253,6 +2253,17 @@
"ssh_connections": [],
// Whether to read ~/.ssh/config for ssh connection sources.
"read_ssh_config": true,
// Default timeout in seconds for all context server tool calls.
// Individual servers can override this in their configuration.
// Examples:
// "context_servers": {
// "my-stdio-server": {
// "command": "/path/to/server",
// "timeout": 120 // Override: 2 minutes for this server
// },
// }
// Default: 60
"context_server_timeout": 60,
// Configures context servers for use by the agent.
"context_servers": {},
// Configures agent servers available in the agent panel.
Expand Down
1 change: 1 addition & 0 deletions crates/agent_servers/src/acp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ impl AgentConnection for AcpConnection {
project::context_server_store::ContextServerConfiguration::Http {
url,
headers,
timeout: _,
} => Some(acp::McpServer::Http(
acp::McpServerHttp::new(id.0.to_string(), url.to_string()).headers(
headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ impl ConfigurationSource {
enabled: true,
url,
headers: auth,
timeout: None,
},
)
})
Expand Down Expand Up @@ -411,6 +412,7 @@ impl ConfigureContextServerModal {
enabled: _,
url,
headers,
timeout: _,
} => Some(ConfigurationTarget::ExistingHttp {
id: server_id,
url,
Expand Down
2 changes: 1 addition & 1 deletion crates/context_server/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl Client {
.map(|name| name.to_string_lossy().into_owned())
.unwrap_or_else(String::new);

let timeout = binary.timeout.map(Duration::from_millis);
let timeout = binary.timeout.map(Duration::from_secs);
let transport = Arc::new(StdioTransport::new(binary, working_directory, &cx)?);
Self::new(server_id, server_name.into(), transport, timeout, cx)
}
Expand Down
17 changes: 15 additions & 2 deletions crates/context_server/src/context_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use collections::HashMap;
use http_client::HttpClient;
use std::path::Path;
use std::sync::Arc;
use std::time::Duration;
use std::{fmt::Display, path::PathBuf};

use anyhow::Result;
Expand Down Expand Up @@ -39,6 +40,7 @@ pub struct ContextServer {
id: ContextServerId,
client: RwLock<Option<Arc<crate::protocol::InitializedContextServerProtocol>>>,
configuration: ContextServerTransport,
request_timeout: Option<Duration>,
}

impl ContextServer {
Expand All @@ -54,6 +56,7 @@ impl ContextServer {
command,
working_directory.map(|directory| directory.to_path_buf()),
),
request_timeout: None,
}
}

Expand All @@ -63,6 +66,7 @@ impl ContextServer {
headers: HashMap<String, String>,
http_client: Arc<dyn HttpClient>,
executor: gpui::BackgroundExecutor,
request_timeout: Option<Duration>,
) -> Result<Self> {
let transport = match endpoint.scheme() {
"http" | "https" => {
Expand All @@ -73,14 +77,23 @@ impl ContextServer {
}
_ => anyhow::bail!("unsupported MCP url scheme {}", endpoint.scheme()),
};
Ok(Self::new(id, transport))
Ok(Self::new_with_timeout(id, transport, request_timeout))
}

pub fn new(id: ContextServerId, transport: Arc<dyn crate::transport::Transport>) -> Self {
Self::new_with_timeout(id, transport, None)
}

pub fn new_with_timeout(
id: ContextServerId,
transport: Arc<dyn crate::transport::Transport>,
request_timeout: Option<Duration>,
) -> Self {
Self {
id,
client: RwLock::new(None),
configuration: ContextServerTransport::Custom(transport),
request_timeout,
}
}

Expand Down Expand Up @@ -113,7 +126,7 @@ impl ContextServer {
client::ContextServerId(self.id.0.clone()),
self.id().0,
transport.clone(),
None,
self.request_timeout,
cx.clone(),
)?,
})
Expand Down
Loading