Skip to content

Adding run_ws_async to FastMCP #411

@aksheyd

Description

@aksheyd

Instead of having to create a class on top of FastMCP to add a run_ws_async() func to connect the websocket_server to uvicorn over a Starlette app (and add test cases), I was wondering if this could be added to the sdk innately?

The solution would entail adding "ws" as a transport option to FastMCP, adding a run_ws_async() func that launches a uvicorn server. Then, a ws_app() func to create a starlette app which binds the FastMCP read/write streams with the websocket_server read/write streams. (Very similar to how run_sse_async() is done).

An alternate would be to just let the user create their own methods? But, I feel like it would be nice to have direct support from the sdk.

I have working code and some tests for this, and I can start a PR (if this would be a viable feature to add). If you want to take a look a the code, I can add it in the comments.

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions