Skip to main content
When AI agents invoke tools through MCP servers, sensitive data can flow in both directions β€” tool inputs may contain PII or restricted content, and tool outputs may return confidential data. MCP Guardrails let you intercept and enforce policies on tools/call requests at two stages: You can apply guardrails at the workspace level (default for all MCP servers in a workspace) or at the server level (targeting specific MCP servers and even individual tools).

How It Works

MCP guardrails use the same policy engine as LLM guardrails, with the target field set to mcp_tools. This keeps MCP and LLM guardrails separate β€” existing LLM guardrails are unaffected. Each guardrail consists of checks (the validation rules) and actions (what happens when a check fails). You then map the guardrail to one or more MCP servers, choosing whether it runs on tool inputs, outputs, or both. When both workspace-level and server-level guardrails are configured, server-level guardrails are applied in addition to workspace defaults.

Supported Checks

The following guardrail checks are available for MCP tool calls (target: "mcp_tools"):
LLM-specific checks (PII detection, content moderation, language checks, and third-party provider checks like Patronus, Azure, Bedrock, etc.) are not available for MCP tool calls. Use the checks listed above for MCP guardrails.

Key Concepts

Target

Every guardrail has a target field: When creating a guardrail for MCP, set target to "mcp_tools".

Run On

Each MCP server mapping includes a run_on field that controls when the guardrail executes: You can set run_on to ["input"], ["output"], or ["input", "output"] for both.

Capability Scoping

By default, a guardrail mapping applies to all tools on an MCP server. To narrow the scope to specific tools, pass mcp_integration_capability_ids β€” an array of tool capability UUIDs. The guardrail will only run on calls to those specific tools.

Workflow

Step 1: Create an MCP Guardrail

Create a guardrail with target: "mcp_tools". Unlike LLM guardrails, checks and actions are optional at creation time β€” you can configure them later.
cURL
Response:

Step 2: Map the Guardrail to MCP Servers

Attach the guardrail to one or more MCP servers. You can use either the bulk sync endpoint (replace all mappings at once) or the single upsert endpoint. This is a declarative, idempotent operation β€” it replaces the full set of MCP server mappings for the guardrail.
cURL
Response:

Single Server Upsert

Map or update a guardrail for a single MCP server:
cURL
Response:

Step 3: Verify the Configuration

List all MCP server mappings for a guardrail:
cURL
Response:

Workspace-Level Defaults

You can set MCP guardrails as workspace defaults so they apply to all MCP servers in a workspace. Configure mcp_input_guardrails and mcp_output_guardrails in your workspace settings.

Blocked Request Response

When a guardrail blocks an MCP tool call, the gateway returns an MCP-compliant JSON-RPC error:

API Reference

Create Guardrail

Create a new guardrail. Set target to "mcp_tools" for MCP guardrails.

List Guardrails

Retrieve guardrails with optional filtering by target.

Get Guardrail

Retrieve a single guardrail by ID or slug. For mcp_tools target guardrails, the response includes mcp_server_mappings.
mcp_server_mappings is only included in the response when target is "mcp_tools".

Update Guardrail

Update a guardrail’s name, checks, or actions.

Delete Guardrail

Archive a guardrail. This also removes all MCP server mappings.
A guardrail cannot be deleted if it is currently used in workspace or organisation defaults (including mcp_input_guardrails and mcp_output_guardrails). Remove it from defaults first.

Bulk Sync MCP Server Mappings

Declaratively sync all MCP server mappings for a guardrail. This replaces the entire set β€” servers not included in the request body are removed.
Request Body: Validation rules:
  • The guardrail must have target: "mcp_tools"
  • All MCP server IDs must be valid UUIDs
  • run_on must be a non-empty array containing "input" and/or "output"
  • All mcp_integration_capability_ids must exist in the database

Upsert Single MCP Server Mapping

Create or update a guardrail mapping for a single MCP server.

List MCP Server Mappings

List all MCP server mappings for a guardrail.

Error Responses


Next Steps

Guardrail Checks

Full list of available guardrail checks and parameters.

Rate Limits

Throttle MCP tool call requests and token consumption.

Observability

Monitor MCP tool call logs and usage analytics.

Access Control

Control which workspaces and users can access MCP servers.

Portkey is now PRISMA AIRS AI Gateway. See it in action.

Contact Us
Last modified on September 3, 2026