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");
let composed = compose_catalogs(
&[
("github".into(), github.clone()),
("gitlab".into(), gitlab.clone()),
],
&AuditConfig::default(),
);
println!("{}", composed.to_text());
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());
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());
}