galcan commited on
Commit
3a81b52
·
1 Parent(s): 6d4e416

Fix MCP session handling - allow requests without session ID

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -373,18 +373,18 @@ async def mcp_post_handler(request: Request):
373
  }
374
  }
375
 
376
- # Handle other requests with session
377
- if not session_id or session_id not in sessions:
378
  return {
379
  "jsonrpc": "2.0",
380
  "error": {
381
  "code": -32000,
382
- "message": "Bad Request: No valid session ID provided"
383
  },
384
  "id": body.get("id")
385
  }
386
 
387
- session = sessions[session_id]
388
  method = body.get("method")
389
  params = body.get("params", {})
390
  request_id = body.get("id")
 
373
  }
374
  }
375
 
376
+ # Handle other requests - allow without session for MCP compatibility
377
+ if session_id and session_id not in sessions:
378
  return {
379
  "jsonrpc": "2.0",
380
  "error": {
381
  "code": -32000,
382
+ "message": "Bad Request: Invalid session ID provided"
383
  },
384
  "id": body.get("id")
385
  }
386
 
387
+ session = sessions.get(session_id) if session_id else None
388
  method = body.get("method")
389
  params = body.get("params", {})
390
  request_id = body.get("id")