You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The MCP spec defines TextContent with optional fields:
interface TextContent {
type: "text";
text: string;
annotations?: Annotations; // optional — may be absent
_meta?: Record<string, unknown>; // optional — may be absent
}
"Optional" in the spec means the field may be absent from the JSON. Both SDKs
agree on this:
Python SDK's TextContentSchema defines annotations and _meta with
Optional[...] = None
Node SDK's TextContentSchema defines them with .optional() — accepts
undefined (absent) but not null
What the Python SDK does
The Python SDK has two serialization paths for CallToolResult:
Normal responses (_send_response in session.py): uses
model_dump(by_alias=True, mode="json", exclude_none=True). This correctly omits
None fields from the JSON. Works fine.
Task result delivery (handle in task_result_handler.py, line 131): uses
result.model_dump(by_alias=True) without exclude_none=True. This serializes
None fields as explicit JSON null:
The Node SDK's requestStream polls tasks/result when a task completes, then
parses the response with CallToolResultSchema. The Zod discriminated union for
content blocks uses:
I'd like to work on this. The fix is to add exclude_none=True, mode="json" to the model_dump() calls in task_result_handler.py (lines 117 and 119), consistent with how the rest of the session layer serializes models. Will submit a PR shortly.
Activity
abhinavmathur-atlan commentedon May 5, 2026
I'd like to work on this. The fix is to add
exclude_none=True, mode="json"to themodel_dump()calls intask_result_handler.py(lines 117 and 119), consistent with how the rest of the session layer serializes models. Will submit a PR shortly.maxisbey commentedon Jul 29, 2026
Thanks for the report. Closing this as it's been fixed in v2, which is now released (see #2809). Feel free to reopen if you still hit it on v2.
AI Disclaimer