fix: allow null id in JSONRPCError per JSON-RPC 2.0 spec (#2056)
This commit is contained in:
parent
3b53fb9a00
commit
705497a593
4 changed files with 151 additions and 24 deletions
|
|
@ -138,7 +138,7 @@ async def sse_client(
|
|||
json=session_message.message.model_dump(
|
||||
by_alias=True,
|
||||
mode="json",
|
||||
exclude_none=True,
|
||||
exclude_unset=True,
|
||||
),
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ async def stdio_client(server: StdioServerParameters, errlog: TextIO = sys.stder
|
|||
try:
|
||||
async with write_stream_reader:
|
||||
async for session_message in write_stream_reader:
|
||||
json = session_message.message.model_dump_json(by_alias=True, exclude_none=True)
|
||||
json = session_message.message.model_dump_json(by_alias=True, exclude_unset=True)
|
||||
await process.stdin.send(
|
||||
(json + "\n").encode(
|
||||
encoding=server.encoding,
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ class StreamableHTTPTransport:
|
|||
async with ctx.client.stream(
|
||||
"POST",
|
||||
self.url,
|
||||
json=message.model_dump(by_alias=True, mode="json", exclude_none=True),
|
||||
json=message.model_dump(by_alias=True, mode="json", exclude_unset=True),
|
||||
headers=headers,
|
||||
) as response:
|
||||
if response.status_code == 202:
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ async def websocket_client(
|
|||
async with write_stream_reader:
|
||||
async for session_message in write_stream_reader:
|
||||
# Convert to a dict, then to JSON
|
||||
msg_dict = session_message.message.model_dump(by_alias=True, mode="json", exclude_none=True)
|
||||
msg_dict = session_message.message.model_dump(by_alias=True, mode="json", exclude_unset=True)
|
||||
await ws.send(json.dumps(msg_dict))
|
||||
|
||||
async with anyio.create_task_group() as tg:
|
||||
|
|
|
|||
Loading…
Reference in a new issue