judgevet.adapters.inbound.mcp_arguments

Status: draft.

judgevet.adapters.inbound.mcp_arguments

Tool error results and ask argument validation for the MCP tools.

The MCP tools specification classifies input validation errors as tool execution errors: a CallToolResult with isError true, not a protocol error. Source: https://modelcontextprotocol.io/specification/2025-11-25/server/tools#error-handling. SDK field names follow the tagged SDK definitions. The caller supplies SDK types, so importing this module needs no MCP runtime. AskKind names the three ask question types, so a misspelt kind fails the type check. ALLOWED names the arguments each ask tool declares; any other argument is a tool error.

Examples:

from judgevet.adapters.inbound.mcp_arguments import ask_arguments

state, instruction, criteria = ask_arguments(
    {"state": "text", "instruction": "Is it true?"}, "noul"
)
assert (state, instruction, criteria) == ("text", "Is it true?", None)
See Also

ask_arguments(arguments, kind)

Validate ask tool arguments before any provider call.

Choice criteria must be a non-empty object and score criteria a non-empty array when given. Noul accepts no criteria. Any argument the tool schema does not declare is an error, because not every client validates the input schema. Source: https://github.com/Alberto-Codes/judgevet/issues/303.

Parameters:

Name Type Description Default
arguments Any

Decoded MCP argument object, or None.

required
kind AskKind

Question type, one of the AskKind literals noul, choice or score.

required

Returns:

Type Description
tuple[Any, Any, Any]

State, instruction and criteria; criteria is None when absent.

Raises:

Type Description
ValueError

If a required argument is missing, an argument is unknown, or criteria has the wrong shape.

tool_error(mcp_types, message)

Return a tool error result without answers or a policy verdict.

Parameters:

Name Type Description Default
mcp_types Any

SDK type constructors.

required
message str

Declared diagnostic.

required

Returns:

Type Description
Any

SDK tool result with is_error true and the message as text.