Security testing MCP servers with promptfoo

Plan promptfoo tests for Model Context Protocol servers and the agents that call them, covering trusted-client testing, tool poisoning across servers, direct MCP checks and CI.

On this page

Security testing MCP servers with promptfoo: when your agents trust tools they should not

Add promptfoo to your MCP testing when agents call tools from servers you did not write, when a server can act with credentials it received from a client, or when a local server runs on developer machines. promptfoo can run red team probes against an agent that uses MCP tools, so you can see whether the agent follows instructions hidden in tool descriptions or tool output and whether it calls tools beyond the user's role. It does not review the MCP servers' code, their OAuth setup or their host configuration, so treat its results as one part of the evidence you collect.

The MCP security best practices name the risks that matter most here. In a confused deputy attack, a proxy server forwards requests using its own privileges, so a user who cannot reach a resource can still reach it through the proxy. Token passthrough is the pattern the MCP authorization specification forbids: a server that accepts tokens not issued for it can be used to reach downstream services under someone else's identity. Local MCP server compromise covers servers started on a workstation, where the MCP guidance expects clients to show the exact command before a one-click install and to run servers with minimal default privileges. Map these to the OWASP Top 10 for Agentic Applications for 2026: ASI02 Tool Misuse covers agents using tools in unintended or unsafe ways, and ASI04 Agentic Supply Chain Vulnerabilities covers the risk from third-party servers, packages and tool definitions you load at runtime.

Treat promptfoo as one tool in a test set. Pair it with a code review of each server you run, a check of the token audience and scopes each server accepts, and a review of which client approvals and sandboxing are enforced on developer machines. Confirm with your MCP client and server vendors which controls they provide, because the protocol guidance describes expected behavior rather than guaranteeing it in your deployment.

Which MCP test approach fits which setup

This table compares trusted-client testing, direct MCP testing and multi-server tool poisoning tests by what each exercises, what the team must supply and when each fits. Read the last row first if you are unsure whether your agent must be wrapped as a promptfoo target, because that decision affects the effort for every other approach.

ApproachWhat it exercisesWhat the team must supplyWhen it fits
Trusted-client testingWhether the MCP client (the agent host) passes tokens, approvals and tool results safely to each server it connects toTest user identities, a wrapped agent endpoint or provider, and the server list the client is configured withAgents already in use, where the question is how the client behaves with servers it trusts
Direct MCP testingWhether a single MCP server enforces authorization, validates scopes and rejects tokens not issued to itServer endpoint access, test tokens for each role, and a list of tools with their parametersServers you run or procure, tested before any agent is allowed to connect to them
Multi-server tool poisoning testsWhether instructions hidden in one server's tool descriptions or outputs steer the agent into calling tools on another serverAt least two connected servers, a wrapped agent endpoint, and control of one server's tool metadata or responsesOrganizations that connect several third-party or internal servers to one agent and need to test cross-server influence
Wrapped agent as promptfoo targetNeeded for trusted-client and multi-server tests so promptfoo can send prompts and read tool callsA small provider that calls your agent and returns its output and tool traceRequired for both agent-level approaches; direct MCP testing can run without it
Setup effort driverNumber of servers, roles and tools in scope, which sets how many identities and fixtures you prepareInventory of servers, roles, and the tools each role may callKeep scope to the servers that hold sensitive data or write actions in the first pass
Evidence to retainTool call traces, the exact tool descriptions tested, and pass or fail results per attackStored run output and the MCP server versions testedConfirm with your assessor which artifacts they expect before the run starts

How to set up an MCP red team in promptfoo

