Guardrail Overview
Cedar Guardrails use the Cedar policy language to evaluate authorization decisions for MCP tool executions. When an agent attempts to invoke an MCP tool, the Cedar guardrail evaluates the request against your defined policies to determine whether the action should be permitted or forbidden.Key Features
- Fine-grained Access Control: Control access at the level of individual tools, users, teams, and even specific tool arguments
- Context-aware Policies: Make authorization decisions based on request context, including tool names, arguments, and user attributes
- Default Deny: By default, all actions are denied unless explicitly permitted by a policy
- Declarative Syntax: Write policies in a clear, readable format that’s easy to understand and maintain
- Real-time Evaluation: Policies are evaluated in real-time for each tool invocation
When to Use Cedar Guardrails
Cedar Guardrails are ideal for:- MCP Tool Access Control: Restrict which users or teams can invoke specific MCP tools
- Argument-based Restrictions: Allow or deny tool invocations based on specific argument values
- Team-based Permissions: Implement team-level access controls for tool usage
- Compliance Requirements: Enforce organizational policies and compliance rules
Entities
Cedar policies operate on entities, which represent the actors and resources in your authorization model. In the context of MCP tool guardrails, the following entity types are used:Principal Entity
The principal represents the user, virtual account, or agent attempting to invoke the tool. Principal entities can be either: User entities have the following structure:Resource Entity
The resource represents the MCP server or tool being accessed. Resource entities have the following structure:Context Entity
The context provides information about the current request, including:Schema
The Cedar schema defines the structure of entities, actions, and common types used in your policies. Here’s the schema for MCP tool guardrails:Schema Components
- Entity Types: Define the structure of principals (User, VirtualAccount) and resources (MCPServer)
- Actions: Define the operations that can be performed (e.g.,
execute_tool) and their context requirements
Example Policies
Here are practical examples of Cedar policies for MCP tool access control:Example 1: Forbid Specific User from Executing Tool with Specific Arguments
This policy prevents a specific user from executing a tool when certain conditions are met:- Blocks the user with email
person@truefoundry.comfrom executing theask_questiontool - Only applies when the tool is invoked on the
test-mcps-deepwikiMCP server - Specifically blocks when the
repoNameargument equals"truefoundry/CruiseKube"
Example 2: Permit Team Members to Execute Tool
This policy allows members of a specific team to execute a tool:- Allows any user who is a member of the
"test-team"team to execute theask_questiontool - Only applies when the tool is invoked on the
test-mcps-deepwikiMCP server - Specifically permits when the
repoNameargument equals"truefoundry/CruiseKube"
Additional Policy Examples
Permit All Users for Specific Tool
Forbid Access to Sensitive Repositories
Permit Based on Multiple Team Membership
Safety and Enforcement
Cedar Guardrails implement a default deny security model, ensuring that only explicitly permitted actions are allowed.Default Deny Model
By default, all tool invocations are denied unless a policy explicitly permits them. This means:- No Policy = Denied: If no policy matches a request, the action is automatically denied
- Explicit Permit Required: An action is only allowed if at least one
permitpolicy matches - Forbid Overrides Permit: If any
forbidpolicy matches, the action is denied even if apermitpolicy also matches
Enforcement Points
Cedar Guardrails are enforced at the MCP Pre Tool hook, which means:- Policies are evaluated before the tool is actually invoked
- If a policy denies the request, the tool invocation is blocked
- The user receives an authorization error without the tool being executed
- This prevents unauthorized access
Configuration
Users can configure Cedar guardrail rules on the MCP Pre Tool hook from AI Gateway → Controls → Guardrails. Navigate to the Guardrails section and add your Cedar guardrail to themcp_tool_pre_invoke_guardrails field in your guardrail configuration rules.
Best Practices for Safety
- Principle of Least Privilege: Start with deny-all and add specific permits only for necessary access
- Validate Tool Arguments: Always validate tool arguments in your policies to prevent unauthorized access to specific resources
- Team-based Access: Prefer team-based permissions over individual user permissions for easier management
- Regular Policy Review: Regularly review and audit your policies to ensure they match your security requirements
Error Handling
When a Cedar guardrail denies a request:- The tool invocation is blocked before execution
- An authorization error is returned to the caller
- The error message indicates that access was denied by a Cedar policy
- Request traces will show which policy (if any) matched and caused the denial
Cedar policies are evaluated in real-time for each tool invocation. This ensures that changes to user attributes (like team membership) are immediately reflected in authorization decisions without requiring policy updates.