fix: add StatelessModeNotSupported exception and improve tests (#1828)
This commit is contained in:
parent
bb6cb029f0
commit
37de50144f
1 changed files with 132 additions and 215 deletions
|
|
@ -18,6 +18,24 @@ class McpError(Exception):
|
|||
self.error = error
|
||||
|
||||
|
||||
class StatelessModeNotSupported(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.
|
||||
"""
|
||||
|
||||
def __init__(self, method: str):
|
||||
super().__init__(
|
||||
f"Cannot use {method} in stateless HTTP mode. "
|
||||
"Stateless mode does not support server-to-client requests. "
|
||||
"Use stateful mode (stateless_http=False) to enable this feature."
|
||||
)
|
||||
self.method = method
|
||||
|
||||
|
||||
class UrlElicitationRequiredError(McpError):
|
||||
"""
|
||||
Specialized error for when a tool requires URL mode elicitation(s) before proceeding.
|
||||
|
|
|
|||
Loading…
Reference in a new issue