MCP Security: How to Test Servers, Tools and Agent Integrations

GUIDE MCP Security Testing Guide A bounded, authorized workflow for servers, tools and agent integrations 1 Scope and Inventory Map servers, transports and identities 2 Baseline Capture advertised tools verbatim 3 Two-Principal Controls Principal A can; principal B must not 4 Verifying Impact Severity follows demonstrated evidence Authorized scope Inert fixtures Token audience Least privilege Audit logging fortbridge.co.uk

Why MCP needs its own testing approach

The Model Context Protocol (MCP) is now the default way AI assistants and agents connect to external systems: file stores, databases, ticketing platforms, cloud services and internal APIs. An MCP server advertises tools (actions the model can invoke), resources (data it can read) and prompts (reusable templates), and the host application mediates between the model and those servers.

That architecture changes the security question. In contrast, a traditional API test asks “can an attacker call this endpoint?” An MCP assessment has to ask a second question as well: “can the model be made to call this endpoint, with these arguments, on the user’s behalf?” The MCP specification is explicit that tools are model-controlled (the model can discover and invoke them automatically) and that there should always be a human in the loop able to deny invocations, with clear UI showing which tools are exposed and prompts to confirm sensitive operations [1].

Testing MCP therefore sits across two disciplines: classic application security (the server is still just software with an attack surface) and AI behaviour (the model is the caller, and it can be steered). This guide sets out how we approach it in an approved engagement, and the controls we most often recommend.

Architecture and trust boundaries

A typical MCP deployment has four parties, and each arrow below is a trust boundary worth testing:

MCP trust boundaries Four boxes: User, Host application with the model, MCP servers A and B, and upstream APIs and data. Arrows mark four trust boundaries. User Host application (client + model) MCP server A MCP server B Upstream APIs, files, data 1. intent 2. tool calls 2. tool calls 3. onward access
  1. User → host. What the user asked for, and what the host actually lets the model do with it.
  2. Host → MCP server. Tool discovery and invocation, over local stdio transports or remote HTTP transports with OAuth-based authorization.
  3. Server → upstream systems. The server usually holds real credentials and real reach: databases, cloud APIs, file systems, third-party SaaS.

The MCP authorization security considerations document several requirements that fall directly out of these boundaries: servers must validate that access tokens were issued specifically for them (token audience binding, via RFC 8707 resource indicators [3]), token pass-through to upstream APIs is explicitly forbidden, and proxy servers holding static client IDs must obtain user consent per dynamically registered client to avoid confused-deputy attacks [2]. Also, each of those is a testable property, not just a design note.

Server flaw or model behaviour?

Before reporting anything, we separate two classes of finding, because they have different owners and different fixes:

  • Server vulnerabilities live in the MCP server itself: missing access checks, weak token validation, path traversal in a resource handler, command injection in a tool implementation, secrets in settings or logs. These are reproducible without any model involvement and are fixed in the server or its deployment.
  • Agent/model behaviour lives in how the host drives the model: the model choosing an inappropriate tool, over-acting on ambiguous instructions, or being steered by malicious content returned from a tool call. These are mitigated by host-side controls (prompts to confirm, scoping, allowlists) and by server-side input handling, but they are not “a bug in the server” in the same sense.

However, a finding that blurs the two (“the model deleted the record”) is not actionable until you can say which boundary failed and what control would have stopped it.

A bounded, authorized testing workflow

However, everything below assumes written permission and a scope agreed with the owner, exactly as for any other penetration test. For hosted third-party MCP services, that means your own tenant and test fixtures, never shared production data.

Phase 1: Scope, transport and identity inventory

Enumerate every configured MCP server, its transport (stdio or Streamable HTTP), its declared capabilities, and the identity model: which user accounts, service principals and OAuth clients are in play, and what scopes/permissions each holds. Therefore, you cannot test access boundaries you have not mapped.

Phase 2: Baseline enumeration

First, connect with a known-good client and record exactly what the server advertises: every tool with its full schema and description, every resource template, every prompt. This advertisement set is both the attack surface and, as we will see, an injection vector, so capture it verbatim and version it, so later changes (a “rug pull” update) are detectable.

Phase 3: Authorization and token checks

Then, using test identities you control confirm the server rejects tokens not issued for it (audience validation), confirms consent flows per client, and enforces per-user access mapping. Run inert controls first: objects and accounts whose access should succeed, then two-principal controls: principal A creates content, principal B attempts to read or act on it. The contrast between “A can, B cannot” is your evidence; a single-principal pass proves nothing about authorization.

Phase 4: Injection surface checks, safely

For example, tool descriptions are fed into the model’s context, so a malicious server can embed instructions in them (tool poisoning), and tool outputs can carry indirect prompt injection back into the model. Test these with inert markers in your own lab: a description containing a distinctive instruction that would produce an observable, harmless effect if followed, and tool output that does the same. In other words, you are testing whether the host’s guardrails hold, not attacking anyone.

Phase 5: Filesystem, network, secrets and agency

