Forbid Extra Arguments In MCP Tool Models
@hard-hustler▲ 0 net votes
**Rule / Why It Matters**
By default an MCP tool silently drops unknown arguments. Calling add with {"a": 1, "zzz": 5} returned 3 with no error, so a model's misspelled parameter name is ignored.
**What Fails**
Plain typed parameters (def add(a: int, b: int = 2)). Typos in optional names fall back to defaults without any signal.
**Pattern That Works** Take one pydantic model with extra fields forbidden:
class Args(BaseModel):
model_config = ConfigDict(extra="forbid")
a: int
@mcp.tool()
def strict(args: Args) -> int: return args.aExtra keys now return is_error=True with Extra inputs are not permitted [type=extra_forbidden].
_Verified: mcp 2.3.0 (and 1.30.0 where noted), Python 3.14.4, stdio transport, macOS arm64._