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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test(mcp): use the shared guardrail exception in regression
Joshua Valluruf4918e69f419
diff --git a/tests/test_litellm/responses/mcp/test_chat_completions_handler.py b/tests/test_litellm/responses/mcp/test_chat_completions_handler.pyindex bfacded34c2..6e049d7634c 100644--- a/tests/test_litellm/responses/mcp/test_chat_completions_handler.py+++ b/tests/test_litellm/responses/mcp/test_chat_completions_handler.py@@ -1395,7 +1395,7 @@ async def test_acompletion_with_mcp_forwards_unserved_external_mcp_tool_to_the_p@pytest.mark.parametrize("selection_source", ["metadata", "litellm_metadata", "body"])@pytest.mark.parametrize("logging_failure", [False, True])async def test_request_selected_mcp_guardrail_blocks_before_upstream(monkeypatch, selected, stream, selection_source, logging_failure):- from fastapi import HTTPException+ from litellm.exceptions import GuardrailRaisedExceptionfrom mcp.types import Toolfrom litellm.caching.caching import DualCachefrom litellm.integrations.custom_guardrail import CustomGuardrail@@ -1410,7 +1410,7 @@ async def test_request_selected_mcp_guardrail_blocks_before_upstream(monkeypatchclass BlockSelected(CustomGuardrail):async def async_pre_call_hook(self, user_api_key_dict, cache, data, call_type):if self.should_run_guardrail(data, GuardrailEventHooks.pre_mcp_call):- raise HTTPException(status_code=400, detail="request-selected MCP block")+ raise GuardrailRaisedException(message="request-selected MCP block", blocked_content=True)return dataguardrail = BlockSelected(guardrail_name="block-all", event_hook="pre_mcp_call", default_on=False)