-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
P0Broken core functionality, security issues, critical missing featureBroken core functionality, security issues, critical missing featurebreaking changeWill break existing deployments when updated without changesWill break existing deployments when updated without changesenhancementRequest for a new feature that's not currently supportedRequest for a new feature that's not currently supportedv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixesIdeas, requests and plans for v2 of the SDK which will incorporate major changes and fixes
Description
Problem
Result types like CallToolResult inherit from Result, not JSONRPCResponse. This means they're missing the jsonrpc: "2.0" and id fields.
Current inheritance:
Result (types.py:133)
└── meta: dict | None
JSONRPCResponse (types.py:168) - separate, not inheriting from Result
├── jsonrpc: Literal["2.0"]
├── id: RequestId
└── result: dict
CallToolResult (types.py:1363) extends Result
└── Missing jsonrpc, id fields
The SDK has to manually wrap every result to add the JSON-RPC envelope before sending (session.py:386-389):
jsonrpc_response = JSONRPCResponse(
jsonrpc="2.0",
id=request_id,
result=response.model_dump(by_alias=True, mode="json", exclude_none=True),
)Same pattern as the notification inheritance issue - might be worth rethinking the type hierarchy.
Related
- Type system complexity creating developer friction and maintenance overhead #837 (type system complexity)
- Excessive use of generics #1207 (excessive generics)
Metadata
Metadata
Assignees
Labels
P0Broken core functionality, security issues, critical missing featureBroken core functionality, security issues, critical missing featurebreaking changeWill break existing deployments when updated without changesWill break existing deployments when updated without changesenhancementRequest for a new feature that's not currently supportedRequest for a new feature that's not currently supportedv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixesIdeas, requests and plans for v2 of the SDK which will incorporate major changes and fixes