Skip to content

OpenAPI request director sends multipart/form-data and form-urlencoded as JSON, drops cookies #3933

@strawgate

Description

@strawgate

The request director detects the declared content type from the OpenAPI spec but only implements the JSON branch. Non-JSON content types silently fall through to application/json.

multipart/form-data → JSON

An OpenAPI endpoint declaring multipart/form-data (e.g., file uploads) sends the body as application/json:

# OpenAPI spec says: content: { "multipart/form-data": ... }
# Actual request: Content-Type: application/json, body: {"file": "data"}
# Expected:       Content-Type: multipart/form-data; boundary=...

application/x-www-form-urlencoded → JSON

Same issue — form submissions are sent as JSON:

# OpenAPI spec says: content: { "application/x-www-form-urlencoded": ... }
# Actual request: Content-Type: application/json, body: {"username": "admin"}
# Expected:       Content-Type: application/x-www-form-urlencoded, body: username=admin

Cookie parameters silently dropped

_unflatten_arguments() handles path, query, header, and body locations but has no cookie case. Cookie parameters log a warning and are lost.

All three are in src/fastmcp/utilities/openapi/director.py. The content type is detected at line 79-81 but never dispatched on for non-JSON types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.openapiRelated to OpenAPI integration, parsing, or code generation features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions