This commit is contained in:
Yug 2026-04-29 14:20:16 +05:30
parent e6d1ba8679
commit 8329baeedb
2 changed files with 9 additions and 4 deletions

View file

@ -2690,7 +2690,7 @@ if MCP_AVAILABLE:
verbose_logger.info(
"SSE connection established, running server loop..."
)
# ContextVars can sometimes be lost when the MCP SDK spawns internal tasks
# (e.g. _receive_loop), so tool handlers can't read auth_context_var reliably.
# Storing it on the read_stream ensures it's isolated per SSE session.
@ -2770,7 +2770,10 @@ if MCP_AVAILABLE:
error_response = JSONResponse(
status_code=500,
content={"error": "Authentication processing failed", "details": str(e)},
content={
"error": "Authentication processing failed",
"details": str(e),
},
)
await error_response(scope, receive, send)
# CRITICAL: Stop execution if auth extraction fails to prevent unauthenticated fall-through
@ -2936,7 +2939,9 @@ if MCP_AVAILABLE:
read_stream = getattr(session, "_read_stream", None)
stored = getattr(read_stream, "_litellm_auth_context", None)
except Exception as e:
verbose_logger.debug(f"get_or_extract_auth_context FALLBACK failed: {e}")
verbose_logger.debug(
f"get_or_extract_auth_context FALLBACK failed: {e}"
)
stored = None
verbose_logger.debug(

View file

@ -1219,7 +1219,7 @@ class NewMCPServerRequest(LiteLLMPydanticObjectBase):
base_command_no_ext = base_command
for ext in [".exe", ".cmd", ".bat", ".com"]:
if base_command.lower().endswith(ext):
base_command_no_ext = base_command[: -len(ext)]
base_command_no_ext = base_command[: -len(ext)].lower()
break
if (
base_command not in MCP_STDIO_ALLOWED_COMMANDS