wb-mcp exposes the weaveback MCP (Model Context Protocol) server as a standalone binary. It reads JSON-RPC requests from stdin and writes responses to stdout, making it usable directly in MCP client configurations without requiring the full weaveback binary.

CLI

Generated from cli-spec/wb-mcp-cli.adoc.

// <<wb-mcp-cli>>=
mod cli_generated;
use cli_generated::Cli;
use clap::Parser;
// @

Main

// <<wb-mcp-main>>=
fn default_pathsep() -> String {
    if cfg!(windows) { ";".to_string() } else { ":".to_string() }
}

fn main() {
    let cli = Cli::parse();

    let pathsep = default_pathsep();
    let include_paths: Vec<std::path::PathBuf> = cli.include
        .split(&pathsep)
        .map(std::path::PathBuf::from)
        .collect();

    let eval_config = weaveback_macro::evaluator::EvalConfig {
        sigil: cli.sigil,
        include_paths,
        allow_env: cli.allow_env,
        ..Default::default()
    };

    let project_root = std::env::current_dir().unwrap_or_else(|_| ".".into());
    if let Err(e) = weaveback_api::mcp::run_mcp(std::io::stdin().lock(), std::io::stdout(), cli.db, cli.gen_dir, project_root, eval_config) {
        eprintln!("wb-mcp: {e}");
        std::process::exit(1);
    }
}
// @

Assembly

// <<@file wb-mcp/src/main.rs>>=
// <<wb-mcp-cli>>
// <<wb-mcp-main>>
// @