Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix: fix indent

Krrish Dholakia4360e1932220
diff --git a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py
index 1d8fa7f2feb..2554e46b9ba 100644
--- a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py
+++ b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py
@@ -355,12 +355,12 @@ class MCPServerManager:
)
# Update tool name to server name mapping (for both prefixed and base names)
- self.tool_name_to_mcp_server_name_mapping[
- base_tool_name
- ] = server_prefix
- self.tool_name_to_mcp_server_name_mapping[
- prefixed_tool_name
- ] = server_prefix
+ self.tool_name_to_mcp_server_name_mapping[base_tool_name] = (
+ server_prefix
+ )
+ self.tool_name_to_mcp_server_name_mapping[prefixed_tool_name] = (
+ server_prefix
+ )
registered_count += 1
verbose_logger.debug(
@@ -1188,26 +1188,26 @@ class MCPServerManager:
asyncio.create_task(_call_tool_via_client(client, call_tool_params))
)
- # IMPORTANT: Must await tasks INSIDE the context manager to keep connection alive
- try:
- mcp_responses = await asyncio.gather(*tasks)
- except (
- BlockedPiiEntityError,
- GuardrailRaisedException,
- HTTPException,
- ) as e:
- # Re-raise guardrail exceptions to properly fail the MCP call
- verbose_logger.error(
- f"Guardrail blocked MCP tool call during result check: {str(e)}"
- )
- raise e
+ # IMPORTANT: Must await tasks INSIDE the context manager to keep connection alive
+ try:
+ mcp_responses = await asyncio.gather(*tasks)
+ except (
+ BlockedPiiEntityError,
+ GuardrailRaisedException,
+ HTTPException,
+ ) as e:
+ # Re-raise guardrail exceptions to properly fail the MCP call
+ verbose_logger.error(
+ f"Guardrail blocked MCP tool call during result check: {str(e)}"
+ )
+ raise e
- # If proxy_logging_obj is None, the tool call result is at index 0
- # If proxy_logging_obj is not None, the tool call result is at index 1 (after the during hook task)
- result_index = 1 if proxy_logging_obj else 0
- result = mcp_responses[result_index]
+ # If proxy_logging_obj is None, the tool call result is at index 0
+ # If proxy_logging_obj is not None, the tool call result is at index 1 (after the during hook task)
+ result_index = 1 if proxy_logging_obj else 0
+ result = mcp_responses[result_index]
- return cast(CallToolResult, result)
+ return cast(CallToolResult, result)
# For OpenAPI tools, await outside the client context
try: