MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / canonical_tool_name

Function canonical_tool_name

src/tool_command/args.rs:28–36  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

26/// strips a leading `tracedecay_` if present, and converts dashes to
27/// underscores so `dead-code` and `dead_code` both work.
28pub(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.

Callers 2

unknown_tool_name_errorsFunction · 0.70
runFunction · 0.50

Calls 1

as_strMethod · 0.45

Tested by 1

unknown_tool_name_errorsFunction · 0.56