Back to all articles
ai automationTool Permissions

How to Design Safe Tool Permissions for MCP-Based Agents

Granting unrestricted write access to AI agents introduces severe security and data integrity vulnerabilities. Designing safe tool permissions requires strict JSON Schema parameter sanitization, explicit read-only vs mutating flags, and human-in-the-loop confirmation gates.

August 20, 2026
12-14 min read
Digital Elliptical Engineering (Principal Security Architect)
mcp_tool_permission_gate.exe
TOOL SPECIFICATION
get_user_account()Queries user metadata from replica. Zero side effects.
isMutating: false
PARAMETER SANITIZATION
> Schema: Zod.strictObject()
> SQL Injection Filter: PASSED
> Egress Whitelist: PASSED
INPUT CONTRACT VERIFIED
GOVERNANCE GATE
Auto-Approved for ExecutionRead-only operations execute immediately without human friction.
Action Status: AUTHORIZED

Executive Summary

  • Unsanitized tool inputs expose internal enterprise systems to SQL injection and command execution exploits.
  • Every MCP tool must be explicitly classified as read-only or mutating in its metadata schema.
  • Mutating tools must trigger client-side approval gates before JSON-RPC frames are dispatched.
  • Parameter validation must enforce strict regex whitelists and prevent unbounded string wildcards.
  • Comprehensive audit logging captures prompt context, parameter diffs, and human supervisor signatures.

The tool execution threat surface in autonomous agents

Language models are probabilistic reasoning engines, not deterministic software programs. When an agent is given access to tools like `execute_sql`, `send_email`, or `delete_repository`, any prompt injection or hallucinated reasoning step can trigger catastrophic real-world side effects.

Traditional API security models assume a human user is making deliberate clicks in a UI. In agentic workflows, an LLM generates the parameter values autonomously without direct human verification of each step.

To protect enterprise data, developers must build a multi-layered security perimeter around Model Context Protocol (MCP) servers, enforcing least-privilege access, strict input validation, and cryptographic confirmation gates.

Defense in depth

Never rely on the system prompt to prevent dangerous tool calls. Safety must be enforced deterministically at the protocol and schema layer.

The three-tier tool permission hierarchy

Enterprise tool catalogs should categorize every available capability into one of three distinct permission tiers:

1. Tier 1: Read-Only Tools (Auto-Approved). These tools observe data without modifying state (e.g. `get_invoice_status`, `read_file`). They execute automatically without human friction.

2. Tier 2: Low-Risk Mutating Tools (Automated Policy Evaluation). These tools make minor modifications with limited financial or operational impact (e.g. `tag_ticket`, `create_draft_email`). They require policy evaluation and anomaly scoring.

3. Tier 3: High-Risk Mutating Tools (Human Gate Required). These tools execute irreversible actions (e.g. `process_refund`, `drop_database`, `revoke_credentials`). They require mandatory supervisor approval.

Tool permission governance matrix

Comparing permission tiers, verification requirements, and execution models.

Tool permission hierarchy comparison

FeaturePermission TierMutation RiskApproval MechanismAudit Requirement
Tier 1: Read-OnlyZero (Read replica query)Auto-approved by runtimeStandard structured access log
Tier 2: Low-Risk MutateLow (Reversible drafting/tagging)Automated rule engine evaluationTelemetry span with argument diff
Tier 3: High-Risk MutateCritical (Financial/Data deletion)Mandatory human cryptographic signatureImmutable audit ledger with dual-key signoff

Hardened MCP tool schema with Zod validation

Below is an example of an MCP tool definition enforcing strict parameter typing and explicit mutating metadata flags.

SafeToolDefinition.ts
Hardened Schema Pattern
import { z } from "zod"; // 1. Strict parameter schema with regex sanitization export const RefundCustomerSchema = z.object({ customerId: z.string().regex(/^cus_[a-zA-Z0-9]{16}$/, "Invalid customer ID format"), amountCents: z.number().int().positive().max(50000, "Maximum single refund limit is $500.00"), reasonCode: z.enum(["DUPLICATE_CHARGE", "CUSTOMER_REQUEST", "FRAUD_SUSPECT"]), idempotencyKey: z.string().uuid() }); // 2. MCP tool specification with security metadata export const refundCustomerTool = { name: "refund_customer", description: "Issues a refund to a verified customer account. REQUIRES SUPERVISOR APPROVAL.", inputSchema: zodToJsonSchema(RefundCustomerSchema), securityMetadata: { permissionTier: 3, isMutating: true, requiresHumanConfirmation: true, maxImpactUSD: 500 } };

Parameter sanitization and egress DLP inspection

Before an argument is passed to an internal database or third-party API, the tool gateway performs deep parameter sanitization.

SQL queries must never be concatenated from raw strings; they must use parameterized prepared statements. File paths must be resolved and checked against path traversal exploits (e.g. `../../etc/passwd`).

Additionally, outbound data payloads are inspected by Data Loss Prevention (DLP) engines to prevent accidental exfiltration of Social Security numbers, credit card numbers, or API keys.

Integrating client-side human confirmation gates

When an agent decides to invoke a Tier 3 mutating tool, the MCP client intercepts the call. Rather than dispatching the JSON-RPC request immediately, the client renders a structured review card in the user interface.

The human operator inspects the proposed arguments, reviews the financial impact, and clicks 'Approve' or 'Reject'. Only upon approval does the client sign the payload and send the `tools/call` frame to the server.

MCP tool security and audit checklist

Verify these security guardrails across all MCP tool implementations.

Tool security checklist

1Schema & Validation
  • All parameters are strictly typed with Zod or JSON Schema
  • String inputs use strict regex patterns to prevent SQL injection and path traversal
  • Unbounded text inputs are constrained with maximum length limits
2Permissions & Human Gates
  • Tools are explicitly tagged with read-only vs mutating flags
  • Mutating operations require client-side human confirmation
  • Financial tools enforce maximum transaction limits per invocation
Decision path

Harden your AI agent tool security and permission boundaries

Unvalidated tool calls can lead to accidental data loss or unauthorized mutations. We will help you implement strict MCP permission gates and DLP filters.

Schedule an AI security review

Keep Reading