This sequence takes a team from an inventory of MCP servers and tools to a repeatable promptfoo scan, with test identities, targeted plugins and a stored evidence trail. Each step ends with a check so the results can be trusted before anyone reads them.

  1. Inventory MCP servers and tools in scope

    Before any test runs, list every MCP server the agent can reach, whether it runs locally or remotely, and every tool each server exposes. Record which tools read data, which write or send data, and which act with someone else's credentials. Assign an owner for each server and note its authentication method. Done means the team has a written list that the security owner and the agent owner have both reviewed, and any tool with write or admin rights is flagged for extra scrutiny.

  2. Install the promptfoo CLI

    Install promptfoo from npm on a workstation or CI runner that meets its requirement of Node.js 22.22.0 or newer, as stated in the npm release for version 0.124.1 published on 8 October 2026. Confirm the installed version against the current release before you record results, because later runs should be reproducible. Check that the CLI starts and prints its version. Keep the project under version control so the configuration can be reviewed like other test code.

  3. Define the target agent as a provider

    Create a promptfoo configuration that points at the agent under test, not at the raw model, so the scan exercises the tool calls, MCP connections and system prompt your users will hit. Depending on how the agent is built, this is an HTTP endpoint, a WebSocket or a Python provider. Confirm the target returns the final answer and, where possible, the tool calls it made. Check that a single benign prompt returns a sensible response through the provider before any red team plugin is added.

  4. Create least-privilege test identities

    Create at least two test identities in the systems behind each MCP server: one with the access the agent should have for a normal user, and one with narrower rights. Use dedicated test accounts with synthetic records, not production users. Configure the provider so each test run authenticates as a specific identity. Verify by logging in as each identity outside promptfoo and confirming that the tool and data access matches the intended role, so any later failure is clearly the agent's fault.

  5. Confirm the agent lists only expected tools

    Run a discovery test that asks the agent what tools it can use and compare the answer with the inventory from the first step. Also confirm that the MCP client exposes only the tools the agent should see for that identity. Any tool that appears in the agent's answer but not in the inventory, or any tool visible to the narrower identity, is a finding to resolve before the red team runs. Record the list and the comparison as the first evidence item.

  6. Add MCP-focused plugins and strategies

    Select red team plugins for authorization, tool misuse and injection that arrive through tool output or documents, and choose strategies that deliver those payloads through the MCP path. Map each plugin to an entry in the OWASP Top 10 for Agentic Applications 2026, such as ASI02 Tool Misuse and ASI03 Identity and Privilege Abuse, so results line up with your risk register. Check the generated configuration by reviewing a sample of the planned test cases before running the full scan.

  7. Run the scan and review failures

    Run the red team scan with the configured identities and plugins. Review each failed case by opening the trace and confirming which tool was called, with what arguments, and under which identity. Separate true failures from grading errors by checking the transcript yourself on a sample. Done means every failure has a trace reference, a severity assigned by the owner and a remediation ticket, and the grader's false positives are documented so future runs are not misread.

  8. Record evidence and repeat the scan

    Save the configuration, the promptfoo version, the list of identities and tools, the scan output and the traces together under a fixed run identifier. Store the results where the audit and security teams can find them. After remediation, rerun the same scan and confirm that the fixed cases now pass and nothing new has regressed. Keep the evidence trail current whenever an MCP server, tool or identity changes, because the scan only covers the setup it was run against.

Where the trust boundaries sit in an MCP test

The diagram starts at promptfoo, which drives the test against the agent under test. The agent is the client that connects to several MCP servers, and each server exposes tools whose descriptions and results come from outside your control. The authorization server issues tokens, and the important check is whether each MCP server accepts only tokens issued for that server, with no token passthrough from the client. Mark the boundary around untrusted documents and tool descriptions, since poisoned text there is where cross-server tool poisoning starts.

Trust boundaries between the test runner, agent, MCP servers, authorization server and untrusted content.

Security risks the MCP test setup must control

A promptfoo red team against MCP servers touches live credentials, sends test content to a model provider, and writes results that hold prompts and outputs. These risks belong to the test setup, not the system under test, and they need controls before the first scan runs. The cards below cover the areas to plan for.

Real credentials in configs

MCP test configs often need tokens to reach a server, and it is easy to paste a production token into a YAML file or environment variable. Keep test configs free of production secrets, issue tokens scoped to test identities, and load them from your secrets store at run time. Check that CI logs and saved configs never echo the token values, and rotate any credential that a config file or shared workspace has exposed.

Test data sent to hosted models

promptfoo runs on your machine but talks directly to the LLM provider you configure, so every test prompt, tool result and document fragment goes to that provider. Before testing an agent that reads customer records or internal documents, confirm which provider endpoint receives the traffic, whether your agreement covers that data, and whether a self-hosted model can serve the same tests. Use synthetic records wherever the test does not need real ones.

promptfoo introduction

Destructive tools on test accounts

Some MCP tools delete files, send messages, change tickets or move money, and a red team will call them on purpose. Point these servers at sandboxed test accounts with throwaway data and minimal permissions, never at production systems. Confirm that the test identity cannot reach live resources, and reset the sandbox after each run so one attack leaves no state that affects the next.

Results files holding prompts and outputs

Eval and red team results record the prompts sent, the tool calls made and the model outputs, which can include injected instructions, sensitive fragments or credentials that leaked during a test. Decide where result files are written, who can read them, how long they are kept and how they are deleted. Apply the same access rules to exported reports and CI artifacts as you do to the data they contain.

Shared workspaces and access

A self-hosted promptfoo server stores data in a local SQLite database and has no RBAC, built-in authentication or SSO, so anyone who can reach it can see every run. Keep it on a restricted network, put it behind your own access layer, or use the Enterprise edition if team access control is required. Confirm this in writing before results from production-like systems are stored on a shared server.

