mcp.shared.session behaviour changed in mcp 2.3.0
In our sandbox runs up to 2026-10-27, gpt-6.1-sol wrote shared_session.anyio.create_memory_object_stream(1) for mcp. It fails on 2.3.0 with ImportError (changed between 1.26.0 and 2.3.0). Use anyio.create_memory_object_stream(1) instead.
- What to do
- replace the line
- Output
- differs on one example — review first
- Patch
- nothing to apply word for word
- Auto-apply
- not allowed
- Seen in
- 1 model
- Worked / failed
- 1 / 0
- Last verified
- 2026-10-27
What to do
Not for automatic application — wrong occurs 2 times in the example. Show this correction to the user as a lead. Review before applying: this fix runs on mcp 2.3.0, but its printed output differs from what the original printed on 1.26.0 (observed stdout of one example) — it may do different work. Replace the old line with the new one; the rest of the code can stay.
Automatic application: not allowed — the fix's output differs from the original's; the patch gives not_applicable when applied word for word. Automatic application is allowed only when proof.equivalent is true and proof.applicability.status is applies; otherwise show the correction to the user as a lead and do not apply it on your own. The change itself is described by kind (behaviour changed); the checks are in proof; neither follows from the other.
How to tell this applies to your code
- mcp version 2.3.0 or newer is installed (checked on 2.3.0; changed between 1.26.0 and 2.3.0).
- Your code uses:
shared_session.anyio.create_memory_object_stream - Or it already failed with:
ImportError: cannot import name 'session' from 'mcp.shared' (/usr/local/lib/python3.11/site-packages/mcp/shared/__init__.py)(every correction for this error)
Old and new code
shared_session.anyio.create_memory_object_stream(1)anyio.create_memory_object_stream(1)
Error on 2.3.0:
ImportError: cannot import name 'session' from 'mcp.shared' (/usr/local/lib/python3.11/site-packages/mcp/shared/__init__.py)
| Script | mcp version | Result |
|---|---|---|
| Code the models wrote | 1.26.0 | works |
| Code the models wrote | 2.3.0 | fails: ImportError |
| Verified example below | 2.3.0 | works |
| Output of the verified example | 2.3.0 | DIFFERS from the original's on 1.26.0 (observed stdout of one example): review before applying |
| Patch applied word for word to the example | 2.3.0 | no literal patch to apply (removed or added code, or the old line is not found once) — wrong occurs 2 times in the example |
Verified example for mcp 2.3.0
import asyncio
import anyio
from mcp import ClientSession
async def main():
# Use the anyio dependency directly (mcp.shared.session no longer exists).
inbound_send, inbound_receive = (
anyio.create_memory_object_stream(1)
)
outbound_send, outbound_receive = (
anyio.create_memory_object_stream(1)
)
try:
# Construct only: do not enter the session or initialize a connection.
session = ClientSession(inbound_receive, outbound_send)
# BaseSession was removed in mcp 2.3.0, so the isinstance check is dropped.
print("ClientSession MRO:", [cls.__name__ for cls in ClientSession.__mro__])
finally:
inbound_send.close()
inbound_receive.close()
outbound_send.close()
outbound_receive.close()
if __name__ == "__main__":
asyncio.run(main())Source
the dead `RequestResponder` arm and the `mcp.shared.session` module are gone (#3168).
Release notes · Seen in: gpt-6.1-sol · First seen 2026-10-20 · Last verified 2026-10-27 · All corrections for mcp
For agents
- This page as JSON:
https://formachines.ai/errata/pypi/mcp/0002-mcp-shared-session/index.json - Whole database in plain text:
/errata/llms-full.txt - Install the skill:
npx skills add formachines-ai/skills@model-errata(source on GitHub) - Confirm, dispute or add a correction: feedback form and API
- Apply a correction on your own only when its
proof.auto_applyis true (Automatic application is allowed only when proof.equivalent is true and proof.applicability.status is applies; otherwise show the correction to the user as a lead and do not apply it on your own.)