mcp-vol 0.1.0

Zero-LLM, deterministic MCP tool linter (24 rules), static Rust/TS/Python scanner, multi-server composer, RFC 6902 patcher, and pre-indexed BM25 eval harness for rmcp and AI agents.
Documentation
//! Demonstrates multi-server MCP composition auditing (`compose_catalogs`),
//! pre-indexed sub-millisecond `Bm25Index` search, per-term `explain_query`,
//! and side-by-side `compare_rankers`.
use mcp_vol::prelude::*;

fn main() {
    let github = Catalog::from_mcp_json(
        r#"{
          "tools": [
            {
              "name": "create_issue",
              "description": "Creates a new GitHub issue in a repository and returns its issue URL.",
              "inputSchema": {
                "type": "object",
                "properties": {
                  "owner": { "type": "string", "description": "Repository owner." },
                  "repo": { "type": "string", "description": "Repository name." },
                  "title": { "type": "string", "description": "Issue title." }
                },
                "required": ["owner", "repo", "title"]
              }
            },
            {
              "name": "search_repositories",
              "description": "Searches GitHub repositories by keyword and returns a paginated list.",
              "inputSchema": {
                "type": "object",
                "properties": {
                  "query": { "type": "string", "description": "GitHub search query." },
                  "perPage": { "type": "integer", "description": "Results per page." }
                },
                "required": ["query"]
              }
            }
          ]
        }"#,
    )
    .expect("valid github catalog");

    let gitlab = Catalog::from_mcp_json(
        r#"{
          "tools": [
            {
              "name": "create_issue",
              "description": "Creates a new GitLab issue in a project and returns its issue IID.",
              "inputSchema": {
                "type": "object",
                "properties": {
                  "project_id": { "type": "string", "description": "Project ID or URL-encoded path." },
                  "title": { "type": "string", "description": "Issue title." }
                },
                "required": ["project_id", "title"]
              }
            },
            {
              "name": "list_merge_requests",
              "description": "Lists open GitLab merge requests for a project with pagination.",
              "inputSchema": {
                "type": "object",
                "properties": {
                  "project_id": { "type": "string", "description": "Project ID." },
                  "limit": { "type": "integer", "description": "Max rows returned." }
                },
                "required": ["project_id"]
              }
            }
          ]
        }"#,
    )
    .expect("valid gitlab catalog");

    // 1) Multi-server composition & namespace simulation
    let composed = compose_catalogs(
        &[
            ("github".into(), github.clone()),
            ("gitlab".into(), gitlab.clone()),
        ],
        &AuditConfig::default(),
    );
    println!("{}", composed.to_text());

    // 2) Pre-indexed Bm25Index on the namespaced catalog + explainability
    let mut combined = github.with_namespace_prefix("github").tools().to_vec();
    combined.extend(
        gitlab
            .with_namespace_prefix("gitlab")
            .tools()
            .iter()
            .cloned(),
    );
    let namespaced = Catalog::new(combined);

    let index = Bm25Index::build(&namespaced);
    let hits = index.search("open gitlab merge requests", 2);
    println!(
        "Top Bm25Index hit: {} ({:.3})",
        hits[0].tool_name, hits[0].score
    );

    let explanation = explain_query(
        &namespaced,
        "open gitlab merge requests",
        Bm25Ranker::default(),
        2,
    );
    println!("{}", explanation.to_text());

    // 3) Side-by-side ranker comparison on an auto-generated adversarial suite
    let suite = EvalSuite::generate_adversarial(&namespaced);
    let tfidf = TfIdfRanker::default();
    let hybrid = HybridRanker::default();
    let cmp = compare_rankers(
        &suite,
        &namespaced,
        &[("bm25", &index), ("tfidf", &tfidf), ("hybrid", &hybrid)],
        3,
    );
    println!("{}", cmp.to_text());
}