exceptions
MCPError
Bases: Exception
Exception type raised when an error arrives over an MCP connection.
Source code in src/mcp/shared/exceptions.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
StatelessModeNotSupported
Bases: RuntimeError
Raised when attempting to use a method that is not supported in stateless mode.
Server-to-client requests (sampling, elicitation, list_roots) are not supported in stateless HTTP mode because there is no persistent connection for bidirectional communication.
Source code in src/mcp/shared/exceptions.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
UrlElicitationRequiredError
Bases: MCPError
Specialized error for when a tool requires URL mode elicitation(s) before proceeding.
Servers can raise this error from tool handlers to indicate that the client must complete one or more URL elicitations before the request can be processed.
Example
raise UrlElicitationRequiredError([
ElicitRequestURLParams(
message="Authorization required for your files",
url="https://example.com/oauth/authorize",
elicitation_id="auth-001"
)
])
Source code in src/mcp/shared/exceptions.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
__init__
__init__(
elicitations: list[ElicitRequestURLParams],
message: str | None = None,
)
Initialize UrlElicitationRequiredError.
Source code in src/mcp/shared/exceptions.py
79 80 81 82 83 84 85 86 87 88 89 90 | |
elicitations
property
elicitations: list[ElicitRequestURLParams]
The list of URL elicitations required before the request can proceed.
from_error
classmethod
from_error(error: ErrorData) -> UrlElicitationRequiredError
Reconstruct from an ErrorData received over the wire.
Source code in src/mcp/shared/exceptions.py
97 98 99 100 101 102 103 104 105 106 | |