What are the core security risks with MCP?
The core security risks do not stem from the Model Context Protocol itself, but from the "agentic loop" where a model decides which tools to call to complete a goal. When an agent is given the ability to execute tools—such as reading databases or sending messages—it can perform unintended or unauthorized actions if the system lacks proper constraints.
When you implement MCP servers, you are essentially giving an AI agent a set of hands. These hands can do wonderful things, like checking a stock level or updating a customer's address, but they can also make mistakes or be manipulated.
- Unintended Tool Execution: MCP allows models to call tools like database queries, file writes, or API calls. A model might misinterpret a goal and trigger a command it shouldn't have.
- Critical Action Risks: Without strict constraints, an agent could perform "critical" actions—such as deleting a customer's transaction history or making external payments—without a human ever knowing.
- The Feedback Loop: Most reliability and security challenges arise from the loop where an agent decides its own next step based on the outputs it receives from a tool. If a tool returns an error or unexpected data, the agent might enter a loop of incorrect decisions.
Implementing Guardrails and Human Approvals
For a small business owner in India, imagine an agent tasked with managing your WhatsApp customer queries. This is where guardrails come in.
Guardrails are rules enforced outside the model. You should never rely on the AI simply "promising" to be good; the software surrounding the AI must be the enforcer. These rules can limit which tools are allowed, set spending limits on API calls, or block specific domains entirely.
Autonomy Levels and Approvals
Not all tasks require the same level of oversight. In a robust agentic architecture, you can assign different levels of autonomy to your agents, ranging from "Observe" to "Autonomous."
- Observe: The agent watches and reports but takes no action.
- Assist: The agent prepares a task and waits for you to click "Go."
- Act: The agent performs routine, low-risk tasks (like fetching a price list).
- Autonomous: The agent handles complex, multi-step processes independently.
For any action that falls into a high-risk category, you must implement a human approval step. This creates a mandatory pause point where a person must explicitly review the proposed action and say "yes" or "no" before the tool is actually executed.
Ensuring Accountability with Audit Logs
If an agent makes a mistake—perhaps it accidentally sends a discount code to the wrong person—you need to know exactly why it happened. You cannot rely on simple text logs that can be easily edited or deleted. Instead, you need a permanent record of the agent's "thought process" and its actions.
A professional implementation uses a hash-chained audit log. This means every action taken by the agent is cryptographically linked to the one before it. This makes it impossible for someone (or the system itself) to quietly edit the history to hide a mistake or a malicious act.
Beyond security, these logs are vital for debugging. When an agent fails, you can use these logs to see the exact sequence of tool calls and observations that led to the error. This allows developers to understand if the problem was the model's reasoning or a failure in the tool itself.
Classifying Tool Risk Levels
To manage security effectively, you should not treat all tools as equal. A tool that reads a public FAQ is very different from a tool that can write to your main accounting database. You should categorize every tool into a risk class:
| Risk Class | Description | Required Oversight |
|---|---|---|
| Read | Retrieving non-sensitive information (e.g., checking a product description). | Low; can be autonomous. |
| Fetch | Retrieving specific data points (e.g., checking a customer's last order date). | Low to Moderate. |
| Write | Modifying existing data (e.g., updating a shipping address in a CRM). | Moderate; often requires human approval. |
| External | Interacting with third-party APIs or sending messages to customers. | High; requires strict guardrails. |
| Critical | Actions with significant financial or data integrity consequences (e.g., deleting records, making payments). | Very High; mandatory human intervention. |
By classifying tools this way, you can allow your agents to work quickly on easy tasks while ensuring that "Critical" tools are always gated by strict autonomy levels and human checkpoints. Additionally, every system should include a kill switch—a way to immediately stop an agent if it begins behaving in an unexpected or repetitive manner.
Building Secure Agentic Architectures
Security is not just about blocking bad actions; it is about building a system that is "safe by design." When designing your MCP server architecture, consider these three layers of defense:
1. Deterministic Verifiers
While LLMs are great at reasoning, they can be bad at math or strict logic. A verifier is a component—often using standard, unbreakable code—that checks the agent's work. For example, if an agent calculates the total of five invoices, a verifier (using a simple Python script) can check if the sum is mathematically correct before the agent is allowed to move to the next step.
2. Resource Budgets
An agent can get stuck in a "loop," where it keeps trying the same failing action over and over. This can lead to massive API costs or server strain. You must implement:
- Step Budgets: A limit on the total number of steps an agent can take in a single run.
- Token Budgets: A limit on the amount of "thinking" (tokens) the agent can consume.
- Bounded Cycles: Code-based limits that detect if an agent is repeating the same sequence of actions.
3. The Verifier Loop
In advanced patterns, you might use an "Evaluator-optimizer" approach. One agent performs a task, and a second, separate component (the verifier) checks the result against the original goal. If the result doesn't match the goal, the agent is sent back to try again, but only within the bounds of its assigned budget.
By combining these architectural safeguards, you can move from simple, risky chatbots to reliable, production-grade agents that can actually help run a business.
Frequently Asked Questions
- How do you prevent an AI agent from making unauthorized API calls?
- You should implement guardrails outside the model that define an allow-list of permitted tools and domains, ensuring the agent cannot call unapproved endpoints.
- What is the role of human approval in MCP security?
- Human approval acts as a mandatory checkpoint for risky actions, ensuring a person reviews and authorizes any task classified as 'critical' before it executes.
- How can I track what an agent has done?
- Use a hash-chained audit log to record every action, providing a permanent and unchangeable record of the agent's decisions and tool calls.
- Can an agent loop indefinitely and cause high costs?
- Yes, which is why you must implement token budgets, step limits, and bounded cycles within the agentic loop to prevent runaway execution.
- What is a 'verifier' in agentic security?
- A verifier is a component—often using deterministic code—that checks the agent's work against specific criteria to ensure accuracy before the task is considered complete.

Questions people ask
How do you prevent an AI agent from making unauthorized API calls?
You should implement guardrails outside the model that define an allow-list of permitted tools and domains, ensuring the agent cannot call unapproved endpoints.
What is the role of human approval in MCP security?
Human approval acts as a mandatory checkpoint for risky actions, ensuring a person reviews and authorizes any task classified as 'critical' before it executes.
How can I track what an agent has done?
Use a hash-chained audit log to record every action, providing a permanent and unchangeable record of the agent's decisions and tool calls.
Can an agent loop indefinitely and cause high costs?
Yes, which is why you must implement token budgets, step limits, and bounded cycles within the agentic loop to prevent runaway execution.
What is a 'verifier' in agentic security?
A verifier is a component—often using deterministic code—that checks the agent's work against specific criteria to ensure accuracy before the task is considered complete.
