* Option to mount SSE server to existing ASGI server
Fixes#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).
* Add `sse_app` method and update `run_sse_async` method in `server.py`
* Add `sse_app` method to return an instance of the SSE server app
* Update `run_sse_async` method to use the new `sse_app` method
Update `README.md` to include instructions for mounting SSE server
* Add section on mounting the SSE server to an existing ASGI server
* fix: Move import statements to the top of the file/
* docs: Update README to reflect changes in mounting SSE server with Starlette
* docs: Formatting of SSE server mounting example in README
uv add is for adding dependency to uv managed python projects, and folks
not familiar with uv may mistaken the command for running mcp. Added
wordings that clarifies this.
- Add proper generic parameter for lifespan context type
- Update README with TypedDict example for strong typing
- Fix context variable initialization in server
- Improve property return type safety
- Remove redundant documentation
- Ensure compatibility with existing tests
Add comprehensive documentation for lifespan support:
- Add usage examples for both Server and FastMPC classes
- Document startup/shutdown patterns
- Show context access in tools and handlers
- Clean up spacing in test files
Update the README.md to include FastMCP as the recommended way to build MCP servers. FastMCP is a high-level, Pythonic interface that makes it easy to build MCP servers with minimal boilerplate. The low-level implementation is still available for more control.
🤖 Generated with Claude CLI.
Co-Authored-By: Claude <noreply@anthropic.com>