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]

feat: add support MCP guardrail to noma

Yuta Saito4eecf59f866d
diff --git a/docs/my-website/docs/mcp_guardrail.md b/docs/my-website/docs/mcp_guardrail.md
index f71ea2fe5ef..9ce3fb2bcf8 100644
--- a/docs/my-website/docs/mcp_guardrail.md
+++ b/docs/my-website/docs/mcp_guardrail.md
@@ -85,4 +85,5 @@ MCP guardrails work with all LiteLLM-supported guardrail providers:
- **Bedrock**: AWS Bedrock guardrails
- **Lakera**: Content moderation
- **Aporia**: Custom guardrails
+- **Noma**: Noma Security
- **Custom**: Your own guardrail implementations
\ No newline at end of file
diff --git a/docs/my-website/docs/proxy/guardrails/noma_security.md b/docs/my-website/docs/proxy/guardrails/noma_security.md
index 4aebb29eb57..a66788cbb52 100644
--- a/docs/my-website/docs/proxy/guardrails/noma_security.md
+++ b/docs/my-website/docs/proxy/guardrails/noma_security.md
@@ -39,6 +39,8 @@ guardrails:
- `pre_call` Run **before** LLM call, on **input**
- `post_call` Run **after** LLM call, on **input & output**
- `during_call` Run **during** LLM call, on **input**. Same as `pre_call` but runs in parallel with the LLM call. Response not returned until guardrail check completes
+- `pre_mcp_call`: Scan MCP tool call inputs before execution
+- `during_mcp_call`: Monitor MCP tool calls in real-time
### 2. Start LiteLLM Gateway
diff --git a/litellm/proxy/guardrails/guardrail_hooks/noma/noma.py b/litellm/proxy/guardrails/guardrail_hooks/noma/noma.py
index 1794751a08c..6bb80cf9480 100644
--- a/litellm/proxy/guardrails/guardrail_hooks/noma/noma.py
+++ b/litellm/proxy/guardrails/guardrail_hooks/noma/noma.py
@@ -41,6 +41,7 @@ from litellm.main import stream_chunk_builder
from litellm.proxy._types import UserAPIKeyAuth
from litellm.types.guardrails import GuardrailEventHooks
from litellm.types.utils import (
+ CallTypes,
CallTypesLiteral,
EmbeddingResponse,
GuardrailStatus,
@@ -582,12 +583,11 @@ class NomaGuardrail(CustomGuardrail):
) -> Optional[Union[Exception, str, dict]]:
verbose_proxy_logger.debug("Running Noma pre-call hook")
- if (
- self.should_run_guardrail(
- data=data, event_type=GuardrailEventHooks.pre_call
- )
- is False
- ):
+ event_type = GuardrailEventHooks.pre_call
+ if call_type == CallTypes.call_mcp_tool.value:
+ event_type = GuardrailEventHooks.pre_mcp_call
+
+ if self.should_run_guardrail(data=data, event_type=event_type) is False:
return data
# In monitor mode, run Noma check in background and return immediately
@@ -638,6 +638,9 @@ class NomaGuardrail(CustomGuardrail):
call_type: CallTypesLiteral,
) -> Union[Exception, str, dict, None]:
event_type: GuardrailEventHooks = GuardrailEventHooks.during_call
+ if call_type == CallTypes.during_mcp_call.value:
+ event_type = GuardrailEventHooks.pre_mcp_call
+
if self.should_run_guardrail(data=data, event_type=event_type) is not True:
return data