MP011: redundant-prefix¶
Tool names should not repeat the server namespace.
At a glance¶
| Category | naming |
| Default severity | error |
| Auto-fixable | yes (unsafe) |
| LLM-gated | no |
| Stable since | v0.1.0 |
What this rule checks¶
The MCP host already shows the agent each tool as <namespace>/<tool_name>. If your namespace is memnex and your tool is memnex_search_memory, the agent sees memnex/memnex_search_memory. The repeated memnex_ adds tokens with no information.
MP011 fires when the first token of the tool name (split on underscores or dashes) matches the server namespace.
The namespace is detected from FastMCP("name") or Server("name") calls, or set explicitly in pyproject.toml. As a fallback, mcpolish also checks the longest token shared by every tool in the server.
Why it matters¶
Two costs:
- Token bloat. The duplicate prefix appears in every tool description the agent sees. With 8 tools, the bloat is 8 times.
- Reading effort for the agent. The model's attention is finite. Tokens that carry no signal still consume attention.
Example: code that triggers this rule¶
memnex = FastMCP("memnex")
@memnex.tool()
def memnex_lookup(key: str) -> str:
"""Use this when the user wants a single memory cell by key.
Args:
key: Memory cell key. Example: "user:123:name".
Returns: the stored value.
"""
return key
The namespace memnex plus the tool name memnex_lookup produces memnex/memnex_lookup. MP011 fires.
Example: how to fix it¶
The agent now sees memnex/lookup, which is shorter and cleaner.
Configuration¶
When to disable this rule¶
If two unrelated tools genuinely need the same prefix to communicate a sub-namespace (e.g. kv_get, kv_set on a key-value server named cache), kv_ is not redundant and MP011 does not fire. The rule only fires when the prefix equals the server name.
If you have a strong style guide that demands the prefix anyway, ignore the rule:
How the check works under the hood¶
mcpolish detects the namespace from a FastMCP(...) or Server(...) call. If no namespace is detected, it computes the longest shared first-token across all tool names. For each tool, it splits the name on _ or - and compares the first token to the namespace.
Auto-fix¶
The unsafe fix renames the tool to drop the prefix. Other files in your project may still reference the old name; the fix only edits the file the diagnostic points to. Apply with:
After running it, grep your project for the old name and update any callers.
Related rules¶
- MP010 generic-tool-name: catches the opposite problem, names with no information.
- MP012 inconsistent-verb-pattern: verb consistency within the namespace.
References¶
- MCP specification, namespace and tool registration.