MP004: require-required-array¶
A hand-written inputSchema with properties must spell out a
requiredarray.
At a glance¶
| Category | schema |
| Default severity | warning |
| Auto-fixable | no |
| LLM-gated | no |
| Stable since | v0.1.0 |
What this rule checks¶
MP004 fires when one of these is true:
- The discoverer detected mandatory parameters (from a function signature where the param has no default) but the inputSchema lacks a
requiredarray. - The inputSchema came from a hand-written dict literal, has at least one property, and has no
requiredkey at all.
It does not fire on auto-derived schemas where every parameter has a default value.
Why it matters¶
The JSON Schema 2020-12 spec uses an explicit required array to mark mandatory properties. Without it, the agent has to guess which parameters are optional. The protocol says nothing in particular, so a missing required defaults to "all properties are optional", which is rarely what the author meant.
Example: code that triggers this rule¶
from mcp import Tool
TOOL = Tool(
name="create_ticket",
description="Use this when the user reports a new bug. Returns the new ticket id.",
inputSchema={
"type": "object",
"properties": {
"title": {"type": "string", "description": "Short summary."},
},
# required array intentionally missing
},
)
The schema has a property but no required list. MP004 fires.
Example: how to fix it¶
inputSchema={
"type": "object",
"properties": {
"title": {"type": "string", "description": "Short summary."},
},
"required": ["title"],
}
Or, when no parameter is mandatory:
Even an empty array tells the agent the author thought about it.
Configuration¶
MP004 has no knobs. To skip it:
When to disable this rule¶
If your team always uses the FastMCP decorator style, the schema is auto-derived and MP004 effectively never fires. The rule mainly serves authors who write Tool(...) constructors by hand.
How the check works under the hood¶
The discoverer flags each ToolDecl with schema_is_explicit=True when the schema came from a literal dict in source. MP004 then checks:
- If the discoverer marked any param as required (decorator case) but the schema's
requiredis falsy, fire. - Else if
schema_is_explicitand the schema has properties but norequiredkey, fire. - Else stay silent.
Related rules¶
- MP005 valid-json-schema: a broken schema fails MP005 first.
- MP002 require-param-description: parameters without descriptions fail MP002.
References¶
- JSON Schema 2020-12 specification. json-schema.org/draft/2020-12.