Title: Support low-level interface for modifying the underlying Uvicorn server · Issue #253 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Support low-level interface for modifying the underlying Uvicorn server · Issue #253 · modelcontextprotocol/python-sdk
X Title: Support low-level interface for modifying the underlying Uvicorn server · Issue #253 · modelcontextprotocol/python-sdk
Description: It would be great to have an API to interact with the MCP's underlying Uvicorn server. More specifically, It would be great to have a leaky interface, that can act as a bridge with the abstraction of the underlying Uvicorn server, a way ...
Open Graph Description: It would be great to have an API to interact with the MCP's underlying Uvicorn server. More specifically, It would be great to have a leaky interface, that can act as a bridge with the abstraction ...
X Description: It would be great to have an API to interact with the MCP's underlying Uvicorn server. More specifically, It would be great to have a leaky interface, that can act as a bridge with the abstract...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/253
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support low-level interface for modifying the underlying Uvicorn server","articleBody":"\n\n\nIt would be great to have an API to interact with the MCP's underlying Uvicorn server.\n\n\nMore specifically, It would be great to have a leaky interface, that can act as a bridge with the abstraction of the underlying Uvicorn server, a way to configure it, or maybe just allowing us to pass arguments/kwargs to the Uvicorn server.\n\n## Problem\n\nAs a start, there is no clean way to close a Uvicorn server programmatically/gracefully, there are some hacks to go around it, here are some related issues: \n\n**Uvicorn cannot be shutdown programmatically** - https://github.com/encode/uvicorn/discussions/1103 \n**Uvicorn cannot be shutdown programmatically** - https://github.com/encode/uvicorn/issues/742\n**Running multiple Uvicorn servers simultaneously hangs on shutdown** - https://github.com/encode/uvicorn/issues/1773\n**Uvicorn eats SIGINTs, does not propagate exceptions** - https://github.com/encode/uvicorn/issues/1579\n\nAnd so on.... \n\n\n## Idea\n\nYou might say that, we already have access to the server and low-level API with\n\n```python\nfrom mcp.server.lowlevel.server import Server\n```\n\nHowever just to handle a graceful shutdown, not being able to handle all the out-of-box features that `FastMCP` class provides, feels like re-inventing the wheel.\n\n\nSo one of the easiest way(s) to do it is, passing the `timeout_graceful_shutdown=0` to the `uvicorn.Config` which solves the (partially) hanging server problem. \n\n\nUvicorn is configurable via environment variables, when they are prefixed with [`UVICORN_`](https://www.uvicorn.org/settings/#settings), so in a similar way, when we pass values to:\n\n```python\nFastMCP(\n \"some_server\",\n lifespan=app_lifespan,\n debug=True, # no prefix, for the Settings class\n uvicorn_timeout_graceful_shutdown=0, # uvicorn prefix, for UvicornConfig?\n)\n```\n\nWe can buffer this, similar to `**settings` then we can pass to the initialization of the server, would it be feasible? \n\nI'm sure there will be other use cases for this, also I'm not sure if the example above is the best way to handle that, just to give you a brief idea.\n\n\n\n\n","author":{"url":"https://github.com/ycd","@type":"Person","name":"ycd"},"datePublished":"2025-03-10T13:36:49Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/253"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:740710dc-65e2-dc25-2d6f-9b04073694a6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B424:A1D0F:CAB61:11592E:6AFCFFB2 |
| html-safe-nonce | 75569c5f27a3405197b29762677cdc15905a9fef8ae14c49922d3da775e523f0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDI0OkExRDBGOkNBQjYxOjExNTkyRTo2QUZDRkZCMiIsInZpc2l0b3JfaWQiOiIxNTkxNjgxMjAwNTU5MDMwMTk0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6f894f894d33438aba098f9cd449da528b9f95f09579f16c570fd23762c4421a |
| hovercard-subject-tag | issue:2907300836 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/253/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3b83f3acab770383b6b8dbf4a879de18d4c9a7007531743953f05a5edcd07751/modelcontextprotocol/python-sdk/issues/253 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3b83f3acab770383b6b8dbf4a879de18d4c9a7007531743953f05a5edcd07751/modelcontextprotocol/python-sdk/issues/253 |
| og:image:alt | It would be great to have an API to interact with the MCP's underlying Uvicorn server. More specifically, It would be great to have a leaky interface, that can act as a bridge with the abstraction ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ycd |
| hostname | github.com |
| expected-hostname | github.com |
| None | cfabad6ee26d2b84c7afef4ae0cc71b8b692fb9d66f9f15997652ef991bfd3f4 |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 35f85b78676038389558a41adf8d76e474592ede |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width