Spaces:
Sleeping
Sleeping
Fix MCP session handling - allow requests without session ID
Browse files
app.py
CHANGED
|
@@ -373,18 +373,18 @@ async def mcp_post_handler(request: Request):
|
|
| 373 |
}
|
| 374 |
}
|
| 375 |
|
| 376 |
-
# Handle other requests
|
| 377 |
-
if
|
| 378 |
return {
|
| 379 |
"jsonrpc": "2.0",
|
| 380 |
"error": {
|
| 381 |
"code": -32000,
|
| 382 |
-
"message": "Bad Request:
|
| 383 |
},
|
| 384 |
"id": body.get("id")
|
| 385 |
}
|
| 386 |
|
| 387 |
-
session = sessions
|
| 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")
|