[v2] ClientSession runs on JSONRPCDispatcher; BaseSession removed (#2838)

This commit is contained in:
Max 2026-06-15 14:46:34 +01:00 • committed by GitHub
commit 1012d60004
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,7 +3,7 @@
import pytest
from mcp.shared.exceptions import MCPError, UrlElicitationRequiredError
from mcp.types import URL_ELICITATION_REQUIRED, ElicitRequestURLParams, ErrorData
from mcp.types import URL_ELICITATION_REQUIRED, ElicitRequestURLParams, ErrorData, JSONRPCError
def test_url_elicitation_required_error_create_with_single_elicitation() -> None:
@ -162,3 +162,14 @@ def test_url_elicitation_required_error_exception_message() -> None:
# The exception's string representation should match the message
assert str(error) == "URL elicitation required"
def test_from_jsonrpc_error_preserves_code_message_and_data() -> None:
"""Building an MCPError from a wire JSONRPCError keeps every error field."""
wire = JSONRPCError(
jsonrpc="2.0",
id=3,
error=ErrorData(code=URL_ELICITATION_REQUIRED, message="go elsewhere", data={"hint": "y"}),
)
error = MCPError.from_jsonrpc_error(wire)
assert error.error == ErrorData(code=URL_ELICITATION_REQUIRED, message="go elsewhere", data={"hint": "y"})