Join our Newsletter — 33% off our NHI Course
Home› Guides› MCP Security Testing Guide: Test Servers and Clients…
Guide MCP, Protocols & Agent Platforms

MCP Security Testing Guide: Test Servers and Clients Against the Official Attack List

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 27 October 2026 13 min read
On this page

Most MCP servers and clients reach production without anyone testing the attacks the MCP project itself documents. The specification's Security Best Practices page lists concrete attacks, from token passthrough and confused deputy flaws to SSRF through OAuth discovery and malicious authorisation URLs, and each one translates into a test case with a clear pass or fail. This guide turns that list into a test plan for MCP servers, MCP clients and hosts, and gateways, and explains how to use the official MCP Inspector and conformance suite safely as test harnesses. It reflects MCP specification revision 2026-07-28, checked on 27 October 2026, and is written for AppSec engineers, penetration testers and teams who build or approve MCP integrations. For agent-level testing such as goal hijacking, use it alongside the AI Agent Security Testing Checklist.

Key takeaways

  • Test the documented attacks first. The MCP Security Best Practices page is effectively the protocol's own threat list; every item has a testable MUST or SHOULD.
  • Servers and clients fail differently. Servers fail on audience validation, token passthrough, state handles and Origin checks; clients fail on SSRF, URL scheme handling, consent dialogs and issuer validation.
  • Conformance is not security. The official conformance suite checks protocol behaviour, including an auth suite; it does not look for injection in tool output or excess privilege. Run both kinds of test.
  • The test harness is itself a target. MCP Inspector runs servers and holds OAuth tokens; keep its API token on, bind it to loopback and never set DANGEROUSLY_OMIT_AUTH.
  • Retest on every protocol revision. Revision 2026-07-28 removed sessions, added required headers and changed error codes, so tests written for 2025-11-25 can pass while missing new failure modes.

Scope: what an MCP security test covers

An MCP deployment has three testable components, plus the model behaviour that sits on top.

ComponentTypical ownerMain test themes
Remote MCP server (Streamable HTTP)Product or platform team, or vendorToken audience and passthrough, scope design, state handles, requestState integrity, Origin and header validation, tool input validation, downstream authorisation
Local MCP server (stdio)Developer tooling team, open-source maintainerWhat it can reach on the host, startup command safety, secrets in environment, any local HTTP listener
MCP client or hostIDE, agent platform or in-house app teamSSRF during OAuth discovery, authorisation URL handling, issuer validation, consent dialogs, elicitation URL handling, credential storage
Gateway or proxyPlatform team or vendorFail-closed authentication, per-tool authorisation, credential brokering, logging; the gateway concentrates every credential
Agent behaviourAI or product teamIndirect prompt injection through tool output, tool poisoning, rug pulls; covered in depth by the agent testing checklist

Agree scope and rules of engagement in writing before testing third-party hosted servers; you may need the vendor's permission. See the Red Team Rules of Engagement Template.

Test cases from the official attack list

Each row is drawn from the MCP Security Best Practices (revision 2026-07-28) and the normative specification text it points to. Pass criteria are the specification's own requirements.

AttackTargetWhat to testPass criteria
Token passthroughServerPresent a valid token issued for a different resource or audienceRejected: servers MUST NOT accept tokens not issued for them and MUST validate audience per RFC 8707
Confused deputyProxy server using a static client ID to a third-party APIRegister a new client with a different redirect_uri after a legitimate consent, then replay the authorisation requestPer-client consent shown before third-party redirect; exact string match on redirect_uri; consent cookie uses __Host- prefix and is bound to the client_id; state single use and set only after consent
SSRF via OAuth discoveryClient deployed on a serverMalicious test server returns resource_metadata, authorization_servers or endpoint URLs pointing at private ranges, 169.254.169.254, localhost or a redirect chainRequests blocked; HTTPS enforced except loopback in development; redirects validated per hop
SSRF against the authorisation serverAuthorisation server accepting Client ID Metadata DocumentsSubmit a client_id URL that resolves to an internal addressFetch blocked by IP range checks or an egress proxy
State handle hijackingStateful serverUse a handle minted for user A while authenticated as user B; try predictable handlesRejected; handles random, expiring and bound server-side to the verified user
Tampered requestStateServer using multi round-trip requestsModify, replay or reuse the opaque state on retryIntegrity failure rejected (HMAC or AEAD); replay rejected where single use matters
Malicious authorisation URLClientTest server supplies javascript:, data:, file: or vbscript: authorisation URLs, or URLs containing shell metacharactersOnly https (and http on loopback) accepted; URL never opened through a shell
Mix-up attackClientSecond authorisation server returns a code with a different or missing issClient records issuer before redirect and rejects a mismatched iss (RFC 9207); credentials keyed by issuer
Local server compromiseClient with one-click installInstall link with a long or obfuscated startup commandFull command shown untruncated, flagged as code execution, explicit approval required
DNS rebindingLocal HTTP serverRequests with a foreign Origin headerHTTP 403 for invalid Origin; server bound to localhost
Scope inflationServer and authorisation serverInspect scopes_supported and challenges; request privileged tool with a minimal tokenNo wildcard or omnibus scopes; precise WWW-Authenticate scope challenge; elevation logged

