use anyhow::Result;
use nexus::server::stdio::run_stdio;
use nexus::server::NexusServer;

pub fn handle(http: bool, port: u16) -> Result<()> {
    let server = NexusServer::default();
    if http {
        let rt = tokio::runtime::Runtime::new()?;
        rt.block_on(nexus::server::http::run_http(server, port))?;
    } else {
        eprintln!("bctx mcp: stdio transport active — waiting for MCP JSON-RPC on stdin");
        run_stdio(&server)?;
    }
    Ok(())
}