Self-hosting docs

Questions teams ask before testing MCP servers

What drives the cost of testing MCP servers?

The main drivers are the number of MCP servers, the number of tools each one exposes, the number of identities (user roles, service accounts and test tenants) you need to test with, and the number of environments in scope. Each combination multiplies the test cases, so a single read-only server tested with one identity is a much smaller job than several servers acting on behalf of several roles across staging and production-like environments. Cost splits into the testing work itself, setup of test accounts and endpoints, and any fixes and retests. Ask any quote to list each server, tool group, identity and environment separately so you can see what changes the price if scope moves.

How long does an MCP server security test take?

Duration depends on the same factors as cost: how many servers, tools, identities and environments are included, how quickly test accounts and endpoints are made available, and how many findings need remediation and retesting. No duration is fixed in advance, so ask for a timeline in the written scope, with separate milestones for access setup, testing, the findings report and the retest. Delays most often come from waiting on credentials or access to the agent under test rather than from the testing itself.

What do you need from our team to start?

Plan to provide the MCP endpoints in scope and their documentation, the transport each one uses, and the client applications or agents that call them. You will also need test accounts for each role you want to check, with clearly defined permissions, and a way to run the agent or client under test in a non-production environment. If you plan to run checks in CI, you will need a pipeline runner that can reach those endpoints and a place to store API keys securely. Confirm all of these items, and who approves them, before the scope is signed.

Can our internal team run MCP security testing without a partner?

Yes, if your team has engineers who can install and configure promptfoo, write test configurations, and read the results. The Community edition is free under the MIT license and includes red teaming with 10k probes per month, and promptfoo runs locally and talks directly with the model, so no data needs to go to a vendor-hosted service for the test runs themselves. The harder parts are designing authorization tests that use realistic identities, interpreting findings on tool poisoning across servers, and deciding what to fix. Confirm your Node.js version meets the requirement of Node.js 22.22.0 or newer before you begin.

How do CI runs differ from a one-off security assessment?

A one-off assessment is a scoped engagement that tests the current servers, tools and identities in depth, then produces a findings report and a retest. A CI run repeats a defined set of checks on every change, such as a new tool, a changed permission or an updated server version, and fails the pipeline when a check fails. CI needs stable test accounts, secrets stored in the pipeline, controlled test data, and an agreed pass threshold, and it covers regressions rather than new attack ideas. Most teams use both: an assessment to establish a baseline and find gaps, then CI checks to keep those gaps from returning.

How much of the work recurs after the first test?

The first pass carries the setup cost: mapping servers and tools, creating identities, writing configurations and agreeing pass criteria. After that, recurring work includes running checks on changes, reviewing new findings, updating test cases when tools are added, and maintaining the pipeline. The Enterprise edition adds continuous monitoring and remediation recommendations, with pricing set by quote, so ask whether you need that or whether a scheduled CI job is enough. For ongoing coverage, DeployOpen offers retainers for continuous testing and updates, and the scope of any retainer should be written down before work starts.

Does passing these tests mean our MCP setup is compliant?

No. Passing red team checks shows that specific tests did not succeed against your setup, which can serve as evidence for a compliance assessment, but it does not certify compliance. Independent auditors and certification bodies issue audit reports and certifications, and DeployOpen prepares systems, controls and evidence for those assessments without issuing them. Ask which MCP and agentic risks the test covers, such as the OWASP Top 10 for Agentic Applications entries for tool misuse and identity and privilege abuse, and which remain outside the scope.

How tool poisoning across multiple servers is tested

Tool poisoning across servers is tested by placing a malicious instruction where the agent will read it as trusted context, then checking whether the agent uses a tool on a different server because of it. The risk is that a tool description or tool output from one MCP server, which the client treats as ordinary metadata, tells the agent to call a second server's tool with attacker-chosen arguments, such as sending a file, reading a record or posting data to an outside address. The test has to model that path, because a prompt sent directly to the agent through the chat box shows only what the model does with user input, not what it does with text that arrives through a tool. The OWASP Top 10 for Agentic Applications for 2026 covers this family of failures under ASI02 Tool Misuse and ASI04 Agentic Supply Chain Vulnerabilities, and the MCP security guidance treats the client's handling of tool metadata as part of the trust boundary.

Design the test around three decisions. First, decide which server is the attacker-controlled one, and make it a test fixture you own, with a tool description or tool result that carries the payload. Second, decide where the payload sits: in the description the client loads at connection time, in the output of a call the user asked for, or in a document the agent retrieves through a second server. Each position is a different realistic path, and a single position does not cover the others. Third, decide what a pass looks like. A pass is not only a refusal in the final answer; it is the absence of a cross-server call with the injected arguments in the trace. Record the tool calls with their server names and arguments, and confirm in your environment that the promptfoo setup you use captures that information, because the documentation you should check governs which trace data is available for each target type.

