Drop RootModel from JSONRPCMessage (#1908)
This commit is contained in:
parent
dcc9b4f8e0
commit
f4672c5084
1 changed files with 314 additions and 476 deletions
|
|
@ -18,7 +18,6 @@ from mcp.types import (
|
|||
EmptyResult,
|
||||
ErrorData,
|
||||
JSONRPCError,
|
||||
JSONRPCMessage,
|
||||
JSONRPCRequest,
|
||||
JSONRPCResponse,
|
||||
TextContent,
|
||||
|
|
@ -130,7 +129,7 @@ async def test_response_id_type_mismatch_string_to_int():
|
|||
"""Receive a request and respond with a string ID instead of integer."""
|
||||
message = await server_read.receive()
|
||||
assert isinstance(message, SessionMessage)
|
||||
root = message.message.root
|
||||
root = message.message
|
||||
assert isinstance(root, JSONRPCRequest)
|
||||
# Get the original request ID (which is an integer)
|
||||
request_id = root.id
|
||||
|
|
@ -142,7 +141,7 @@ async def test_response_id_type_mismatch_string_to_int():
|
|||
id=str(request_id), # Convert to string to simulate mismatch
|
||||
result={},
|
||||
)
|
||||
await server_write.send(SessionMessage(message=JSONRPCMessage(response)))
|
||||
await server_write.send(SessionMessage(message=response))
|
||||
|
||||
async def make_request(client_session: ClientSession):
|
||||
nonlocal result_holder
|
||||
|
|
@ -185,7 +184,7 @@ async def test_error_response_id_type_mismatch_string_to_int():
|
|||
"""Receive a request and respond with an error using a string ID."""
|
||||
message = await server_read.receive()
|
||||
assert isinstance(message, SessionMessage)
|
||||
root = message.message.root
|
||||
root = message.message
|
||||
assert isinstance(root, JSONRPCRequest)
|
||||
request_id = root.id
|
||||
assert isinstance(request_id, int)
|
||||
|
|
@ -196,7 +195,7 @@ async def test_error_response_id_type_mismatch_string_to_int():
|
|||
id=str(request_id), # Convert to string to simulate mismatch
|
||||
error=ErrorData(code=-32600, message="Test error"),
|
||||
)
|
||||
await server_write.send(SessionMessage(message=JSONRPCMessage(error_response)))
|
||||
await server_write.send(SessionMessage(message=error_response))
|
||||
|
||||
async def make_request(client_session: ClientSession):
|
||||
nonlocal error_holder
|
||||
|
|
@ -247,7 +246,7 @@ async def test_response_id_non_numeric_string_no_match():
|
|||
id="not_a_number", # Non-numeric string
|
||||
result={},
|
||||
)
|
||||
await server_write.send(SessionMessage(message=JSONRPCMessage(response)))
|
||||
await server_write.send(SessionMessage(message=response))
|
||||
|
||||
async def make_request(client_session: ClientSession):
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in a new issue