@@ -13,11 +13,13 @@ Get up and running with session roaming in 5 minutes!
1313### Step 1: Start Redis
1414
1515** Using Docker:**
16+
1617``` bash
1718docker run -d -p 6379:6379 redis:latest
1819```
1920
2021** Or using local Redis:**
22+
2123``` bash
2224redis-server
2325```
@@ -32,17 +34,20 @@ uv sync
3234### Step 3: Start Multiple Instances
3335
3436** Terminal 1 - Instance 1:**
37+
3538``` bash
3639uv run mcp-streamablehttp-roaming --port 3001 --instance-id instance-1
3740```
3841
3942** Terminal 2 - Instance 2:**
43+
4044``` bash
4145uv run mcp-streamablehttp-roaming --port 3002 --instance-id instance-2
4246```
4347
4448You should see:
45- ```
49+
50+ ``` text
4651======================================================================
4752🚀 Instance instance-1 started with SESSION ROAMING!
4853======================================================================
@@ -56,12 +61,14 @@ You should see:
5661### Step 4: Test Session Roaming
5762
5863** Terminal 3 - Run Test:**
64+
5965``` bash
6066./test_roaming.sh
6167```
6268
6369Expected output:
64- ```
70+
71+ ``` text
6572🧪 Testing Session Roaming Across MCP Instances
6673================================================
6774
@@ -80,6 +87,7 @@ Expected output:
8087```
8188
8289** What just happened?**
90+
83911 . Session created on Instance 1
84922 . Tool called on Instance 1 - success
85933 . ** Same session** used on Instance 2 - ** also success!**
@@ -95,6 +103,7 @@ docker-compose up -d
95103```
96104
97105This starts:
106+
98107- Redis (persistent event store)
99108- 3 MCP server instances (ports 3001, 3002, 3003)
100109- NGINX load balancer (port 80)
@@ -146,7 +155,8 @@ docker-compose logs -f mcp-instance-3
146155```
147156
148157Look for these log messages:
149- ```
158+
159+ ``` text
150160INFO - Session abc123 roaming to this instance (EventStore enables roaming)
151161INFO - Created transport for roaming session: abc123
152162INFO - Instance instance-2 handling request for session abc123
@@ -179,7 +189,8 @@ curl -X POST http://localhost:3001/mcp \
179189```
180190
181191** Save the session ID from the response header:**
182- ```
192+
193+ ``` text
183194MCP-Session-ID: a1b2c3d4e5f67890abcdef1234567890
184195```
185196
@@ -203,6 +214,7 @@ curl -X POST http://localhost:3001/mcp \
203214```
204215
205216** Response shows:**
217+
206218``` json
207219{
208220 "result" : {
@@ -234,6 +246,7 @@ curl -X POST http://localhost:3002/mcp \
234246```
235247
236248** Response shows:**
249+
237250``` json
238251{
239252 "result" : {
@@ -252,6 +265,7 @@ curl -X POST http://localhost:3002/mcp \
252265### What Enables Session Roaming?
253266
254267** Just one line of code:**
268+
255269``` python
256270session_manager = StreamableHTTPSessionManager(
257271 app = app,
@@ -260,6 +274,7 @@ session_manager = StreamableHTTPSessionManager(
260274```
261275
262276That's it! The ` event_store ` parameter enables:
277+
2632781 . ✅ Event replay (resumability)
2642792 . ✅ Session roaming (distributed sessions)
265280
@@ -276,6 +291,7 @@ When Instance 2 receives a request with an unknown session ID:
276291### Why Does This Work?
277292
278293Events in EventStore prove sessions existed:
294+
279295- Session ` abc123 ` has events in Redis
280296- Therefore session ` abc123 ` existed
281297- Safe to create transport for it
@@ -288,6 +304,7 @@ Events in EventStore prove sessions existed:
288304** Problem:** Redis not running
289305
290306** Solution:**
307+
291308``` bash
292309docker run -d -p 6379:6379 redis:latest
293310```
@@ -297,13 +314,15 @@ docker run -d -p 6379:6379 redis:latest
297314** Problem:** EventStore not configured or Redis not accessible
298315
299316** Solution:**
317+
300318- Check Redis is running: ` redis-cli ping ` (should return "PONG")
301319- Check Redis URL in server startup
302320- Check logs for Redis connection errors
303321
304322### Session not roaming
305323
306324** Checklist:**
325+
307326- [ ] Redis running and accessible
308327- [ ] All instances use same ` --redis-url `
309328- [ ] Session ID included in ` MCP-Session-ID ` header
@@ -319,6 +338,7 @@ docker run -d -p 6379:6379 redis:latest
319338## Questions?
320339
321340Check out:
341+
322342- [ README.md] ( README.md ) - Full documentation
323343- [ server.py] ( mcp_simple_streamablehttp_roaming/server.py ) - Implementation
324344- [ redis_event_store.py] ( mcp_simple_streamablehttp_roaming/redis_event_store.py ) - EventStore implementation
0 commit comments