"""Transport-agnostic error types raised by the core. Core tool handlers and the authorization layer must not depend on the web stack (FastAPI). They raise :class:`ToolError` carrying an advisory HTTP status code; each transport adapter maps it to its own wire format (the HTTP adapter to ``fastapi.HTTPException``, the stdio adapter to an MCP error). This keeps the core importable without FastAPI installed. """ from __future__ import annotations class ToolError(Exception): """Error raised by a core tool handler or the authorization layer. Args: message: Human-readable, non-sensitive error detail. status_code: Advisory HTTP status (e.g. 403 for denied). Adapters map this to their transport; the stdio adapter only uses the message. """ def __init__(self, message: str, *, status_code: int = 400) -> None: super().__init__(message) self.status_code = status_code self.detail = message