Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to Mount SSE Server to Existing ASGI Server #311

Closed
comfuture opened this issue Mar 18, 2025 · 0 comments · Fixed by #312
Closed

Option to Mount SSE Server to Existing ASGI Server #311

comfuture opened this issue Mar 18, 2025 · 0 comments · Fixed by #312

Comments

@comfuture
Copy link
Contributor

The SSE server in fastmcp currently operates as a Starlette app. In addition to running it as a standalone server, it would be beneficial to provide an option to mount it to an existing ASGI server.

Suggested solution

Currently, the run(transport="sse") method and the run_sse_async() method include the code for actually serving the application. It would be better to separate this functionality and allow users to obtain an instance of the SSE server app via a method like mcp.sse_app() or mcp.starlette_app().

comfuture added a commit to comfuture/python-sdk that referenced this issue Mar 18, 2025
Fixes modelcontextprotocol#311

Add option to mount SSE server to an existing ASGI server.

* Add a new method `sse_app` in `src/mcp/server/fastmcp/server.py` to return an instance of the SSE server app.
* Update the `run_sse_async` method in `src/mcp/server/fastmcp/server.py` to use the new `sse_app` method.
* Update the documentation in `README.md` to include instructions on how to mount the SSE server to an existing ASGI server.
* Fix the example in `README.md` to use `app.mount('/', mcp.sse_app())` instead.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/modelcontextprotocol/python-sdk/issues/311?shareId=XXXX-XXXX-XXXX-XXXX).
@Kludex Kludex closed this as completed in a9aca20 Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant