published fresh until

MCP Python SDK: typing.Dict return wrapped in {"result"}

Summary As of October 2026, MCPServer tools annotated -> typing.Dict[str, X] returned {"result": ...} and bare -> dict gave no outputSchema. Fixes merged 2026-10-24 (PRs #3756, #3758) are on main after v2.3.0; no release containing them was found.

Not for transport errors 400 or 406, see mcp-streamable-http-400-missing-session-id-406-not-acceptable

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Diagnostic: Tool <name> has an output schema but did not return structured content is raised by the MCP client (Python and TypeScript SDK source) when a tool lists an outputSchema but its result has no structuredContent. Fix the server, or drop the schema: in the Python SDK add structured_output=False to the tool decorator. If the result is a plain error, set isError (is_error in Python): both the Python client (session.py) and the TypeScript client skip the output-schema checks for error results.

Checked 2026-10-30. Separate case, covered below: typing.Dict[str, X] returns wrapped in {"result": ...}.

Not for: transport errors like 400 or 406, see mcp-streamable-http-400-missing-session-id-406-not-acceptable; a server that never connects, see claude-code-mcp-server-failed-to-connect-status-checklist.

Opt out and validation (Python SDK docs)

from mcp.server import MCPServer

mcp = MCPServer("Weather")

@mcp.tool(structured_output=False)
def weather_report(city: str) -> str:
    ...

Per the structured output page, with this flag there is no output schema, no wrapping and no validation; structured_content is None and content carries the text. structured_output=True forces structured output and raises at import time if the return type cannot be serialized.

  • Opted out by default: content blocks (alone, in a list or union), a bare list or tuple, and a class without type hints (the model then gets its repr).
  • Wrapped in {"result": ...} per the page: scalars, list[...], tuple[...], sets and unions, and a dict with non-str keys. dict[str, ...], Dict[str, ...] and bare dict are documented as unwrapped objects; that matches the main branch after the fixes below, not the released v2.3.0 behavior reported in the issues.
  • A return value that does not match the schema fails the call: is_error=True, text "Error executing tool get_weather", and a Pydantic ValidationError in the server log (for example a missing humidity field).
  • Client side: the Python client raises RuntimeError with the message above, and Invalid structured content returned by tool <name> when the content does not match (session.py). The TypeScript client uses the same first message, plus Structured content does not match the tool's output schema (client.ts).

The typing.Dict wrapping bug

Do first: annotate tool returns as dict[str, Any] (builtin) until a release with the fixes ships; the issues show that form behaves as intended. Symptom: -> typing.Dict[str, Any] gives outputSchema with a result property and structuredContent {"result": {...}}, while -> dict[str, Any] gives the object itself. A bare -> dict (also list, tuple) got no outputSchema and no structuredContent, and with structured_output=True raised InvalidSignature ... return type <class 'dict'> is not serializable for structured output. Cause (from the issues): in _create_output_model the generic branch used isinstance(type_expr, GenericAlias) from types; typing.Dict[str, X] is a typing._GenericAlias, so it fell through to the wrap-everything case. Bare containers went to the "other class types" case where get_type_hints(dict) is empty. The #3745 reporter notes ruff UP006 rewrites Dict to dict and silently changed one tool's output, so a client with a cached schema rejected results. Fixes (read 2026-10-30): PR #3756 treats typing.Dict[str, X] like dict[str, X] (merged 2026-10-24, closes #3745). PR #3758 gives bare dict the dict[str, Any] behavior and wraps bare set/frozenset; per its description a bare list/tuple deliberately stays unstructured (and is wrapped with structured_output=True). Closes #3725. The PR descriptions flag the change: tools on typing.Dict[str, X] stop wrapping in {"result": ...}, and bare -> dict tools start publishing an outputSchema. Release: v2.3.0 (2026-10-02) predates both merges, so the fixes are on main only. Still open: #3771 (2026-10-27) reports unsubscripted typing.Dict still wrapped and typing.List/typing.Tuple bypassing the opt-out; a reporter says they have a branch, no maintainer reply seen. Members: #3745 (benjamin-di, closed), #3725 (g-s-jithesh, closed), #3771 (chauvuusvn, open). Checked 2026-10-30.

Started from a post by @benjamin-di, packaged by the editor. Original post

Subjects

More in model context protocol

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# MCP Python SDK: typing.Dict return wrapped in {"result"}
Summary: As of October 2026, MCPServer tools annotated -> typing.Dict[str, X] returned {"result": ...} and bare -> dict gave no outputSchema. Fixes merged 2026-10-24 (PRs #3756, #3758) are on main after v2.3.0; no release containing them was found.
Copy for agent
get the whatworks thread ptr-mcp-python-sdk-typing-dict-return-wrapped-in-result-structured-output and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread ptr-mcp-python-sdk-typing-dict-return-wrapped-in-result-structured-output
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks