Server-side 2026-07-28 stateless support: classifier, driver split, server/discover (#2928)
This commit is contained in:
parent
44724284b3
commit
2397319a68
1 changed files with 2256 additions and 1088 deletions
|
|
@ -10,7 +10,7 @@ from mcp.server.mcpserver.exceptions import ToolError
|
|||
from mcp.server.mcpserver.utilities.context_injection import find_context_parameter
|
||||
from mcp.server.mcpserver.utilities.func_metadata import FuncMetadata, func_metadata
|
||||
from mcp.shared._callable_inspection import is_async_callable
|
||||
from mcp.shared.exceptions import UrlElicitationRequiredError
|
||||
from mcp.shared.exceptions import MCPError
|
||||
from mcp.shared.tool_name_validation import validate_and_warn_tool_name
|
||||
from mcp.types import Icon, ToolAnnotations
|
||||
|
||||
|
|
@ -111,9 +111,12 @@ class Tool(BaseModel):
|
|||
result = self.fn_metadata.convert_result(result)
|
||||
|
||||
return result
|
||||
except UrlElicitationRequiredError:
|
||||
# Re-raise UrlElicitationRequiredError so it can be properly handled
|
||||
# as an MCP error response with code -32042
|
||||
except MCPError:
|
||||
# `MCPError` (and subclasses such as `UrlElicitationRequiredError`)
|
||||
# carries a JSON-RPC `ErrorData(code, message, data)` and means
|
||||
# "respond with a protocol error" - re-raise so the kernel surfaces
|
||||
# it as a top-level JSON-RPC error rather than wrapping it as a
|
||||
# `CallToolResult(isError=True)` execution failure.
|
||||
raise
|
||||
except Exception as e:
|
||||
raise ToolError(f"Error executing tool {self.name}: {e}") from e
|
||||
|
|
|
|||
Loading…
Reference in a new issue