Merge branch 'fix/mcp-sampling-elicitation-hardening' of https://github.com/yugborana/litellm into fix/mcp-sampling-elicitation-hardening

This commit is contained in:
Yug 2026-04-29 13:37:24 +05:30
commit 31f1b47039

View file

@ -2720,6 +2720,20 @@ if MCP_AVAILABLE:
from starlette.responses import JSONResponse
from starlette.status import HTTP_500_INTERNAL_SERVER_ERROR
error_response = JSONResponse(
status_code=HTTP_500_INTERNAL_SERVER_ERROR,
content={"error": "MCP request failed", "details": str(e)},
)
except HTTPException:
raise
except Exception as e:
verbose_logger.exception(f"Error handling MCP request: {e}")
# Instead of re-raising, try to send a graceful error response
try:
# Send a proper HTTP error response instead of letting the exception bubble up
from starlette.responses import JSONResponse
from starlette.status import HTTP_500_INTERNAL_SERVER_ERROR
error_response = JSONResponse(
status_code=HTTP_500_INTERNAL_SERVER_ERROR,
content={"error": "MCP request failed", "details": str(e)},