1"""Exception types used by `plain.mcp`."""
 2
 3from __future__ import annotations
 4
 5
 6class MCPUnauthorized(Exception):
 7    """Raised from `before_request` to reject an MCP request.
 8
 9    `MCPView.handle_exception` catches this and returns a JSON-RPC 401
10    response with the exception message as the error text.
11    """
12
13
14class MCPInvalidParams(Exception):
15    """Raised from a JSON-RPC handler to signal bad caller params.
16
17    The dispatcher translates this to a JSON-RPC `INVALID_PARAMS`
18    (-32602) error rather than the blanket `INTERNAL_ERROR`.
19    """