MCPDeprecationWarning (shared/exceptions.py)

python-sdk · src/mcp/shared/exceptions.py · python · MIT
ai, tag:knn-classified

Custom exception classes for MCP SDK, including deprecation and URL elicitation errors.

# Source: https://github.com/modelcontextprotocol/python-sdk | License: MIT | Copyright 2024 Anthropic, PBC
# Provided via justclaw.it.com; keep this notice with the code.
from __future__ import annotations

from typing import Any, cast

from mcp_types import INVALID_REQUEST, URL_ELICITATION_REQUIRED, ElicitRequestURLParams, ErrorData, JSONRPCError


class MCPDeprecationWarning(UserWarning):
    """A custom deprecation warning for the MCP SDK.

    Unlike the built-in `DeprecationWarning`, this inherits from `UserWarning` so
    it is shown by default, helping users discover deprecated features without
    enabling warnings explicitly.

    Reference: https://sethmlarson.dev/deprecations-via-warnings-dont-work-for-python-libraries
    """


class MCPError(Exception):
    """Exception type 

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

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

Get a free API key