How to run promptfoo mcp for AI coding tools safely
A team that wants Cursor or Claude Desktop to run promptfoo evals and red team scans from inside the editor can do so with the promptfoo mcp command, but the safe setup is a set of limits decided before any agent starts a run. The command starts a Model Context Protocol server that exposes promptfoo tools to AI agents and development environments such as Cursor and Claude Desktop, according to the promptfoo MCP server docs. Before rollout, the team should confirm which tools the server exposes in its installed version, because an agent can only call what the server makes available to it.
Install method matters. Slim installs of promptfoo need the optional @modelcontextprotocol/sdk package before the MCP server will start, so the platform team should add it deliberately rather than assume it is present. Record the exact promptfoo version and the SDK version in the engineering baseline, since both determine the tool surface. The same docs describe how each client is pointed at the server, and the client configuration is where an administrator decides which server entries developers can add themselves.
The main risk is that an agent launches expensive or sensitive runs without a person reviewing them. Decide in advance which provider keys the MCP server can read, which target applications it can reach, and whether red team scans may run from a laptop at all. Also confirm how many probes and model calls a single agent request can trigger, and who pays for them. Test these limits on a non-production target first, and keep the eval configs the agent is allowed to run in version control so changes to them go through review.
What you need before connecting an MCP client
Connecting an AI coding tool to promptfoo takes four pieces: a supported Node.js runtime, a working promptfoo install, the MCP client configuration, and provider credentials for the eval runs. Work through them in this order so a failed connection is easy to trace to one layer.
Node.js runtime version
The current npm release of promptfoo requires Node.js 22.22.0 or newer. Check the version on the machine that will run the server, not only on your laptop, because a CI runner or shared development host may ship an older runtime. Confirm the version with node --version before you install anything, and pin it in your team's setup notes so every developer runs the same server behavior.
promptfoo installation
Install promptfoo globally or in the project that owns your eval configs, so the promptfoo mcp command resolves to the same version your team tests against. Record the installed version in your setup notes. An MCP client that launches a different promptfoo build than your CI pipeline can produce results that do not match. Upgrades should be planned and tested like any other tooling change.
Optional MCP SDK package
Full installs bundle what the MCP server needs. A slim install does not, and the server needs the optional @modelcontextprotocol/sdk package added before promptfoo mcp will start. If the server fails at launch with a missing module error, this is the first thing to check. Add the package to the same environment that the MCP client launches, and note it in your dependency review because it is a separate component your security team may want to track.
MCP client configuration location
Each client keeps its MCP server definitions in its own configuration file, and the entry points to the command that starts promptfoo. Confirm where Cursor, Claude Desktop or your other client reads that file on each operating system, and keep the entry under version control or a managed profile where possible. Set the working directory to the project holding your configs so the agent reads the right files.
Provider credentials for eval runs
Eval and red team runs call the model provider configured in your promptfoo config, so the provider API keys must be present in the environment where the server process starts. Use a dedicated key with a spending limit and a scope limited to the test workloads, not a personal or production key. Confirm how your MCP client passes environment variables to the server, since a key set only in your shell may not reach a process the client launches.
Network access to providers
promptfoo runs on the machine where the server starts and sends requests directly to the LLM providers, so that machine needs outbound network access to each endpoint your configs reference. Behind a corporate proxy or egress firewall, test connectivity from the server host before debugging the agent. Also confirm which data leaves the network, because prompts and responses from test cases travel to those providers.
promptfoo introductionConfiguring the promptfoo mcp server in your client
This sequence installs promptfoo, starts its MCP server, connects it to Cursor or Claude Desktop, limits what the server can reach, and confirms read and run access in order. The result is an MCP connection that agents can use only after each check has passed.
Confirm Node.js and install promptfoo
The engineer who prepares the workstation checks that Node.js 22.22.0 or newer is installed, the minimum version for npm release 0.124.1, then installs promptfoo into the project the agent will work in. Run
promptfoo --versionand confirm the reported version matches the release your security team approved. The step is done when the command returns a version number with no runtime errors.Add the MCP SDK for slim installs
If your install is slim, add the optional
@modelcontextprotocol/sdkpackage to the same project, because thepromptfoo mcpcommand depends on it. Ask your platform team whether your standard install already includes it, and record the answer in the change ticket. The step is done whenpromptfoo mcpstarts in the next step without a missing-module error.Start the promptfoo mcp server
From the project root you intend to expose, run
promptfoo mcp. This starts a Model Context Protocol server that exposes promptfoo tools to AI agents and development environments such as Cursor and Claude Desktop. Confirm in the command line docs whether your client launches the command itself or whether you run it as a standing process, because that decides where the process and its logs live. The step is done when the server starts, reports no errors, and waits for a client connection.Register the server in Cursor or Claude Desktop
In each client, open its MCP settings and add promptfoo as a server entry that points to the
promptfoo mcpcommand. Use the key names shown in the client's current MCP documentation and in the promptfoo MCP server docs, since client settings change between releases and this page does not reproduce them. Register the server only for developers on the approved list. The step is done when the client shows promptfoo as connected and lists its tools.Limit the directories and config files in reach
Point the server at a dedicated project directory that holds only the eval configs, test data and scripts the team has reviewed. Keep provider API keys out of config files and load them from environment variables or your secrets store. Confirm whether the server restricts file paths itself. If it does not, rely on operating system account permissions and directory ownership. The step is done when a test file placed outside the approved directory cannot be read through the client.
Run a read-only test call first
Before any run is allowed, ask the client to call a read-only promptfoo tool, such as one that lists or reads configuration. Confirm the exact tool name in the MCP server documentation first. Check that the response matches the file on disk and that no evaluation or red team job starts. Watch your model provider's usage page during the test. The step is done when the read returns the expected content and the provider shows no new requests.
Enable eval and red team runs with limits
Only after the read test passes, allow runs on a small, reviewed config against a non-production target. Set spend limits with each model provider and cap the number of probes. Confirm the probe allowance for your edition, because the promptfoo pricing page lists 10k red teaming probes per month in the free Community edition. Agents should not change configs or targets without review. The step is done when a small run completes, its results appear in the client, and spend matches the expected limit.
How an agent request reaches promptfoo and the model under test
The request starts in the MCP client inside the editor or desktop app, which calls tools exposed by the promptfoo mcp process running on the developer machine. That process reads the local config and writes results to local files, then sends model calls over the network to the provider or application under test. Check three boundaries: what tools the agent is allowed to call, which files the process can read and write, and which network destinations the run can reach.
Data and control flow from the agent to promptfoo and the external model under test.
Limits to set before an agent can start runs
An MCP client acts on whatever configuration files and target endpoints the server can reach, so the first limit is an allowlist of what an agent may run. Decide which eval and red team configs are approved, which application or model endpoints each config may call, and whether an agent can create new configs at all or only run existing ones. Keep the approved configs in a version-controlled repository that the agent's working directory points to, and keep production endpoints out of any config an agent can read. Confirm in the MCP server documentation and the command line reference exactly which arguments and config paths the promptfoo mcp command accepts, and test whether a tool call can reference a file outside the approved directory.
- Approved config directory: Store eval and red team configs in one repository path and confirm the server cannot resolve paths outside it.
- Target endpoints: List the staging or test endpoints each config may hit, and keep production URLs out of agent-visible files.
- No config authoring: Decide whether agents may write new configs or only run reviewed ones.
- Read-only checkout: Where possible, mount the config directory read-only for the agent's session.
- Path traversal test: Ask an agent to reference a config outside the approved path and record the result.
Before approving the setup, check that a config outside the allowlist cannot be run, and that the target list shown to the agent matches the one your security team signed off.",
Provider API keys determine what an agent can spend and which data it can send to a model vendor. Decide which keys the server process can read, and keep them out of the agent's view. A developer machine often holds personal keys with broad quotas, so the first question is whether those keys should be available to the MCP server at all. On shared workstations, separate keys per project with narrow spending limits reduce exposure if an agent misuses one. Confirm with the promptfoo introduction and provider documentation which environment variables the CLI reads and whether the server echoes them in tool output.
- Dedicated test keys: Issue keys used only for evals and red teams, with provider-side spending caps set by the account owner.
- Environment scoping: Pass only the variables a given config needs, rather than exporting the full developer environment to the server.
- No key in config files: Reference keys through environment variables so the agent never reads a literal key from a file.
- Output review: Confirm that tool responses and logs do not print key values or full request headers.
- Rotation owner: Name who rotates keys after a suspected leak and how quickly they can do it.
Check that an agent asked to print its environment cannot retrieve a provider key, and that revoking one key stops runs without breaking the others.",
Red team scans generate many probes, and each probe is a paid model call against the target and often against a judge model. An agent that is asked to test a feature may choose a broad plugin set or a large probe count without understanding the cost. Decide the maximum scan size per run, the plugins and strategies an agent may select, and the number of runs allowed in a period. The Community edition includes red teaming with 10k probes per month according to the promptfoo pricing page, so an agent running scans on a shared key can exhaust that allowance quickly. Confirm whether the MCP tools accept probe or concurrency arguments and whether those arguments can be fixed in the config so the agent cannot raise them.
- Fixed probe counts: Set the number of probes in the reviewed config and do not expose an override to the agent.
- Plugin allowlist: Name the plugins and strategies an agent may run, and exclude expensive or broad sets by default.
- Concurrency cap: Limit parallel requests to the target so a scan does not overwhelm a test environment.
- Run quota: Agree how many scans a developer or agent may start per day, and log each one.
- Monthly allowance check: Compare planned scan volume with the probe allowance on the account.
Check that a request to run a larger scan than approved is refused or fails before any model call is made.",
Some runs should wait for a person to approve them before any provider budget is spent. Approval gates are a process decision that you design around the server, so confirm first what the MCP client and server support. A common pattern is to have the agent prepare a run, show the config, target, plugin set and estimated probe count, and wait for a developer to confirm in the client. Another is to restrict agents to dry runs or to read-only tools, and let CI or a named engineer start paid runs. Do not assume the server pauses for approval unless the documentation or your own test shows it.
- Two-step runs: Require the agent to propose a run and a person to confirm it before the spend step.
- Dry runs first: Allow agents to validate configs without calling paid providers, if the tool supports this.
- Spend-bearing configs: Mark configs that call paid models or run red teams as approval-required in your repository rules.
- Audit trail: Record who approved each run, the config hash and the time, in a place the security team can query.
- Escalation path: Name who may approve runs when the usual approver is unavailable.
Before rollout, run a test in which an agent attempts a paid run without approval and confirm the run does not start.
Which MCP client settings map to promptfoo permissions
This table maps each setting you control in an MCP client, such as the server command, arguments, environment variables, working directory and allowed tools, to the promptfoo concept it shapes. Read the right-hand column as the check to run in your own environment, since the public docs confirm some of these links and leave others for you to verify.
| Client setting | promptfoo concept it affects | What to confirm before agents start runs |
|---|---|---|
| Server command (promptfoo mcp) | Starts the MCP server that exposes promptfoo tools to the client | Confirm the installed promptfoo version exposes the mcp command on the host the client runs on |
| Arguments passed to the command | Which promptfoo tools and behavior the server offers to the agent | Check the MCP server docs for supported arguments and test each one before granting it |
| Optional @modelcontextprotocol/sdk package | Required for slim installs before the mcp command works | Confirm the package is present in slim installs; the docs flag it as optional, so do not assume it is bundled |
| Environment variables (provider API keys) | Provider keys used by evals and red team runs the agent starts | Confirm which keys the server reads from its environment and scope them to a test account with spend limits |
| Working directory | Location of the promptfoo config file the server loads for runs | Confirm which config path the server resolves from its working directory and keep it outside production source trees |
| Results location | Where eval and red team output is written | Verify the output path the server uses, and whether results can reach shared storage or a self-hosted instance |
| Test target (app or endpoint under test) | The application or model the runs call, set through the config and provider definitions | Confirm agents cannot retarget a run to a production endpoint; pin the target in the config file |
| Allowed tools in the client | Which promptfoo MCP tools an agent can call from the client | Restrict tools to the minimum needed for the task and test that blocked tools fail closed |
Hardening the MCP server on developer machines
An MCP server gives an AI coding agent a set of tools that run on a developer's laptop, with that developer's file access and credentials. The cards below cover the risks that matter most on that machine and the checks to make before an agent starts a run. Confirm each setting against the current promptfoo MCP documentation for your version before you rely on it.
Prompt injection through repository content
A coding agent reads README files, issue text, comments and dependency code, and any of it can contain instructions that steer the agent toward running a different eval or red team target. Treat repository content as untrusted input when an agent is allowed to call promptfoo tools. Review which config files the agent can edit, and require a human to approve any run that targets a new endpoint.
promptfoo MCP docsOver-broad file access
Eval configs reference prompt files, datasets and provider scripts, so an agent with broad filesystem access can read SSH keys, cloud credentials or unrelated client data along with the files it needs. Limit the agent's working directory to the project under test and keep secrets outside that tree. Confirm what paths the MCP server and the client each expose.
API keys in client config files
Clients such as Cursor and Claude Desktop store MCP server definitions in JSON files, and it is common to paste model provider keys into the env block there. Those files are often readable by other local tools and may be synced or shared. Load keys from a secrets manager or a shell profile with restricted permissions, and check the client config for keys before committing dotfiles.
Untrusted MCP servers beside promptfoo
Every MCP server the client loads runs with the same trust as the agent that calls it, so a malicious or careless server can read tool results from promptfoo or call other tools. Install only servers your security team has reviewed, pin their versions, and remove any server that is not in use. Review the full list of servers in each client before starting a red team run.
Unreviewed red team targets
A red team run sends adversarial prompts to whatever target the config names, which could be a staging app, a production endpoint or a third-party API with real costs. An agent that edits the target URL can redirect attacks to systems nobody approved. Require the target and the scan size to appear in a reviewed config file, and check the target before each run that an agent starts.
Access control for teams
The paid Enterprise tier adds team sharing, SSO and access control, but that layer covers the promptfoo platform, not necessarily what a local MCP client can do. Ask the vendor how the MCP server authorizes tool calls before relying on any team-wide policy. Until that is confirmed in the docs, treat each developer machine as a separate trust boundary.
promptfoo pricingWhy the MCP server fails to start or respond
This table lists the failures most often seen when promptfoo MCP server setups do not start or do not answer, with the likely cause and the fix for each. Read it top to bottom when a client reports no tools or a failed call, since the first rows cover startup and the last rows cover runtime behavior.
| Symptom | Likely cause | Fix |
|---|---|---|
| Server exits at startup with a missing module error | Slim install without the optional @modelcontextprotocol/sdk package | Install the optional @modelcontextprotocol/sdk package in the same environment that runs promptfoo mcp, then restart the client |
| Command fails or behaves unexpectedly on launch | Node.js older than the version promptfoo requires (22.22.0 or newer for the 0.124.1 release) | Check the Node.js version the server process uses, upgrade it, and confirm the promptfoo version with the release notes |
| Client reports that the server failed to connect | Client configuration points at the wrong command, path or working directory | Use the exact promptfoo mcp invocation your installation resolves to, with an absolute path if the client does not inherit your shell PATH |
| Server runs but no promptfoo tools appear in the client | Client was not reloaded after the configuration change, or the server is listed under the wrong key | Reload or restart the client, confirm the server name and entry in its MCP settings, and check the client's server log |
| Tool calls fail with authentication or model errors | Provider API keys are set in your interactive shell but not in the environment of the process the client launches | Pass the required provider keys through the client's environment settings for the MCP server, and avoid storing secrets in shared config files |
| Long eval or red team tool calls time out or appear hung | Client request timeout is shorter than the run, so the client gives up while promptfoo keeps working | Start a smaller run first, raise the client timeout where it allows, and set run limits such as case count and concurrency before agents start jobs |
Keeping the MCP server current after promptfoo upgrades
Pin the promptfoo version that your MCP server runs, and treat every upgrade as a change to the agent setup rather than a routine package bump. promptfoo ships quickly: the npm release 0.124.1 was published on 8 October 2026, and the project's GitHub releases page is where changes to commands and behavior are announced. Before moving to a newer version, read the release notes for changes to the promptfoo mcp command, to the tools it exposes, and to the optional @modelcontextprotocol/sdk dependency that slim installs need. Record the pinned version in the same place your team pins other tooling, so that a fresh install on a developer laptop or in a CI image does not quietly pull a different release.
After each upgrade, retest the connection from every client that uses the server, including Cursor and Claude Desktop. Start the server from a clean shell, confirm the client lists the expected tools, and run one read-only call and one eval or red team call that you already know the result of, using the same limits and configuration your agents use. Check that the server still starts with the slim install and the SDK package in the form your team has chosen. Keep these results with the change record so that a later failure can be traced to a specific version. Confirm the tool names and arguments that the installed version exposes before you write agent instructions against them, because an instruction that names a tool the server no longer provides will fail in ways that are hard to diagnose from the agent's side. Repeat this check whenever the version changes, including patch releases, since a dependency change can alter behavior even when the commands look the same.
Questions teams ask before running promptfoo as an MCP server
Does running promptfoo as an MCP server cost anything extra?
The promptfoo package is MIT licensed, and the promptfoo mcp command is part of the same tool, so the server itself adds no license fee. The costs that matter are the people time to set it up and the model API usage that agents trigger when they start runs. Each eval or red team run calls the model under test, so token spend depends on how many runs your agents start and how large each suite is. Ask any partner to separate one-time setup effort from recurring items such as model usage, hosting and retainer support, and to state which of these they expect you to pay directly.
How long does it take to get promptfoo MCP working in Cursor or Claude Desktop?
For one developer on a laptop, the main steps are installing promptfoo on Node.js 22.22.0 or newer, confirming the promptfoo mcp command starts, and adding the server entry to the MCP client configuration. The duration depends less on the install than on deciding which tools agents may call and which configs and providers they may reach. Teams with a standard Node.js setup and a clear permission list can usually finish that first pass quickly. Broader rollout takes longer because it needs written limits, a test run against a non-production target, and a review of who can change the configuration. Ask for a timeline tied to those specific steps.
Can our own engineers set up promptfoo MCP without a partner?
Yes, a team with Node.js and MCP client experience can install and configure the server in-house. The skills that are harder to build are limits design and verification: deciding which promptfoo tools an agent may call, which provider keys it can read, where results are written, and how a run is capped before it starts. Security review of the setup, such as testing whether a prompt can make an agent start runs outside its brief, is also specialist work. If your team lacks that experience, a partner can handle the design and testing while your engineers keep ownership of the configuration.
Does the promptfoo Community edition cover running the MCP server?
The Community edition is free and includes all LLM evaluation features, all model providers and integrations, and red teaming with 10k probes per month, with community support. Running the MCP server on a developer machine falls within that scope because the server is part of the open-source tool. The 10k probes per month limit still applies to red team runs started by agents, so an agent that repeats scans can use up the allowance quickly. Enterprise adds team sharing, SSO, role-based access control and continuous monitoring, which matter once several people share one server. Confirm the current probe limits and edition terms on the promptfoo pricing page before you plan volume.
What changes when the promptfoo MCP server moves from a laptop to a shared environment?
On a laptop, one person controls the server and its credentials. In a shared environment, several people or agents reach the same tools, so access control, audit trails and data handling become the main concerns. The self-hosted promptfoo app stores data in a local SQLite database that cannot be shared across replicas, and it has no RBAC, horizontal scaling, built-in authentication or SSO, and it is not recommended for production use. Teams that need shared use typically look at Enterprise or On-Premise, or they add their own identity and access controls around the service. Ask how each option handles authentication, logging, secrets and upgrades before you choose.
What limits should we set before agents can start promptfoo runs?
Set limits before the first agent connects, because an agent can start expensive runs without a person watching. Useful controls include which tools the MCP client may call, which config files and providers the server can read, which API keys are available to it, how many probes or test cases a run may use, and where output is written. Test each limit with a prompt that tries to exceed it. Treat the list as a starting point: the exact options depend on your promptfoo version and MCP client, so check the MCP server documentation and command reference before you write the configuration.
What should we ask for in a quote for promptfoo MCP work?
Ask for a written scope that lists the MCP clients in use, the number of users, the promptfoo edition, the target environment, and the tools agents may call. Request separate line items for installation, limits design, security testing of the setup, documentation and any handover training. Ask which items are one-time and which recur, such as retainer support or retesting after upgrades. Also confirm who pays for model API usage and hosting, and what happens if the scope changes. DeployOpen agrees scope, deliverables and timelines in writing before work starts and does not publish a price list, so a quote follows from that written scope.
How do we check that the promptfoo MCP server is safe to run?
Verify the setup in the environment where it will run, not only on paper. Confirm that the server starts only with the optional @modelcontextprotocol/sdk package installed when you use a slim install, and that the MCP client sees only the tools you approved. Then test the agent against prompts that try to read unapproved files, use other provider keys, or start large red team scans. Record the results and retest after each upgrade. This verification supports your own review and is not a certification or audit report.
How DeployOpen scopes and delivers an MCP server rollout
DeployOpen plans, builds, tests and documents promptfoo MCP server setups inside your own infrastructure, so your security and engineering teams can review how coding agents reach evals and red team tools. Engagements are fixed-scope, with the scope, deliverables and timeline agreed in writing before work starts.
How we scope
- Map which AI coding tools and MCP clients will connect, and which promptfoo eval and red team tools each one may call
- Record the workstation, network and credential boundaries the promptfoo mcp process will run under
- Agree the limits on run size, providers, output locations and approvals in the written scope before any build starts
How we build
- Install promptfoo with the optional @modelcontextprotocol/sdk package where a slim install is used, and pin the Node.js version
- Configure each MCP client entry so it starts only the tools the approved scope allows, with credentials supplied from your secret store
- Test agent-initiated runs for permission gaps, prompt injection through tool inputs and unexpected access to files or model keys
How we hand over
- Deliver the client configuration files, install steps and a runbook covering startup, upgrades and rollback
- Provide a findings report with fixes and a retest of the agent setup against the agreed test cases
- Document the run limits, logging and ownership so your team can review and operate the setup after handover
How we support
- Offer ongoing support, upgrades and continuous testing as a retainer when the setup must follow new promptfoo releases
- Review changes to MCP client configurations and tool permissions before they reach developer machines
- Confirm release notes and compatibility for each promptfoo version against your pinned Node.js and MCP SDK versions

