News / Learn / MCP & tool integrations
What are the security risks of MCP?
You'll be able to name the main security risks of MCP and apply basic controls to reduce them.
In plain English
The Model Context Protocol (MCP) lets an AI app call outside tools and read outside data through a server. Every server you connect adds new paths for an attacker or a mistake to cause harm. The risks come from what the model reads, what tools it can run, and what permissions those tools hold.
Why it matters
If you build a product with AI, MCP servers can read files, query databases, send messages, or change records. A single bad instruction or a malicious server can turn those abilities against your users or your data. Knowing the risks lets you design the app so one failure does not become a breach.
How it works
The first risk is prompt injection through tool output. A tool may return text such as a web page, an email, or a document that contains hidden instructions. The model can treat that text as a command and call another tool, such as one that sends data out. Because the model cannot always tell instructions from data, you should treat all tool output as untrusted input.
The second risk is excessive permission. An MCP server often runs with the access of the user or service account that started it. If a server can delete files, read every table, or call any API, a single mistake or injected instruction can cause large damage. Give each server the smallest set of tools and scopes it needs.
The third risk is untrusted servers. Installing a server means running code or trusting a remote endpoint with the data you send it. A malicious or compromised server can log prompts, steal credentials passed to it, or return poisoned results. Only connect servers from sources you have reviewed, and pin the versions you use.
The fourth risk is secret leakage. Tokens and keys placed in configs, prompts, or tool arguments can end up in logs, model context, or third-party systems. Keep secrets in a secret store, pass them only where needed, and redact them from logs.
A concrete example
A simple policy check that requires human approval before any tool that writes or sends data runs.
SAFE_TOOLS = {"search_docs", "get_weather"}
REVIEW_TOOLS = {"send_email", "delete_file", "run_query"}
def run_tool(name, args, ask_user):
if name in SAFE_TOOLS:
return call_tool(name, args)
if name in REVIEW_TOOLS:
if not ask_user(f"Allow {name} with {args}?"):
return {"error": "denied by user"}
return call_tool(name, args)
# Unknown tools are blocked by default.
return {"error": f"tool {name} is not allowed"}A short sketch to show the idea. Check the official docs of the tool you use.
What goes wrong
- Trusting tool output as safe Treat text from tools, web pages, and files as untrusted. Never let it set tool choice or permissions without a check.
- Giving servers broad access Grant read-only or narrowly scoped credentials. Split a powerful server into smaller ones with fewer tools.
- Installing unreviewed servers Review the code or the provider before you connect it. Pin versions and watch for changes after install.
- Putting secrets in prompts or logs Load secrets from a secret manager at call time. Redact tokens from logs and never echo them back to the model.
Going deeper
Learn the principle of least privilege, threat modeling for LLM apps, and common defenses against prompt injection, such as separating trusted instructions from untrusted data and requiring confirmation for high-impact actions.
FAQ
Can I make MCP fully safe?
No system is fully safe. You can lower the risk by limiting permissions, reviewing servers, requiring approval for sensitive actions, and monitoring tool use.
Is prompt injection only a problem for MCP?
No. Any AI app that reads outside text and acts on it can face prompt injection. MCP makes it more serious because tools can take real actions.
Should I run MCP servers locally or remotely?
Both carry risk. Local servers run with your user's access. Remote servers receive your data. Choose based on what data the server sees and what it can do.
How do I know which tool calls are risky?
Flag any tool that writes, deletes, sends, pays, or reads sensitive data. Those calls deserve review or extra checks.
Written with AI by CapyLaunch. Spotted a mistake? Email hello@capylaunch.com.