1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//! # `mcp-vol` — Deterministic MCP Tool Volatility & Selection Auditor
//!
//! Zero-LLM, sub-millisecond **MCP tool linter**, **deep JSON Schema walker**, **sibling
//! collision analyzer**, **RFC 6902 patch suggester**, and **BM25 / TF-IDF / Hybrid RRF
//! evaluation harness** designed specifically for **AI coding agents** and Rust (`rmcp`) CI gates.
//!
//! ## AI Agent Quick Reference (Single-Read Cheat Sheet)
//!
//! ### 1. Recommended `Cargo.toml`
//! ```toml
//! [dev-dependencies]
//! mcp-vol = { version = "0.1", features = ["rmcp"] }
//! ```
//!
//! ### 2. One-Line Prelude & Facades (Minimal Boilerplate)
//! ```rust
//! use mcp_vol::prelude::*;
//!
//! let json = r#"{
//! "tools": [
//! {
//! "name": "list_issues",
//! "description": "Lists open or closed GitHub issues for a repository. Use this when browsing issues; for cross-repo keyword search use search_issues. Returns at most 50 issues per page.",
//! "inputSchema": {
//! "type": "object",
//! "properties": {
//! "repo": { "type": "string", "description": "Repository in owner/name format." },
//! "state": { "type": "string", "enum": ["open", "closed", "all"], "description": "Issue state filter." },
//! "limit": { "type": "integer", "description": "Maximum issues per page (default 50)." }
//! },
//! "required": ["repo"]
//! },
//! "annotations": {
//! "readOnlyHint": true,
//! "destructiveHint": false,
//! "idempotentHint": true,
//! "openWorldHint": true
//! }
//! }
//! ]
//! }"#;
//!
//! // One-line JSON audit + assertion
//! let report = audit_json(json).unwrap();
//! assert!(report.passed());
//!
//! // Selection routing eval (Bm25Ranker, TfIdfRanker, or HybridRanker)
//! let catalog = Catalog::from_mcp_json(json).unwrap();
//! assert_catalog_clean(&catalog);
//! let suite = EvalSuite::new([EvalCase {
//! id: "c1".into(),
//! query: "show open issues in this repo".into(),
//! expected_tool: "list_issues".into(),
//! acceptable_tools: vec![],
//! }]);
//! assert_eq!(suite.run(&catalog, &Bm25Ranker::default(), 3).top1_accuracy, 1.0);
//! assert_eq!(suite.run(&catalog, &HybridRanker::default(), 3).top1_accuracy, 1.0);
//! ```
//!
//! ### 3. One-Line `rmcp` v3.12 Test Gate (`features = ["rmcp"]`)
//! ```rust,ignore
//! #[test]
//! fn mcp_tools_are_agent_ready() {
//! let tools: Vec<rmcp::model::Tool> = my_server_tools();
//! mcp_vol::assert_rmcp_tools_clean(&tools);
//! }
//! ```
//!
//! ### 4. Rule Codes (`VOL001`–`VOL024`)
//! - **Purpose Clarity:** `VOL001` missing description, `VOL002` tautology, `VOL003` vague verb
//! - **Usage Guidelines:** `VOL004` missing usage cue (catalog ≥ 5), `VOL005` missing sibling boundary
//! - **Behavioral Transparency:** `VOL006` annotation contradiction, `VOL007` missing annotations,
//! `VOL008` undisclosed side effect/limit, `VOL018` unbounded list/search,
//! `VOL019` coercive routing / hidden directive, `VOL024` missing return contract
//! - **Parameter Semantics (recursive `$ref`/nested):** `VOL009` undocumented param,
//! `VOL010` unconstrained closed-set string, `VOL011` opaque name or missing date/regex format,
//! `VOL020` incompatible/broken `inputSchema` or `$ref`, `VOL021` unsatisfiable schema constraint
//! - **Conciseness:** `VOL012` token budget exceeded (>250/tool or >15k/catalog), `VOL013` schema-prose duplication,
//! `VOL023` excessive parameter count (>12) or nesting depth (>4)
//! - **Contextual Completeness:** `VOL014` tool collision (≥0.72 or dup), `VOL015` TDQS shadowing risk,
//! `VOL016` empty `outputSchema` stub, `VOL017` SEP-986 / mixed naming style,
//! `VOL022` duplicate or placeholder description
//!
//! ### 5. Mechanical RFC 6902 Auto-Fix, Baseline Eval Bootstrapping & Self-Describing Schemas
//! ```rust
//! use mcp_vol::prelude::*;
//!
//! let broken = r#"[{"name":"delete_all","description":"Deletes records.","inputSchema":{"type":"object"},"annotations":{"readOnlyHint":true,"destructiveHint":false}}]"#;
//! let catalog = Catalog::from_mcp_json(broken).unwrap();
//! let report = Auditor::default().audit(&catalog);
//! let patches = suggest_patches(&catalog, &report);
//! assert!(patches.patch_count >= 1);
//!
//! // Apply high-confidence patches deterministically and verify score lift
//! let (fixed_catalog, applied) = apply_patches(&catalog, &AuditConfig::default(), PatchConfidence::High);
//! assert_eq!(applied.errors_after, 0);
//! assert!(applied.score_after > applied.score_before);
//!
//! // Synthesize a starter routing eval suite in <1 ms, index with Bm25Index & inspect JSON Schemas
//! let suite = EvalSuite::generate_baseline(&fixed_catalog);
//! let index = Bm25Index::build(&fixed_catalog);
//! assert_eq!(suite.run(&fixed_catalog, &index, 1).top1_accuracy, 1.0);
//! assert!(json_schema_for(SchemaTarget::AuditReport)["properties"]["findings"].is_object());
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use all_rules;
pub use ;
/// Convenience one-line wildcard import for AI agents and test modules: `use mcp_vol::prelude::*;`.
/// One-line helper to parse and audit any MCP `tools/list` JSON string with default settings.
/// One-line `cargo test` assertion that panics with a prioritized agent-readable [`RepairPlan`]
/// if any finding meets or exceeds `Severity::Error`.
///
/// # Panics
///
/// Panics if [`AuditReport::passed`] is `false`.