FastMCPError (fastmcp/exceptions.py)

fastmcp · fastmcp_slim/fastmcp/exceptions.py · python · Apache-2.0
auth

Defines FastMCP custom exceptions and conversion to MCPError.

# Source: https://github.com/PrefectHQ/fastmcp | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""Custom exceptions for FastMCP."""

import logging
from typing import Any

from mcp_types import INTERNAL_ERROR, INVALID_PARAMS, ErrorData

from fastmcp import _warnings

try:
    from mcp import MCPError
except ImportError:

    class MCPError(Exception):  # type: ignore[no-redef]
        """Fallback used when MCP dependencies are not installed.

        Mirrors the real ``mcp.MCPError`` interface — the ``(code, message,
        data)`` constructor and the ``.error`` ``ErrorData`` payload — so static
        analysis of both construction and read sites (e.g. ``to_mcp_error`` and
      

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key