diff --git a/lib/crates/fabro-cli/src/commands/mcp/mod.rs b/lib/crates/fabro-cli/src/commands/mcp/mod.rs index 566a33c17..a18067ada 100644 --- a/lib/crates/fabro-cli/src/commands/mcp/mod.rs +++ b/lib/crates/fabro-cli/src/commands/mcp/mod.rs @@ -26,7 +26,7 @@ pub(crate) async fn dispatch(ns: McpNamespace, base_ctx: &CommandContext) -> Res fn server_settings( base_ctx: &CommandContext, connection: &ServerConnectionArgs, -) -> Result { +) -> Result { let connection_ctx = base_ctx.with_connection(connection)?; let server_target = user_config::resolve_nondefault_server_target( &connection.target, @@ -37,7 +37,7 @@ fn server_settings( .as_unix_socket_path() .map_or_else(|| target.to_string(), |path| path.display().to_string()) }); - Ok(fabro_mcp_server::McpServerSettings { + Ok(fabro_mcp_server::FabroMcpServerSettings { config: config_settings(connection), server_target, storage_dir: connection_ctx.storage_dir().to_path_buf(), diff --git a/lib/crates/fabro-mcp-server/src/lib.rs b/lib/crates/fabro-mcp-server/src/lib.rs index a4291e8f7..db94592c0 100644 --- a/lib/crates/fabro-mcp-server/src/lib.rs +++ b/lib/crates/fabro-mcp-server/src/lib.rs @@ -8,7 +8,7 @@ pub use config::{config_json, init_agent}; pub use server::start; #[derive(Debug, Clone)] -pub struct McpServerSettings { +pub struct FabroMcpServerSettings { pub config: McpConfigSettings, pub server_target: Option, pub storage_dir: PathBuf, diff --git a/lib/crates/fabro-mcp-server/src/server.rs b/lib/crates/fabro-mcp-server/src/server.rs index 7869de858..c381b9348 100644 --- a/lib/crates/fabro-mcp-server/src/server.rs +++ b/lib/crates/fabro-mcp-server/src/server.rs @@ -23,20 +23,20 @@ use tokio::sync::OnceCell; use tokio::task::yield_now; use tokio::time::sleep; -use crate::{McpServerSettings, run_tools}; +use crate::{FabroMcpServerSettings, run_tools}; const CLIENT_REQUEST_TIMEOUT: Duration = Duration::from_secs(30); const SERVER_START_TIMEOUT: Duration = Duration::from_secs(8); #[derive(Clone)] pub(crate) struct FabroMcpServer { - settings: Arc, + settings: Arc, client: Arc>>, cwd: PathBuf, tool_router: ToolRouter, } -pub async fn start(settings: McpServerSettings) -> Result<()> { +pub async fn start(settings: FabroMcpServerSettings) -> Result<()> { let server = FabroMcpServer::new(Arc::new(settings)); let service = serve_server(server, stdio()).await?; service.waiting().await?; @@ -53,7 +53,7 @@ impl ServerHandler for FabroMcpServer { #[tool_router(router = tool_router)] impl FabroMcpServer { - pub(crate) fn new(settings: Arc) -> Self { + pub(crate) fn new(settings: Arc) -> Self { let cwd = settings.cwd.clone(); Self { settings, @@ -186,7 +186,7 @@ impl FabroMcpServer { } } -async fn client_from_settings(settings: &McpServerSettings) -> Result { +async fn client_from_settings(settings: &FabroMcpServerSettings) -> Result { yield_now().await; if let Some(server) = settings.server_target.as_ref() { return connect_target(server, settings).await; @@ -194,7 +194,7 @@ async fn client_from_settings(settings: &McpServerSettings) -> Result { connect_local_server(settings).await } -async fn connect_target(server: &str, settings: &McpServerSettings) -> Result { +async fn connect_target(server: &str, settings: &FabroMcpServerSettings) -> Result { let target: ServerTarget = server.parse()?; let auth_store = AuthStore::default(); let mut credential = resolve_target_credential_with_store(&target, &auth_store)?; @@ -221,7 +221,7 @@ async fn connect_target(server: &str, settings: &McpServerSettings) -> Result Result { +async fn connect_local_server(settings: &FabroMcpServerSettings) -> Result { let bind = ensure_local_server_running(&settings.storage_dir, &settings.config_path).await?; match bind { Bind::Unix(path) => {