feat: add connection timeout setting
This commit is contained in:
parent
c8d9592ab8
commit
54e0f9b595
@ -490,7 +490,7 @@ async fn schedule_mcp_start_task<R: Runtime>(
|
|||||||
reqwest::Client::builder()
|
reqwest::Client::builder()
|
||||||
.default_headers({
|
.default_headers({
|
||||||
// Map envs to request headers
|
// Map envs to request headers
|
||||||
let mut headers = reqwest::header::HeaderMap::new();
|
let mut headers: tauri::http::HeaderMap = reqwest::header::HeaderMap::new();
|
||||||
for (key, value) in config_params.envs.iter() {
|
for (key, value) in config_params.envs.iter() {
|
||||||
if let Some(v_str) = value.as_str() {
|
if let Some(v_str) = value.as_str() {
|
||||||
// Try to map env keys to HTTP header names (case-insensitive)
|
// Try to map env keys to HTTP header names (case-insensitive)
|
||||||
@ -508,6 +508,7 @@ async fn schedule_mcp_start_task<R: Runtime>(
|
|||||||
}
|
}
|
||||||
headers
|
headers
|
||||||
})
|
})
|
||||||
|
.connect_timeout(config_params.timeout.unwrap_or(Duration::MAX))
|
||||||
.build()
|
.build()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
StreamableHttpClientTransportConfig {
|
StreamableHttpClientTransportConfig {
|
||||||
@ -572,6 +573,7 @@ async fn schedule_mcp_start_task<R: Runtime>(
|
|||||||
}
|
}
|
||||||
headers
|
headers
|
||||||
})
|
})
|
||||||
|
.connect_timeout(config_params.timeout.unwrap_or(Duration::MAX))
|
||||||
.build()
|
.build()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
rmcp::transport::sse_client::SseClientConfig {
|
rmcp::transport::sse_client::SseClientConfig {
|
||||||
@ -724,12 +726,14 @@ pub fn extract_command_args(config: &Value) -> Option<McpServerConfig> {
|
|||||||
let args = obj.get("args")?.as_array()?.clone();
|
let args = obj.get("args")?.as_array()?.clone();
|
||||||
let url = obj.get("url").and_then(|u| u.as_str()).map(String::from);
|
let url = obj.get("url").and_then(|u| u.as_str()).map(String::from);
|
||||||
let transport_type = obj.get("type").and_then(|t| t.as_str()).map(String::from);
|
let transport_type = obj.get("type").and_then(|t| t.as_str()).map(String::from);
|
||||||
|
let timeout = obj.get("timeout").and_then(|t| t.as_u64()).map(Duration::from_secs);
|
||||||
let envs = obj
|
let envs = obj
|
||||||
.get("env")
|
.get("env")
|
||||||
.unwrap_or(&Value::Object(serde_json::Map::new()))
|
.unwrap_or(&Value::Object(serde_json::Map::new()))
|
||||||
.as_object()?
|
.as_object()?
|
||||||
.clone();
|
.clone();
|
||||||
Some(McpServerConfig {
|
Some(McpServerConfig {
|
||||||
|
timeout,
|
||||||
transport_type,
|
transport_type,
|
||||||
url,
|
url,
|
||||||
command,
|
command,
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
@ -9,6 +11,7 @@ pub struct McpServerConfig {
|
|||||||
pub command: String,
|
pub command: String,
|
||||||
pub args: Vec<Value>,
|
pub args: Vec<Value>,
|
||||||
pub envs: serde_json::Map<String, Value>,
|
pub envs: serde_json::Map<String, Value>,
|
||||||
|
pub timeout: Option<Duration>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tool with server information
|
/// Tool with server information
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user