fix: Lifespan pr cleanup/Extending ASGI lifespan examples #1534
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Removed the stateless http additions by @ranjitodedra as they weren't necessary for the issue and may add confusion as stateless_http isn't necessary for a streamable http mcp service.
Motivation and Context
Fixing #1494 and also added an example with more detailed explanation of attaching ASGI services through lifespan.
How Has This Been Tested?
I tested the new example with information from #1484. The main issue was attempting to run two separate ASGI services at the same time rather than mounting them to a main one to call other ASGI services.
Breaking Changes
No there are no breaking changes just documentation and examples.
Types of changes
Checklist
Additional context
As was said in Issue #1494 they found they could mount existing server routes onto an mcp server but were struggling on the configuration to run multiple services asynchronously. It is possible to do so with Starlette examples, the mcp service, as well as other asynchronous services can be started and stopped by a context manager lifespan function, on a Starlette app call.
The confusion with stateless_http is probably that a streamable_http mcp server requires stateless_http due to its name, unless you look deeper you won't find that it is only tied to if requests track sessions or carry persistence between requests. I removed the added stateless_http since it wasn't necessary for the examples in question.