60e0ffc959
Upgrade checks / Notify on failure (push) Has been cancelled
Upgrade checks / Close issue on success (push) Has been cancelled
Schema Crash Test / Real-world schema crash test (232K schemas) (push) Has been cancelled
Run static analysis / static_analysis (push) Has been cancelled
Tests / Tests: Python 3.10 on ubuntu-latest (push) Has been cancelled
Tests / Tests: Python 3.13 on ubuntu-latest (push) Has been cancelled
Tests / Tests: Python 3.10 on windows-latest (push) Has been cancelled
Tests / Tests with lowest-direct dependencies (push) Has been cancelled
Tests / MCP conformance tests (push) Has been cancelled
Tests / Integration tests (push) Has been cancelled
Tests / Package install smoke (push) Has been cancelled
Upgrade checks / Static analysis (push) Has been cancelled
Upgrade checks / Tests: Python 3.10 on ubuntu-latest (push) Has been cancelled
Upgrade checks / Tests: Python 3.13 on ubuntu-latest (push) Has been cancelled
Upgrade checks / Tests: Python 3.10 on windows-latest (push) Has been cancelled
Upgrade checks / Integration tests (push) Has been cancelled
Update MCPServerConfig Schema / update-config-schema (push) Has been cancelled
Update SDK Documentation / update-sdk-docs (push) Has been cancelled
Persistent Session State
This example demonstrates session-scoped state that persists across tool calls within the same MCP session.
What it shows
- State set in one tool call is readable in subsequent calls
- Different clients have isolated state (same keys, different values)
- Reconnecting creates a new session with fresh state
Running
HTTP transport:
# Terminal 1: Start the server
uv run python server.py
# Terminal 2: Run the client
uv run python client.py
STDIO transport (in-process):
uv run python client_stdio.py
Example output
Each line below is a separate tool call
Alice connects
session a9f6eaa3
set user = Alice
set secret = alice-password
get user → Alice
get secret → alice-password
Bob connects (different session)
session 0c3bffc5
get user → not found
get secret → not found
set user = Bob
get user → Bob
Alice reconnects (new session)
session e39640e3
get user → not found