Protocol-level checks added in 2026-07-28

  • Header binding: Streamable HTTP POST requests must carry Mcp-Method and, where applicable, Mcp-Name. Send a body whose method differs from the header: the server should answer HTTP 400 with the HeaderMismatch error (-32020). Gateways that authorise on headers but forward bodies are the risk this closes.
  • Schema handling: implementations must not automatically dereference $ref values that point to network URIs, and should bound schema depth and subschema counts. Feed tool schemas with remote $ref and deep nesting to clients and gateways.
  • No session identity: Mcp-Session-Id is gone. Check that servers upgraded from earlier revisions do not still treat a session-like value as proof of identity.

Using MCP Inspector and the conformance suite safely

MCP Inspector as a test client

The Inspector (v2 ships as the single package @modelcontextprotocol/inspector; v1 receives security fixes only) is the project's interactive client for exercising tools, resources, prompts, OAuth flows and elicitation against a server. Its own documentation sets out the security model you should keep intact when using it on a test bench:

  • API token: every /api/* route is guarded by a bearer token, random per launch unless you set MCP_INSPECTOR_API_TOKEN. DANGEROUSLY_OMIT_AUTH disables it; do not use it.
  • Binding: HOST defaults to 127.0.0.1, and all-interfaces binds are refused unless DANGEROUSLY_BIND_ALL_INTERFACES is set. The Docker image sets that flag, so publish the port as 127.0.0.1:6274:6274, never a bare -p 6274:6274, which exposes the Inspector to your network.
  • Origins and hosts: ALLOWED_ORIGINS and MCP_INSPECTOR_ALLOWED_HOSTS restrict which browser origins and Host headers are served; other hosts get HTTP 403.
  • Secrets: the Inspector persists acquired OAuth tokens by default. Its secret-storage documentation is explicit that the file store does not protect against code running as the same user, including the stdio servers the Inspector launches. On a bench that runs untrusted servers, use MCP_INSPECTOR_SECRET_STORE=memory and test accounts only.
  • Isolation: stdio servers launched by the Inspector receive only a short environment allowlist plus their configured env, but they still run as your user. Run unknown servers in a disposable VM or container with no production credentials.

Conformance suite

The @modelcontextprotocol/conformance framework tests clients (it starts a scenario server and runs your client against it) and servers (it connects as a client). Useful options for security work are --suite auth, --spec-version 2026-07-28 to pin the revision under test, and --expected-failures with a YAML baseline so CI fails only on regressions. Treat a pass as evidence of correct protocol behaviour, then add your own negative tests from the table above.

Choosing test methods

MethodFindsMissesWhen to use
Conformance suite in CIProtocol and auth flow regressionsBusiness logic, injection, privilegeEvery build of a server, client or SDK fork
Manual testing with Inspector and an intercepting proxyAudience, scope, state and header flawsBehaviour at scaleBefore first release and after auth changes
Malicious test server against a clientSSRF, URL handling, consent and elicitation flawsServer-side issuesEvaluating any MCP client or host you deploy
Agent red teamingPrompt injection through tool output, tool poisoning effectsProtocol detailsAgents with write tools or sensitive data; see the AI Red Teaming Guide
Code review and SASTCommand injection, path traversal, secrets in codeRuntime configurationOpen-source servers before approval

Small organisations that mostly consume vendor servers should focus on testing their clients and gateway and on asking vendors for test evidence against the table above. Organisations that publish servers should own the full table and run conformance in CI.

Testing tools and tool output

  • Tool definitions: diff tools/list output across versions and runs; 2026-07-28 asks servers to return tools in deterministic order, which makes unexpected changes easier to spot. Review descriptions for hidden instructions (ATLAS AML.T0110 AI Agent Tool Poisoning).
  • Input validation: fuzz tool arguments against inputSchema; look for command injection, path traversal and SQL injection in the tool implementation, mapped to ASVS input validation requirements.
  • Object-level authorisation: call tools with identifiers belonging to another user (OWASP API1:2023 Broken Object Level Authorization) and test function-level checks on admin tools (API5:2023).
  • Tool output as an attack channel: plant instructions in data the server returns, such as a ticket, error report or document, and confirm the agent does not act on them without approval. The Sentry MCP agentjacking research is a realistic template: a fake error event led coding agents to run a package command.
  • Resource consumption: check rate limits and pagination bounds on list and read operations (API4:2023 Unrestricted Resource Consumption).

Testing gateways and proxies

A gateway sits between many clients and many servers, so a single flaw exposes every connected credential. Test it as both a server (to clients) and a client (to servers).

  • Fail closed: send requests with no token, an empty bearer value, a one-character token, an expired token and a token from another issuer. Every one must be refused before any tool list or call is processed.
  • Policy on the right field: where the gateway authorises by tool name, send a request whose Mcp-Name header names an allowed tool while the body calls a blocked one. The gateway must reject the mismatch or authorise on the body, never on the header alone.
  • Credential brokering: confirm clients never receive the downstream credential, that per-user tokens are not shared across users, and that the gateway does not forward the client's token downstream (passthrough at the gateway is the same flaw as passthrough at a server).
  • Management plane: test the admin API and test endpoints separately from the MCP route; they often have weaker authentication and more power, such as the ability to add servers or run connection tests.
  • Logging: check that every test call appears in gateway logs with client identity, server, tool and decision, and that secrets are redacted.

See the MCP Gateway and MCP Server Governance Guide for the controls these tests verify.

Running an MCP test programme

  1. Inventory and tier: list servers, clients and gateways, and tier them by data access and write capability. Test high tiers first.
  2. Build the bench: isolated VM or container network, test identity provider tenant, test accounts, an intercepting proxy, the Inspector on loopback with memory secret storage, and a malicious test server for client tests.
  3. Baseline with conformance: run the suites for the revision you support and record expected failures.
  4. Run the attack table: one test per row, with evidence (request, response, log line) for each result.
  5. Agent tests: add prompt injection and tool poisoning scenarios for agents with write tools.
  6. Fix and retest: track findings by severity; retest fixes and add each as a regression test in CI.
  7. Repeat on change: retest on every new protocol revision, SDK upgrade, new tool, scope change or gateway policy change. Roll back a release that fails a high-severity test rather than shipping with an exception.

Metrics

  • Share of tier-1 servers and clients tested against the full attack table in the last 12 months.
  • Open high-severity MCP findings and their median age.
  • Conformance suite pass rate at the supported revision, excluding the documented baseline.
  • Number of regression tests added per finding (target: at least one).
  • Time from a new protocol revision to completed retest of tier-1 components.

Framework mapping

ActivityNIST SP 800-53 Rev. 5NIST CSF 2.0Threat references
Penetration testing of servers, clients, gatewaysCA-8 Penetration Testing; CA-2 Control AssessmentsID.RA-01ATT&CK T1190 Exploit Public-Facing Application
Conformance and developer testing in CISA-11 Developer Testing and Evaluation; SA-11(1) Static Code AnalysisPR.PS-06OWASP ASVS 5.0
Token audience and passthrough testsSC-7 Boundary Protection; AC-3 Access EnforcementPR.AA-05ATT&CK T1528 Steal Application Access Token; OWASP API2:2023
SSRF testsSC-7; SI-10 Information Input ValidationID.RA-01OWASP API7:2023 Server Side Request Forgery
Tool poisoning and injection testsSI-10; RA-5 Vulnerability Monitoring and ScanningDE.CM-09ATLAS AML.T0110; AML.T0051.001 Indirect prompt injection; mitigation AML.M0033

Common failure patterns

  • Testing only the happy path. A server that completes the OAuth flow correctly can still accept tokens for another audience. Negative tests matter more than positive ones.
  • Fail-open authentication. The LiteLLM MCP auth bypass (CVE-2026-59822, in CISA KEV since 2 September 2026) fell back to an empty authentication object when token validation failed, so any bearer token, even one character, produced a session. Always test malformed, empty and wrong-audience tokens.
  • Ignoring build and hosting inputs. The Smithery.ai MCP hosting breach came from an unvalidated build path setting, not from the MCP protocol. Include platform configuration in scope.
  • Exposing the test harness. An Inspector published on all interfaces with auth disabled is a remote command runner on the tester's machine.
  • Testing with real credentials. Tokens stored by test clients are readable by the servers under test; use dedicated test tenants.
  • Stale revision. Passing tests against 2025-11-25 says little about header validation or state handling in 2026-07-28 deployments.

Practitioner checklist

  • Map every MCP server, client and gateway to a test tier and owner.
  • Run each row of the official attack table and keep evidence per test.
  • Run the conformance suite with --spec-version pinned and an expected-failures baseline in CI.
  • Keep the Inspector on loopback with its API token on, and use memory secret storage on benches that run untrusted servers.
  • Test negative token cases: wrong audience, empty, malformed, expired, other issuer.
  • Test clients with a malicious server for SSRF, URL schemes, mix-up and consent dialogs.
  • Add prompt injection through tool output and tool definition diffing for agents with write tools.
  • Retest on every protocol revision, SDK upgrade and scope change.

Standards and references

Related NHI Mgmt Group resources: AI Agent Security Testing Checklist · MCP Security Guide · Remote MCP Server Hardening Guide · MCP Authorisation Specification Guide · MCP Incident Response Playbook

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 27 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.