Confirm the points below before you build the suite, since the plugin behavior is documented only at the level of the red teaming docs in the promptfoo red teaming documentation. Confirm whether a built-in plugin injects content into tool descriptions or only into user messages. Confirm how the target reports tool calls and which server each call went to. Confirm whether your client shows the full tool description to the user before approval, since the MCP guidance expects an explicit approval step for local servers. Where a built-in plugin does not cover a path, write a custom test that places the payload yourself and grade the trace against the cross-server call you are trying to prevent.

Common MCP findings and the fixes they point to

Most MCP findings trace back to a small set of trust decisions: which tokens a server accepts, how much access a grant carries, what a client will run and how sessions are bound. Each card below pairs a finding with the MCP guidance it breaks and the change teams usually make, so the test results lead directly to a fix.

Token passthrough

An MCP server accepts a token that was not issued for it. The client forwards whatever access token it holds, and the server relays it to a downstream API. The MCP authorization specification forbids this: a server must not accept tokens that were not explicitly issued for that server. In testing, supply a token minted for another audience and confirm the server rejects it. The usual fix is audience validation on every inbound token, with a separate token exchange when the server must call a downstream service.

MCP security best practices

Over-broad scopes

Tokens grant more tools and data than the task needs. Scopes are often requested once as a broad bundle during setup and reused for every tool call. The MCP guidance on scope minimization points toward requesting narrow scopes and stepping up only when a sensitive tool is called. Test by calling each tool with a low-privilege identity and listing what succeeds. The usual change is splitting scopes by tool group and removing wildcard grants from the default consent screen.

Unapproved local server commands

A one-click install runs a command the user never saw. For local MCP servers, the guidance requires clients offering one-click configuration to show the exact command and require explicit user approval, and to run servers sandboxed with minimal default privileges. Test whether a crafted server entry or a poisoned configuration file starts a process without a visible prompt. The usual fix is a confirmation step that displays the full command and arguments, plus restricted filesystem and network access for the server process.

SSRF through server URLs

A server fetches URLs that the agent or user supplies. Tools that accept a URL, such as a webpage reader or an OAuth metadata lookup, can be steered toward internal addresses, cloud metadata endpoints or local services. The MCP guidance lists server-side request forgery as a named risk. Test with internal and link-local addresses, redirects and DNS names that resolve to private ranges. The usual fix is an outbound allowlist, blocking private address ranges after resolution, and validating authorization URLs before the server follows them.

Session hijacking

A session identifier alone is enough to act as another user. When a server trusts a session ID without binding it to the authenticated identity, a leaked or guessed ID lets another client continue the session. The MCP guidance covers session hijacking as a distinct risk. Test by reusing a session ID from one identity under another token and by checking whether IDs are unpredictable. The usual change is binding each session to the authenticated subject, rotating IDs and rejecting requests where the two no longer match.

How DeployOpen scopes and delivers MCP security testing

DeployOpen plans and runs MCP security testing as a fixed-scope engagement, with scope, deliverables and timelines agreed in writing before work starts. The work covers promptfoo setup, the test cases for trusted clients, multi-server tool poisoning and direct MCP testing, and the CI checks that keep them running.

How we scope

  • We confirm which MCP servers, clients and agents are in the written scope and who owns each one
  • We agree the trust boundaries to test, such as which tokens, scopes and local servers are in play
  • We list the test identities, environments and data the testing may touch before any run starts
  • Ongoing support and continuous testing are available as a retainer after the fixed-scope work

How we build

  • We configure promptfoo in a self-hosted or CLI setup that runs inside infrastructure you control
  • We write tests for trusted-client behavior, cross-server tool poisoning and direct MCP calls
  • We map findings to OWASP agentic and LLM categories so each test has a stated security purpose
  • We wire the checks into your CI pipeline with reports that your security team can review

How we hand over

  • You receive the promptfoo configuration, test cases and CI job definitions as versioned files
  • You receive a findings report with reproduction steps, affected components and suggested fixes
  • We retest fixed findings and document the results so the evidence trail is complete
  • We walk your engineers through running, extending and reading the suite before handover closes

How we support

  • Support covers upgrades to promptfoo and changes to your MCP servers and client configurations
  • Retainers can include scheduled re-runs of the suite and review of new findings
  • Your team keeps ownership of the repository, pipeline and test identities after handover
  • Ask each vendor, including DeployOpen, to confirm response times and support terms in the written quote

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.