mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-12 23:01:41 +00:00
fix(mcp): preserve www-authenticate header on HTTPException, filter # from server name
- Forward e.headers to JSONResponse in HTTPException handlers (handle_streamable_http_mcp, handle_sse_mcp) so OAuth2 www-authenticate header is preserved per RFC 9728 - Filter fragment identifier (#) from path segment when extracting server name to avoid misleading 404 Made-with: Cursor
This commit is contained in:
parent
7b234ebfd6
commit
0842186202
1 changed files with 5 additions and 1 deletions
|
|
@ -2240,7 +2240,7 @@ if MCP_AVAILABLE:
|
|||
# Child app receives path like /undefined when mounted at /mcp
|
||||
# Extract first path segment as server name
|
||||
segments = path.strip("/").split("/")
|
||||
if segments and segments[0] and "?" not in segments[0]:
|
||||
if segments and segments[0] and "?" not in segments[0] and "#" not in segments[0]:
|
||||
mcp_servers_from_path = [segments[0]]
|
||||
return mcp_servers_from_path
|
||||
|
||||
|
|
@ -2464,9 +2464,11 @@ if MCP_AVAILABLE:
|
|||
content = {"error": detail}
|
||||
else:
|
||||
content = {"error": {"message": str(detail)}}
|
||||
headers = dict(e.headers) if e.headers else {}
|
||||
error_response = JSONResponse(
|
||||
status_code=e.status_code,
|
||||
content=content,
|
||||
headers=headers,
|
||||
)
|
||||
await error_response(scope, receive, send)
|
||||
except Exception:
|
||||
|
|
@ -2554,9 +2556,11 @@ if MCP_AVAILABLE:
|
|||
content = {"error": detail}
|
||||
else:
|
||||
content = {"error": {"message": str(detail)}}
|
||||
headers = dict(e.headers) if e.headers else {}
|
||||
error_response = JSONResponse(
|
||||
status_code=e.status_code,
|
||||
content=content,
|
||||
headers=headers,
|
||||
)
|
||||
await error_response(scope, receive, send)
|
||||
except Exception:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue