use clap::Parser;
use nusy_codegraph::mcp_bridge::McpBridge;
#[derive(Parser)]
#[command(name = "nusy-mcp-bridge", about = "Generic MCP-to-NATS bridge")]
struct Args {
#[arg(long, default_value = "nats://localhost:4222")]
nats: String,
#[arg(long, default_value = "codegraph")]
services: String,
#[arg(long, default_value = "5000")]
timeout_ms: u64,
}
#[tokio::main]
async fn main() -> Result<(), String> {
tracing_subscriber::fmt()
.with_writer(std::io::stderr)
.with_env_filter(
tracing_subscriber::EnvFilter::from_default_env()
.add_directive("nusy_codegraph=info".parse().unwrap()),
)
.init();
let args = Args::parse();
let mut bridge = McpBridge::new(&args.nats).timeout_ms(args.timeout_ms);
for service in args.services.split(',') {
let service = service.trim();
match service {
"codegraph" => {
bridge = bridge.service("codegraph.cmd", "code_");
}
other => {
eprintln!("warning: unknown service '{other}', skipping");
}
}
}
bridge.run_stdio().await
}