Deploy docs: reused-process runtimes (Lambda) hit the single-use session manager error, but aren't covered
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- aws, python
- Domain
- cloud, documentation
Research direction
Start in docs/troubleshooting.md, where the existing StreamableHTTPSessionManager error cases for Mount and long-running workers are documented. Add the missing AWS Lambda reused-process case, explain that the app should be built fresh inside the handler rather than at module scope, and confirm the entry clearly connects the error to that deployment pattern.
Written by the indexing model from the issue text.
Description
Running our MCP server (Streamable HTTP) on AWS Lambda, every second invocation against a warm container failed outright, on every request, with:
RuntimeError: StreamableHTTPSessionManager .run() can only be called once per instance. Create a new instance if you need to run again.
It happens the first time any Lambda container gets reused, which is the normal, expected behavior in production. Not an edge case. Discovered it testing against real repeated traffic, not a single request. Anyone deploying a Streamable HTTP MCP server to Lambda the natural way (build the app once, at import time, like you would for any long-running server) hits this the moment a container is reused.
Root cause: the app was built once at import time, so its session manager's lifespan ran and finished during the first invocation. The second invocation reuses the same process and tries to enter that same manager's lifespan again, which it refuses.
docs/troubleshooting.md already documents this exact error for two other causes (a Mount swallowing a lifespan, several long-running workers). Neither matches a serverless/reused-process deployment, and nothing pointed us at the actual fix. Had to reproduce the crash directly to find the fix.
Fix: build the app fresh inside the handler, per invocation, instead of at module scope.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 19
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelcontextprotocol/python-sdk
-
P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
modelcontextprotocol/python-sdk#3597 · 1 comment ·
Maintainers usually reply within 1 day
-
v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
modelcontextprotocol/python-sdk#3592 · 1 comment ·
Maintainers usually reply within 1 day
-
v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
modelcontextprotocol/python-sdk#3589 ·
Maintainers usually reply within 1 day
-
v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
modelcontextprotocol/python-sdk#3585 · 1 comment ·
Maintainers usually reply within 1 day
-
v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
modelcontextprotocol/python-sdk#3578 · 1 comment ·
Maintainers usually reply within 1 day
All issues in modelcontextprotocol/python-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
kornia/kornia#5263 · 1 comment ·
Maintainers usually reply within 1 day
-
approved correction metadata
Difficulty 1/5 Under an hour Newbie friendliness 88/100
acl-org/acl-anthology#10133 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
BasedHardware/omi#20084 ·
Maintainers usually reply within 1 day
-
bug needs-acceptance wg/evaluation-quality
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
vllm-project/semantic-router#4424 ·
Maintainers usually reply within 1 day