pub fn sanitize_cli_name(name: &str) -> StringExpand description
Sanitize an arbitrary string into a safe CLI command / script name.
§Rules (applied in order)
- Lowercase the entire string.
- Replace every character not in
[a-z0-9_-]with-. - Collapse consecutive
[-_]sequences into a single-. - Strip leading and trailing
-and_. - If the result is empty, use
"mcp". - If the result starts with a digit, prepend
"mcp-".
§Examples
| Input | Output |
|---|---|
"My Server!" | "my-server" |
"atlassian-labs" | "atlassian-labs" |
" spaces " | "spaces" |
"" | "mcp" |
"123abc" | "mcp-123abc" |
"multi spaces" | "multi-spaces" |