mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-05 18:20:35 -08:00
Fix origin handling in HTTP request processing for MCP server
This commit is contained in:
parent
a492352901
commit
006b8c8d50
1 changed files with 3 additions and 2 deletions
|
|
@ -216,19 +216,20 @@ class MCPServer:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
async def handle_mcp_request(request: web.Request) -> web.Response:
|
async def handle_mcp_request(request: web.Request) -> web.Response:
|
||||||
|
nonlocal origin
|
||||||
"""Handle MCP JSON-RPC request over HTTP POST"""
|
"""Handle MCP JSON-RPC request over HTTP POST"""
|
||||||
try:
|
try:
|
||||||
# Parse JSON-RPC request from POST body
|
# Parse JSON-RPC request from POST body
|
||||||
request_data = await request.json()
|
request_data = await request.json()
|
||||||
if origin is None:
|
if origin is None:
|
||||||
request_origin = request.headers.get("origin")
|
origin = request.headers.get("origin")
|
||||||
|
|
||||||
mcp_request = MCPRequest(
|
mcp_request = MCPRequest(
|
||||||
jsonrpc=request_data.get("jsonrpc", "2.0"),
|
jsonrpc=request_data.get("jsonrpc", "2.0"),
|
||||||
id=request_data.get("id"),
|
id=request_data.get("id"),
|
||||||
method=request_data.get("method"),
|
method=request_data.get("method"),
|
||||||
params=request_data.get("params"),
|
params=request_data.get("params"),
|
||||||
origin=request_origin
|
origin=origin
|
||||||
)
|
)
|
||||||
|
|
||||||
# Handle request
|
# Handle request
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue