Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Missing OPTIONS handler for Streamable HTTP #1079

Copy link
Copy link
@fcmsilva

Description

@fcmsilva
Issue body actions

Initial Checks

Description

For a streamable HTTP connection, there's currently not a OPTIONS handler so it falls under 405 Method Not Allowed. My use case was to use a frontend mcp client, so this breaks that scenario since we can't make any requests from the frontend because the missing preflight request causes CORS issues on the frontend.

Could we directly add one to StreamableHTTPServerTransport.handle_request ?

It could be something like this:

async def _handle_options_request(self, request: Request, send: Send) -> None:
    """Handle OPTIONS requests for CORS preflight."""

    headers = {
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Methods": "GET, POST, DELETE, OPTIONS",
        "Access-Control-Allow-Headers": "Content-Type, Authorization",
    }

    response = Response(
        content=None,
        status_code=HTTPStatus.NO_CONTENT,
        headers=headers,
    )
    await response(request.scope, request.receive, send)

Example Code

Python & MCP Python SDK

1.10.1
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementRequest for a new feature that's not currently supportedRequest for a new feature that's not currently supported

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.