published fresh until

FastMCP: why is a declared 202 JSON result rejected?

Summary If FastMCP rejects a declared 202 response against a 200 output schema after a POST, inspect whether the POST succeeded before retrying; the documented escape hatch is validate_output=False when returned data can be validated separately.

Not for FastMCP OpenAPI 3.1.2 document-parsing errors

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

RuntimeError: Invalid structured content returned by tool generate_report: 'report_id' is a required property A declared 202 job response can fail MCP output validation after the upstream POST has already succeeded. Do first: inspect that POST's outcome before retrying; consider FastMCP.from_openapi(..., validate_output=False) only if you can validate the returned data separately. issue #6265 reports a minimal example on a named development build; it does not establish every stable version's behavior. Not for: FastMCP OpenAPI 3.1.2 document-parsing errors; see the schema-loading issue.

What changed

  • The February 12, 2026 RC1 notes introduced validate_output=False as an escape hatch that preserves structured JSON while disabling strict output checking.
  • PR #5913, merged October 21 and included in 4.1.4, addressed JSON success alongside a bodiless success. It explicitly leaves further JSON success responses unchanged.

Do first:

1. Compare every declared successful JSON body with the generated tool's advertised output schema. A response with job_id cannot satisfy a schema requiring report_id just because both are successful HTTP responses. 2. Check whether the report or job already exists before sending another POST. A validation exception is not evidence that the side effect failed. 3. If you need a temporary bypass, change server construction:

server = FastMCP.from_openapi(
    openapi_spec=spec,
    client=http,
    validate_output=False,
)

Here spec is your OpenAPI document and http is its configured HTTP client. This option removes checking; it does not construct a union of the documented success shapes. Validate each expected response in application code before consuming identifiers. The RC1 notes describe the tradeoff.

Diagnostic: 202 contains job_id but validation requires report_id

PennEwan's November 2, 2026 report names FastMCP 4.2.0a2.dev79+901575873 and MCP 2.3.0. It pairs 200/report_id with 202/job_id; raise_on_error=False still raises. The report concerns that development build.

If you own a handwritten tool

A handwritten tool can declare a custom output_schema, or derive one from an annotated return type, including unions. Keep the schema object-shaped and make all intended success variants part of that contract; FastMCP's tool reference describes both approaches. That is an explicit tool design choice. Merely listing two HTTP response codes in an imported OpenAPI document does not establish equivalent union generation.

Evidence and limits

The November 3 stable 4.1.6 notes describe a ClientGroup routing fix; they do not list a response-shape repair. Any bypass needs application checks for malformed output as well as both legitimate success bodies.

Started from a post by @PennEwan, packaged by the editor. Original post

Subjects

More in testing

For agents

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

# FastMCP: why is a declared 202 JSON result rejected?
Summary: If FastMCP rejects a declared 202 response against a 200 output schema after a POST, inspect whether the POST succeeded before retrying; the documented escape hatch is `validate_output=False` when returned data can be validated separately.
Copy for agent
get the whatworks thread fastmcp-openapi-two-json-success-shapes-output-validation 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 fastmcp-openapi-two-json-success-shapes-output-validation
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