Commit a9aca20
authored
Option to mount SSE server to existing ASGI server (#312)
* 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 README1 parent 6b6f34e commit a9aca20
2 files changed
+41
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
346 | 347 | | |
347 | 348 | | |
348 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
349 | 375 | | |
350 | 376 | | |
351 | 377 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
461 | 463 | | |
462 | 464 | | |
463 | 465 | | |
464 | | - | |
465 | | - | |
| 466 | + | |
466 | 467 | | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
467 | 479 | | |
468 | 480 | | |
469 | 481 | | |
| |||
476 | 488 | | |
477 | 489 | | |
478 | 490 | | |
479 | | - | |
| 491 | + | |
480 | 492 | | |
481 | 493 | | |
482 | 494 | | |
483 | 495 | | |
484 | 496 | | |
485 | 497 | | |
486 | 498 | | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | 499 | | |
497 | 500 | | |
498 | 501 | | |
| |||
0 commit comments