Cehpoint

MCP security: giving an AI agent safe server access

MCP security for small teams: how to give an AI agent access to your servers with least privilege, fixed actions, human approval and a full audit trail.

A woman drawing a flowchart on a whiteboard

AI agents can now read your server's health, explain an alert and suggest a fix in plain English. The same connection that lets an agent help can also let it do damage if it is set up carelessly. This guide explains how to connect an agent to your servers through MCP so that it stays useful, limited and accountable.

What is MCP and why does it matter for server security?

MCP, the Model Context Protocol, is an open standard that lets an AI assistant call tools on another system, such as "list my servers" or "block this address". Each tool the agent can reach is a door into your infrastructure, so MCP security is mostly about deciding which doors exist, who can open them and who is watching.

In MCP, a server (the program offering tools) publishes a list of tools, and a client (the AI assistant) chooses which to call. The MCP specification for tools describes tools as "model-controlled": the language model decides when to call them. That is what makes agents useful, and it is why the specification also says that "there SHOULD always be a human in the loop with the ability to deny tool invocations".

The risk has a name. The OWASP Top 10 for LLM Applications calls it excessive agency: damaging actions carried out "in response to unexpected, ambiguous or manipulated outputs from an LLM". OWASP traces it to three causes: too much functionality, too many permissions and too much autonomy. The sections below take each in turn.

How much access should an AI agent have to a server?

Give an agent the least access that does the job. Start with read-only access, add the ability to act only when you have a clear need, and keep the most disruptive actions behind a separate, explicit permission. A key that can only read cannot be turned against you to change anything.

The MCP security best practices recommend a "progressive, least-privilege scope model": a minimal starting set of low-risk read operations, with more access granted only when a privileged operation is actually needed. It lists the common mistakes to avoid, including wildcard or "full-access" scopes and bundling unrelated permissions "to preempt future prompts".

A practical way to set this up for a small team:

  1. One key per agent. Name each key after the agent or person using it, so the audit log shows which one acted.
  2. Read-only by default. Most questions ("what needs my attention?", "why did this alert fire?") need no write access at all.
  3. Act only where needed. Give a separate key the ability to act, and keep it to the people or agents that need it.
  4. Strong actions separately. Actions such as ending live sessions or stopping containers should need an extra, explicit permission or a person.
  5. Revoke freely. If a key is no longer used, delete it.

Should an AI agent be allowed to run shell commands on a server?

Generally, no. A shell (a command line that can run anything) gives the agent, and anyone who can influence it, unlimited power over the server. A safer design gives the agent a short list of named actions, such as "block this address" or "renew this certificate", each with checked inputs.

OWASP's guidance on excessive agency says to avoid open-ended extensions "such as run a shell command" where possible and to prefer granular tools. The difference is easy to see in a comparison:

Question Open shell access Fixed, named actions
What can the agent do? Anything the account can do Only the actions on the list
Can inputs be checked? Hard: any command is valid Yes: each action checks its own arguments
What does approval look like? A person must read and understand a command A person approves a plain action, such as "block 203.0.113.7"
What does a manipulated agent risk? Data theft, deletion, persistence At most a listed action, still subject to its checks
What does the log show? Raw commands to interpret Clear named actions with who approved them

The MCP specification backs this up from the server side: servers "MUST validate all tool inputs", "implement proper access controls", "rate limit tool invocations" and "sanitize tool outputs".

When should a person confirm an AI agent's action?

A person should confirm any action that changes something: blocking an address, restarting a service, installing updates or stopping a process. Reading and explaining can run freely. The confirmation should show the exact action and its inputs, so the person approves what will actually happen rather than a summary of it.

The MCP tools specification says clients should "present confirmation prompts to the user for operations" and "show tool inputs to the user before calling the server". OWASP lists human-in-the-loop control for high-impact actions as a core defence, and its prompt injection guidance says to "require human approval for high-risk actions".

Good confirmation design looks like this:

  • the agent explains what it found and what it proposes, in plain language;
  • the action and its inputs are shown exactly;
  • the person approves or declines, and the agent cannot approve on their behalf;
  • only actions offered for that specific problem can be run.

How do I stop an AI agent being tricked by what it reads?

You cannot fully prevent it, so limit what a tricked agent could do. Logs, web pages and alert text can contain words planted by an attacker, and a language model may follow them as instructions. This is called indirect prompt injection. Keep untrusted content away from powerful tools and keep a person approving changes.

OWASP defines indirect prompt injection as what happens when a model "accepts input from external sources, such as websites or files". Server logs are a good example: an attacker controls the web addresses and browser names they send, and those end up in your access log, which is exactly what a security agent reads.

The NCSC is direct about the limits. Its blog post Prompt injection is not SQL injection (it may be worse) says prompt injection attacks "may never be totally mitigated", because the models do not separate data from instructions. Its recommendations are practical:

  • rely on deterministic (non-AI) safeguards that limit what the system can do;
  • reduce the agent's privileges when it is handling untrusted input;
  • mark external content clearly as data;
  • log inputs, outputs and tool calls so unusual behaviour can be spotted.

Fixed actions and human confirmation are exactly those deterministic safeguards: even a manipulated agent can only propose a listed action, and a person still has to approve it.

How should secrets and API keys for an AI agent be handled?

Treat the agent's key like any other credential. Store it in the assistant's configuration or a secret store, never in a shared document or chat. Give it the smallest scope, keep server passwords and private keys out of the agent's reach entirely, and make sure the service only ever stores a hash of the key.

Two points from the MCP security guidance are worth knowing even if you do not build MCP servers yourself:

  • Tokens must be meant for the server using them. The specification says MCP servers "MUST NOT accept any tokens that were not explicitly issued for the MCP server", which rules out passing one service's key through to another.
  • Local MCP servers run with your privileges. A local MCP server (one that runs on your own computer) can do anything your account can. The guidance warns about servers from untrusted sources and says clients offering one-click set-up must show the exact command that will run before you approve it.

One more habit of our own: data sent to an agent should have passwords and tokens masked before it leaves the machine, because anything an agent reads may end up in its conversation history.

Why do audit logs matter when an AI agent can act on servers?

An audit log records who did what, when and with which key. When an agent can act, the log is how you check it behaved as expected, explain a change to a client or insurer, and spot a misused key. Each action should be recorded against the named key or person that approved it.

The MCP specification says clients should "log tool usage for audit purposes", and the NCSC's guidelines for secure AI system development include logging and monitoring in the operation and maintenance stage. Review the log regularly, not only after an incident.

This is how Cehpoint's AI agent access to the Agentic SOC is built. Agents connect to a remote MCP server with an API key scoped to read or act, with strong actions needing an extra permission or a person in the console. Every action is one of a fixed list built into the device agents, re-checked on the device; nothing runs arbitrary commands. Fixes are confirmed through a form in the assistant, or by typing "yes" where forms are not supported, and every action is written to the account's activity log under the key's name. Answers are compact summaries, typically hundreds of times less to read than the raw logs behind them. The wider controls are set out in the security overview.

Frequently asked questions

Is MCP itself secure?

MCP is a protocol, so its security depends on how servers and clients use it. The specification sets requirements and recommendations, such as validating inputs, rate limiting, human confirmation and least-privilege scopes. A well-built MCP server with narrow tools is much safer than a broad one, whatever the protocol.

Can I give an AI agent read-only access to my servers?

Yes, and it is the best place to start. Read-only access lets an agent summarise health, list alerts and explain what happened without being able to change anything. Add the ability to act later, on a separate key, once you are comfortable with how the agent behaves.

What is the difference between a local and a remote MCP server?

A local MCP server runs on your own computer, usually started by the assistant, and has the same access as your user account. A remote MCP server runs elsewhere and is reached over the internet, usually with a key or sign-in. Remote servers keep powerful access off your laptop; local ones need care over where they came from.

Does human confirmation slow an AI agent down too much?

Only for changes. Reading, summarising and explaining run without interruption, and those are most of what an agent does. A confirmation for each change takes seconds and is the main protection if the agent has been misled by something it read, so it is worth keeping for anything that alters a server.

If you are planning to let AI agents work on your infrastructure, read how Cehpoint connects AI coding agents to the Agentic SOC, or start with the documentation for agent access.

Sources checked on 2 December 2026.

See what your own servers need today.