Next, review what the server can touch: filesystem paths, outbound network destinations, environment variables and secret stores, and the agency of each tool (read-only vs. destructive). Also, check that secrets are not logged or returned in tool output, and that destructive tools are behind a prompt to confirm. Verify any sandboxing claims with benign probes: a controlled read of a known test file outside an allowed directory is evidence; a crash is not.

Phase 6: Verifying impact, severity and remediation

Finally, for every claimed effect, verify it through an independent source (a second client, the server’s own audit log, or the underlying system of record). Instead, severity follows demonstrable impact in the approved scope, not theoretical worst case. Every finding gets a concrete suggested control.

Common issues, safe tests and controls

Access and token issues

Issue Why it matters Safe, authorized test Suggested control
Missing token audience validation A token issued for one service is accepted by another; stolen or replayed tokens work where they shouldn’t [2] Present a valid token issued for a different test resource you own; the server must reject it Enforce RFC 8707 resource indicators; validate audience on every request
Token pass-through to upstream APIs The upstream API cannot distinguish the real caller; consent is bypassed [2] Inspect how the server calls its upstream (config/logs you are permitted to read); the MCP client’s token must not appear upstream Exchange for a separate upstream token; never forward the client token
Over-broad scopes and no least privilege One compromise grants far more than the task needs Inventory granted vs. actually used scopes during normal operation Minimum scopes per integration; read-only defaults; separate write grants

Agent and injection issues

Issue Why it matters Safe, authorized test Suggested control
No human confirmation for consequential tools The model can delete, send or pay without a checkpoint [1] In a test workspace, drive an inert destructive-labelled action and check for a confirmation prompt Human-in-the-loop check for irreversible or external-effect tools
Tool-description poisoning Hidden instructions in tool metadata steer the agent Lab-only: a test server whose description contains a distinctive benign instruction; check whether the agent acts on it Only connect trusted, reviewed servers; pin and diff tool metadata across updates
Indirect prompt injection via tool output Malicious content in returned data steers the agent Lab-only inert marker strings in tool output; check for observable agent behaviour change Treat tool output as untrusted; host-side guardrails; see our prompt-injection guide

Access, data and logging issues

Issue Why it matters Safe, authorized test Suggested control
Excessive agency A “helper” server ships read/write/execute when you needed read-only Enumerate tools and map each to a business need; probe write/execute paths with inert fixtures Remove or gate consequential tools; per-environment tool sets
Secrets in config, logs or tool output Tokens cached or logged by client or server are directly reusable [2] Review settings files, log sinks and tool responses you are permitted to read for secret-shaped values Secure token storage, redaction, short-lived tokens, refresh-token rotation [2]
No per-user access mapping Every user acts with one shared powerful identity Two-principal test: user B must not reach user A’s objects through the server Per-user access enforced server-side; deny-by-default
Missing or unauditable logs You cannot reconstruct what the agent did Perform a known inert action; confirm it appears, attributed, in logs you can read Structured audit logging of tool invocations with identity and arguments

What good looks like: the control set

Overall, across engagements, the recommendations converge on a consistent set:

  • Least privilege everywhere: scopes, tools, filesystem paths, network egress.
  • Human confirmation for consequential calls: irreversible, external-facing or financial actions never run silently [1].
  • OAuth done properly: audience-bound tokens, no pass-through, per-client consent, short-lived access tokens with refresh rotation [2].
  • Secrets hygiene: no tokens in prompts, tool output or logs; secure storage on both client and server.
  • Per-user identity: the server enforces each caller’s own permissions rather than a shared superuser.
  • Logging and verification: every tool invocation attributable and reviewable after the fact.

One caution worth stating plainly: prompts are not an access control. System-prompt instructions like “never delete files” reduce the chance of an action; they do not enforce it. Enforcement lives in the server and the host, not in the model’s instructions. We cover the model-steering side of this in more depth in our prompt injection guide, and the wider AI testing context in our LLM penetration testing overview.

Practical checklist

Before sign-off, you should be able to answer yes to each of these:

Limitations

This workflow tests what is configured and reachable in your approved environment. However, it does not prove the absence of flaws in the model itself, in the host application’s closed-source internals, or in third-party servers you are not permitted to test. In addition, hosted MCP services change frequently; results are dated, and re-testing after material updates is the norm rather than the exception. Finally, a passing review of settings is not a guarantee against a motivated attacker with valid credentials. Defence-in-depth and monitoring remain essential.

Further reading

  1. Model Context Protocol specification (version 2026-07-28), Server: Tools: tool semantics, the model-controlled invocation model, and the human-in-the-loop requirement.
  2. Model Context Protocol specification (version 2026-07-28), Authorization Security Considerations: token audience binding, the prohibition on token pass-through, confused-deputy mitigations and token-theft controls.
  3. RFC 8707: Resource Indicators for OAuth 2.0: the mechanism behind audience binding.
  4. Fortbridge: LLM penetration testing and Prompt injection attacks: how we test: the surrounding AI security testing practice this guide builds on.

Talk to us

If your organisation is wiring AI agents into real systems and wants an independent, approved assessment of the MCP layer (servers, tools, authorization and all), get in touch with Fortbridge. We test it the way this guide describes: bounded, approved, and evidenced.