Normalize a user-supplied tool name to the canonical `tracedecay_ ` form used by the MCP registry. Accepts aliases (e.g. `query` → `search`), strips a leading `tracedecay_` if present, and converts dashes to underscores so `dead-code` and `dead_code` both work.
(raw: &str)
| 26 | /// strips a leading `tracedecay_` if present, and converts dashes to |
| 27 | /// underscores so `dead-code` and `dead_code` both work. |
| 28 | pub(crate) fn canonical_tool_name(raw: &str) -> String { |
| 29 | let trimmed = raw.strip_prefix("tracedecay_").unwrap_or(raw); |
| 30 | let normalized = trimmed.replace('-', "_"); |
| 31 | let mapped = NAME_ALIASES |
| 32 | .iter() |
| 33 | .find(|(k, _)| *k == normalized) |
| 34 | .map_or(normalized.as_str(), |(_, v)| *v); |
| 35 | format!("tracedecay_{mapped}") |
| 36 | } |
| 37 | |
| 38 | /// Parse CLI args against the tool's JSON Schema. Returns the JSON object to |
| 39 | /// hand to the handler, plus side-effects from reserved flags. |