Polyaxon v3 is coming →

MCP security testing: tools, permissions, and untrusted content

Build MCP security tests for tool discovery, authorization, injected tool results, session identity, and approval boundaries in AI agents.

August 6, 2026by Polyaxon
MCP — Model Context Protocol — security testing, with the MCP symbol and connected geometric nodes on a navy background.

MCP security testing checks the boundaries between an AI application, an MCP server, and the systems behind its tools. Successful tool discovery or a valid protocol response does not establish that an action was authorized for the current user.

Test the client and server together, then verify the downstream service's state. MCP observability helps reconstruct a sequence; security tests define which sequences should be allowed and which must be rejected.

Inventory the actual trust boundaries

For each server, record its transport, operator, exposed tools, required credentials, downstream systems, and update process. Identify which tool results contain third-party text and which actions modify data.

The MCP tools specification describes tool metadata and annotations. Treat an annotation about a tool's behavior as a claim whose trust depends on its source, not as a permission grant. A tool labeled read-only still needs implementation and authorization checks.

Distinguish remote HTTP authorization from local process access. A local server launched over standard input and output inherits a different set of risks, including its process credentials, filesystem access, and environment. Test the deployment you actually use rather than assuming every server has the same identity model.

Build a matrix for each tool

Use a synthetic order service with a read tool and a refund tool. Keep its action ledger outside the agent's control.

TestControlled conditionExpected evidence
Unauthorized objectTenant A requests a B order IDServer rejects access; no private result is returned
Missing write permissionA reader calls the refund tool directlyNo refund is recorded
Misleading descriptionTest server metadata claims that a write needs no approvalApplication approval policy still applies
Injected resultAn order description tells the agent to call a write toolContent does not become approval; actual calls are recorded
Session mix-upTwo test identities use separate sessionsResults and permissions remain associated with the correct actor
Changed tool schemaA known tool gains a new destination argumentChanged behavior is reviewed and constrained before use
Timeout after acceptanceTest service records a write, then times outRetry policy avoids duplicate writes

Pair these with valid read and approved-write cases. A server that refuses everything is not a functioning implementation.

Test authorization independently of prompting

Call the server directly with permitted and restricted test identities. This verifies the authorization boundary even if the model proposes an invalid call. Then run the full agent to see whether malicious content can influence its choice of tools or arguments.

For HTTP deployments using MCP authorization, test missing, expired, and wrong-audience tokens in the authorized test environment. Preserve rejection status and request identifiers without storing token values in reports. The MCP security best practices address token passthrough, confused-deputy behavior, and session risks. In particular, a downstream service token should not be accepted as though it were issued to the MCP server.

An approval should bind to the intended action and relevant arguments. In the test service, approve a refund for A-42, then change the proposed order or amount. The changed action should require a new valid approval according to the application's policy. A general “user approved” string in the conversation is insufficient evidence.

Observe content at the client boundary

Capture tool descriptions and results as the client received them. A test payload in a source document is irrelevant if a server parser removed it before returning the result. Conversely, rendered text and structured output can carry different content; inspect both when the client uses both.

Record the tool name with its server identity. Similar names on different servers must not become interchangeable in logs or routing. When testing a schema update, compare the discovery result and the actual arguments sent after the update.

Avoid including credentials or real private records in shared traces. Synthetic identifiers are usually enough to establish whether a tenant or approval boundary was crossed.

Repeat the tests when the integration changes

Rerun the matrix when server code, tool schemas, client routing, authentication, or model prompts change. Preserve the server and client revisions, initial fixture state, calls, results, and action ledger in Polyaxon run artifacts.

Use pipelines to execute the server-level tests and the end-to-end agent suite as separate steps. This is a workflow you assemble around your MCP implementation; recording results in Polyaxon does not add an authorization layer to that implementation.

Continue with agent red teaming and continuous testing, or explore the agents learning path.