use std::path::PathBuf;
use anyhow::{Context, Result};
use rmcp::{transport::io::stdio, ServiceExt};
use crate::mcp::tools::GitCortexServer;
pub async fn serve(repo_root: PathBuf, compact: bool) -> Result<()> {
let handler = GitCortexServer::new_with_mode(&repo_root, compact)
.context("failed to open graph store")?;
let transport = stdio();
tracing::info!("GitCortex MCP server started (stdio, compact={compact})");
let service = handler.serve(transport).await.context("MCP server error")?;
service.waiting().await.context("MCP server stopped")?;
Ok(())
}