refactor(mcp): clarify Fabro server settings type

This commit is contained in:
Bryan Helmkamp 2026-05-11 12:16:51 -04:00
parent 6a11cdd7fc
commit b39738af7f
No known key found for this signature in database
3 changed files with 10 additions and 10 deletions

View file

@ -26,7 +26,7 @@ pub(crate) async fn dispatch(ns: McpNamespace, base_ctx: &CommandContext) -> Res
fn server_settings(
base_ctx: &CommandContext,
connection: &ServerConnectionArgs,
) -> Result<fabro_mcp_server::McpServerSettings> {
) -> Result<fabro_mcp_server::FabroMcpServerSettings> {
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(),

View file

@ -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<String>,
pub storage_dir: PathBuf,

View file

@ -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<McpServerSettings>,
settings: Arc<FabroMcpServerSettings>,
client: Arc<OnceCell<Arc<Client>>>,
cwd: PathBuf,
tool_router: ToolRouter<Self>,
}
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<McpServerSettings>) -> Self {
pub(crate) fn new(settings: Arc<FabroMcpServerSettings>) -> Self {
let cwd = settings.cwd.clone();
Self {
settings,
@ -186,7 +186,7 @@ impl FabroMcpServer {
}
}
async fn client_from_settings(settings: &McpServerSettings) -> Result<Client> {
async fn client_from_settings(settings: &FabroMcpServerSettings) -> Result<Client> {
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<Client> {
connect_local_server(settings).await
}
async fn connect_target(server: &str, settings: &McpServerSettings) -> Result<Client> {
async fn connect_target(server: &str, settings: &FabroMcpServerSettings) -> Result<Client> {
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<Cl
.context("failed to connect Fabro API")
}
async fn connect_local_server(settings: &McpServerSettings) -> Result<Client> {
async fn connect_local_server(settings: &FabroMcpServerSettings) -> Result<Client> {
let bind = ensure_local_server_running(&settings.storage_dir, &settings.config_path).await?;
match bind {
Bind::Unix(path) => {