mcp2cli

Fuzzy Matching

Mistype a command? mcp2cli suggests the closest match instead of a cryptic error.


How It Works

When you type a command that doesn’t exist, mcp2cli computes the Levenshtein edit distance between your input and all known commands from the server’s manifest. If a close match is found, you get a helpful suggestion:

Terminal window
$ work ecoh --message hello
error: unrecognized subcommand 'ecoh'
Did you mean: echo?
Terminal window
$ work serch --query "test"
error: unrecognized subcommand 'serch'
Did you mean: search?

Matching Rules

RuleDetail
Max distanceSuggestions are shown for edit distance ≤ 3 and < half the query length + 1
Max suggestionsUp to 3 closest matches are shown
SortingClosest match first
ScopeOnly manifest commands are matched (server tools, resources, prompts)

What Counts as an Edit?

Levenshtein distance counts the minimum number of:

  • Insertionsechecho (1 insertion)
  • Deletionsecchoecho (1 deletion)
  • Substitutionsecxoecho (1 substitution)

Examples

TypedActualDistanceSuggested?
ecohecho2
serchsearch1
deplpydeploy2
xyzecho4❌ (too far)
eecho3✅ (distance ≤ 3)

Multiple Suggestions

When several commands are close, all are listed:

Terminal window
$ work ad --a 1 --b 2
error: unrecognized subcommand 'ad'
Did you mean: add, audit, admin?

Runtime Commands Are Not Matched

Fuzzy matching applies only to server-derived commands (tools, resources, prompts). Built-in runtime commands like ls, ping, auth, jobs, doctor are not included in the fuzzy search because they’re handled by a separate parser.


Interaction with Profile Overlays

Fuzzy matching works against the final manifest — after profile aliases, renames, and groups have been applied. If you’ve renamed echo to ping via a profile overlay, the fuzzy matcher suggests ping, not echo.


See Also