mcph
MCP Harness: diagnostics, real-client proxy and agent evals for MCP servers.
Early development: the commands and
mcph.yamlmay still change between 0.x releases.
Install
pip install mcph # Python 3.12+
uvx mcph --help # or run it without installing
pip install 'mcph[gateway]' # with the gateway, mcph proxy --gateway (see The gateway)
Quick start
mcph init writes a starter mcph.yaml for you:
$ mcph init --server-cmd "uv run python src/server.py"
Created /path/to/mcph.yaml
Edit the server entries, then run `mcph doctor run`.
Or write it yourself. It describes your MCP servers: stdio servers that mcph starts for you, and http servers that are already running.
extends:
- builtin:core # the rules that ship with mcph (without a pack there is no rule)
servers:
- name: orders
transport: stdio
command: uv
args: ["run", "python", "src/server.py"]
env_file: .env # more variables for the server, kept out of this file
env:
LOG_LEVEL: WARNING
API_KEY: ${API_KEY} # taken from the environment mcph runs in
- name: docs
transport: http
url: http://localhost:8080/mcp
env_file: .env # where ${DOCS_TOKEN} is looked for if the environment does not have it
auth: # optional: send a bearer token
type: bearer
token: ${DOCS_TOKEN} # the token comes from this environment variable
eval: # optional, for `mcph eval`: what to run against a server with an agent
suites: # the suites, as `servers` is a list of servers
- name: order-tracking # every suite has its own target, runners and matrix
path: suites/order-tracking.yaml # its file, with its tasks and checks
target: orders # the server the agent gets (default: the only server, or the gateway)
runners: # the ways to run an agent, by name
haiku: {preset: claude, model: haiku}
- name: order-cancellation
path: suites/order-cancellation.yaml
target: orders
runners:
sonnet: {preset: claude, model: sonnet}
haiku: {preset: claude, model: haiku}
matrix: # every task runs once for each of these (see "Evaluating a server")
runner: [sonnet, haiku]
repeat: 5 # and 5 times, unless a task says otherwise: an agent does not do the same thing every time
A stdio server only gets the environment you give it: ${API_KEY} takes a variable from the environment mcph runs in, and env_file points at a dotenv file (keep it out of Git) for the variables you do not want in mcph.yaml (see Environment variables of a server). The bearer token of an http server is written the same way: token: ${DOCS_TOKEN}, and its own env_file is where mcph looks for the variable when the environment it runs in does not have it, which is the case for a client that starts mcph without your shell's variables.
Then check them:
$ mcph doctor run
Checking 2 servers from /path/to/mcph.yaml
orders
OK started in 423 ms (orders-server 1.0.0, MCP 2026-07-28), 3 tools
WARN core.tool_name_snake_case: tool 'getOrder' is not snake_case (try 'get_order')
docs
OK connected in 87 ms (docs-server 2.1.0, MCP 2026-07-28), 5 tools
OK core.tool_name_snake_case
SKIP oauth.metadata, oauth.issuer, oauth.pkce, oauth.registration: not needed, the server accepted the connection
All servers OK, 1 warning.
extends lists the packs whose rules doctor uses; builtin:core is the pack that ships with mcph (see Rules and packs). Under each server doctor lists every rule: OK ran and found nothing, WARN or ERROR found a problem, OFF is turned off in mcph.yaml, and SKIP could not run or was not needed (skipped rules with the same reason share one line). To make a rule fail the run instead, or to switch it off, add a doctor section to the same file:
doctor:
rules:
core.tool_name_snake_case: error # or warn, or off
See Configuring rules for the details.
Commands
| Command | What it does |
|---|---|
mcph init [DIRECTORY] |
Writes a starter mcph.yaml that extends builtin:core (default: the current directory, created if needed). It never overwrites an existing file. |
mcph doctor run |
Starts each stdio server (or connects to an http one), completes the MCP handshake, lists its tools, checks them against the rules of the packs under extends and reports what each rule found. |
mcph doctor rules |
Lists the rules of the packs under extends with their severity: the default, or the setting from doctor.rules in mcph.yaml. It starts no server. |
mcph pack list |
Lists the packs under extends with the rules each one defines. |
mcph pack verify [PATH] |
Checks a pack directory (default .): its manifest, its rule files and the rules they define. It lists every problem and exits with 1 if there are any. |
mcph server auth login SERVER, status [SERVER], logout SERVER |
Signs in to an http server that uses OAuth through the browser, shows who is logged in, and signs out again. mcph server is the group of the commands about the servers of mcph.yaml; auth is the first of them. |
mcph version |
Prints the installed version. |
mcph proxy [--trace-out FILE] [--no-redact] (-- COMMAND... | --server NAME | --gateway [--no-namespace-tools]) [--transport http [--host HOST] [--port N] [--path PATH] [--ready-file FILE] [--allow-remote]] |
Records the traffic between a client and a server, to a trace: a stdio server given as a command, or a stdio or http server of mcph.yaml with its environment and auth, for a client that starts the proxy. With --transport http, an http server of mcph.yaml on a local URL, for a client that connects by URL. With --gateway, every server of mcph.yaml behind one endpoint, on stdio or a URL (needs mcph[gateway]). See Recording traffic. |
mcph trace print FILE |
Prints what a trace says, in plain words: the session, the tools the client was offered, every tool call (named server.tool, with its arguments, how it ended and how long it took) and what went wrong. See Reading a trace. |
mcph eval [SUITE...] [--trace FILE ...] [--task ID] [--runner NAMES] [--model NAMES] [--target NAMES] [--repeat N] [--report FILE] [--junit FILE] |
Runs the tasks of the suites with an agent (claude, in a sandbox, or a command of yours), in every cell of the matrix of runners, models and servers that each suite of eval.suites in mcph.yaml defines, as many times as the suite or the task says (repeat: an agent does not do the same thing every time), and checks each session (every call worked, the arguments fit the schema of the tool, tools that must or must not be called, the answer, ...). With --trace it checks recorded traces instead. Says what failed and exits with 1 if a check failed. Can also write the results as a JSON report and as JUnit XML. See Evaluating a server. |
mcph report print FILE |
Prints a run report (the file of mcph eval --report) as mcph eval printed it: a block for each run, the grid of how each task did in each cell, and the count of the traces that failed. The same text, made by the same code, for reading a report later. Exits with 0 when it could be read, whatever the report says. See Evaluating a server. |
mcph report diff BASE HEAD [--cell ID ...] [--fail-on-regression] [--markdown] |
Compares two run reports (the files of mcph eval --report): the tasks that passed in a cell in BASE and do not pass in HEAD are regressions (a task passes when its pass rate reaches what its suite asks for), improvements and other changes are listed too, and for a regression the checks that failed. With --fail-on-regression it exits with 1 when there is a regression; --markdown writes it for a pull request comment. See Evaluating a server. |
mcph doctor is a group of commands: on its own it is an error, so a script that still calls it fails instead of passing without checking anything. mcph doctor --help lists its commands.
mcph init --template minimal|multi-server|oauthpicks the starter: onestdioserver (the default), astdioserver plus anhttpserver with a bearer token from an environment variable, or anhttpserver that signs in with OAuth.--server-cmd "uv run python src/server.py"sets how thestdioserver starts (split like a shell would).--extend SOURCE(repeatable) replaces the defaultbuiltin:core, so add--extend builtin:coreto keep the core rules next to a pack of your own.--forceoverwrites an existingmcph.yaml.initwritesDIRECTORY/mcph.yaml, so the global-cdoes not apply to it.-c, --config PATHselects the config file (default./mcph.yaml). It goes before the command:mcph -c other.yaml doctor run.mcph doctor run --timeout SECONDSlimits how long each server may take to start and answer (default 30).mcph doctor run --strictalso fails on warnings, which is handy in CI.mcph doctor runexits with0if all servers are OK,1if a server failed (or, with--strict, if there are warnings),2if the config is invalid.
If an http server refuses mcph, doctor says why instead of a generic error: no token was sent (401), the token was rejected (with the server's error, its explanation and the scope it asks for), or the token lacks a scope (403). It also shows what the server announces about its OAuth setup when it publishes protected resource metadata (RFC 9728): its authorization server and scopes.
docs
ERROR authentication required: the server answered 401 (add `auth` to this server in mcph.yaml)
challenge: Bearer resource_metadata="http://localhost:8080/.well-known/oauth-protected-resource/mcp"
authorization server: https://auth.example.com/
scopes: api.read, api.write
SKIP core.tool_name_snake_case: mcph could not connect to the server
OK oauth.metadata
OK oauth.issuer
OK oauth.pkce
OK oauth.registration
Doctor also checks the OAuth setup the server announces (for an auth: {type: oauth} server that is not logged in yet too), so a problem that would stop a client from signing in shows up before anyone tries. It only sends unauthenticated requests, and only for a server that needs authentication. For a server that connected, these checks are listed as SKIP:
| Check | Severity | Looks for |
|---|---|---|
oauth.metadata |
error | The authorization server's metadata can be found and has an authorization and a token endpoint. |
oauth.issuer |
error (warning if only a trailing slash differs) | The metadata's issuer is the authorization server the resource announced. |
oauth.pkce |
error | PKCE with S256 is advertised. |
oauth.registration |
warning | Dynamic client registration is offered. |
These rules are in the core pack, and you can configure each of them (see Rules and packs and Configuring rules).
OAuth login
For a server that uses OAuth, set auth: {type: oauth} (optionally with scopes) and sign in once:
$ mcph server auth login docs
Signing in to docs (http://localhost:8080/mcp)
Opening your browser. If it does not open, visit:
https://auth.example.com/authorize?response_type=code&client_id=...
Logged in to docs; the token expires in 15 min.
mcph renews it with the refresh token that the server issued.
mcph doctor run then uses the stored token. An access token usually expires after a few minutes. When the server issued a refresh token, mcph uses it to get a new access token once the old one has expired (or is about to), so doctor keeps working without another sign-in for as long as the authorization server accepts the refresh token. If it does not (the refresh token expired or was revoked), or if the server issued none, doctor says so and asks you to log in again. mcph server auth status shows who is logged in, when each token expires and whether a refresh token is stored (mcph server auth login tells you right after signing in), and mcph server auth logout docs deletes the tokens. For CI use a bearer token from an environment variable instead.
Some authorization servers only issue a refresh token to a client that asks for the offline_access scope; the sign-in asks for it when the server's metadata lists it. A login made with an older mcph kept no refresh token: log in once more to get one.
Tokens are kept in files only you can read, under mcph's state directory (set MCPH_STATE_DIR to put it elsewhere). A refresh token stays valid much longer than an access token, so that directory deserves the care you give your other credentials.
If login stops with Authorization server metadata issuer mismatch, the server announces its authorization server differently from the way that server describes itself. The standard wants the two to be identical, so the right fix is on the server. When the only difference is a trailing slash (https://auth.example.com/ against https://auth.example.com), you can have mcph accept it with ignore_issuer_trailing_slash: true under auth. It tolerates that one difference and nothing else.
Recording traffic
mcph proxy sits between an MCP client and a server and records everything the two say to each other. You name the server as a command, or as a server of mcph.yaml, or take every server of mcph.yaml at once (see The gateway). A client that starts its servers as processes starts the proxy instead of the server; a client that connects by URL is given the URL of a proxy that you start (see A URL).
A command
For a stdio server, put mcph proxy -- in front of its command in the client's configuration (the mcpServers format of .mcp.json, Cursor and Claude Desktop):
{
"mcpServers": {
"orders": {
"command": "uvx",
"args": ["mcph", "proxy", "--", "uv", "run", "python", "src/server.py"]
}
}
}
Use the client as usual. The proxy writes the trace while you do and tells you where it is on stderr, which clients show in their server logs:
mcph proxy: recording to /path/to/project/.mcph/traces/20261130T101503Z-3f9a1c.jsonl
The traffic is passed on byte for byte, in both directions: the proxy changes nothing that the client or the server says. The server's stderr is the proxy's stderr. Signals (Ctrl-C, terminate, hangup) are passed on to the server, and when the client closes its input the server's input is closed too. The proxy exits with the server's exit code: 128 + N if signal N ended it, 127 if the command was not found and 126 if it cannot be run.
A server of mcph.yaml
mcph proxy --server NAME proxies a server that mcph.yaml already describes, with everything the entry says about it. The global -c goes before the command:
{
"mcpServers": {
"docs": {
"command": "uvx",
"args": ["mcph", "-c", "/path/to/mcph.yaml", "proxy", "--server", "docs"]
}
}
}
- A
stdioserver is run as above, byte for byte, with thecommandandargsof the entry, in the directory ofmcph.yaml, and with its environment: the minimal one plusenv_fileandenv, asmcph doctor runstarts it. A client that has none of your shell's variables still gets them frommcph.yamland your.env. - An
httpserver is reached over Streamable HTTP with theauthof the entry. With none, nothing is sent. Withtype: bearer, the token istoken: ${NAME}from the environment of the proxy or, if that does not have it, from theenv_fileof the entry: a client that does not have your shell's variables needs nothing in its ownenvsetting when the entry has anenv_filewith the variable, and if it is set nowhere the proxy stops with a message before anything starts. Withtype: oauth, runmcph server auth login NAMEfirst: the proxy sends the stored token and renews it with its refresh token whenever it has expired, also in the middle of a session. A login made or renewed in another terminal is used at once. - The relay is transparent. There is one session at the server for the whole session of the client, and the messages go through as they are, including the server's own requests to the client (sampling, roots, elicitation). The trace says
reserialized: the messages are parsed and sent on again, so the HTTP details are the proxy's. - A server that is down, or refuses a request, is answered, never waited on. The client gets an error that says why and what to do, and the same text goes to stderr:
mcph proxy: cannot reach http://localhost:8080: ConnectError: All connection attempts failed,mcph proxy: not logged in (runmcph server auth login docs),mcph proxy: the server rejected the token in $DOCS_TOKEN (HTTP 401). - It ends when the client closes its input, after the server has answered what is still open (at most five seconds, so that
echo request | mcph proxy --server docsgets its answer), and the session at the server is ended properly. A SIGINT, SIGTERM or SIGHUP ends it at once. The exit code is0, or128 + Nfor a signal, or the server's own for astdioserver. - Not supported: the older HTTP+SSE transport (a server with a separate
/sseendpoint), which MCP has deprecated in favour of Streamable HTTP, and tool parameters that the newer protocol revision copies into HTTP headers. A client that connects by URL can use the listener.
A URL
A client that connects by URL, instead of starting a process, needs --transport http. It serves a server of mcph.yaml that is itself an http server (Streamable HTTP) on a local address, and you start the proxy yourself:
$ mcph proxy --server docs --transport http --port 8081
mcph proxy: recording to /path/to/project/.mcph/traces/20261130T101503Z-3f9a1c.jsonl
mcph proxy: proxying the server docs (http)
mcph proxy: listening on http://127.0.0.1:8081/mcp
Then give the client that URL, for example in VS Code's .vscode/mcp.json:
{ "servers": { "docs": { "type": "http", "url": "http://127.0.0.1:8081/mcp" } } }
- It is the server, as far as the client can tell. A request goes to the URL of the entry as it is, and the answer (one JSON body, or an event stream) comes back as it is. mcph does not interpret the protocol, so both generations of Streamable HTTP (with or without the
initializehandshake and a session id), streamed progress, the server's own requests to the client and resuming a stream withLast-Event-IDwork as they do without the proxy. - mcph signs in for the client. The
authof the entry (the stored OAuth token, renewed as it expires, ortoken: ${NAME}) replaces anyAuthorizationheader of the client, which therefore needs no login of its own. An entry withoutauthleaves the client's own header alone. A server that is down, or refuses a request, is answered with its HTTP status and an error that says why and what to do, with the id of the request (mcph proxy: not logged in (runmcph server auth login docs)). Cookies andOriginof the client are not sent on, andSet-CookieandWWW-Authenticateof the server are not sent back, so that a client does not start a sign-in of its own at the real server. --port 0picks a free port, which is what a program that starts the proxy wants. The URL is printed once the proxy accepts connections, and written to--ready-file FILEif you give one, so that the program can wait for the file (it is written whole, an old one is removed at the start, and it is removed again at the end).--host(default127.0.0.1),--port(default8080) and--path(default/mcp) say where. A port that is taken stops the proxy at once, before a trace exists.- Only you can reach it, unless you say otherwise. The proxy uses your login of the server, so anyone who can reach it can use it. It listens on a loopback address, and refuses any other
--hostunless you give--allow-remote. On loopback a request whoseHostorOriginis not a loopback name (a web page that has pointed its own name at127.0.0.1) is refused with421or403. - It ends on SIGINT, SIGTERM or SIGHUP, with exit code
0. It stops accepting connections, ends the event streams that clients keep open, lets requests in progress finish for up to five seconds (one that is still running then is answered with an error that says the proxy is shutting down), ends the sessions that the server opened, as their clients would have, and ends the trace. A second signal does not wait. - The trace is one for the whole run, whichever clients come and go, and says
passthrough: the frames are the bytes that went through. The format has no field for which client a frame belongs to, so when several clients use the proxy at the same time their frames are interleaved, andlatency_mscan pair wrongly if two of them use the same id at the same moment. - Not supported: a
stdioserver on a URL (use it through the standard input and output), TLS, and CORS for web pages that call the proxy.
The gateway
mcph proxy --gateway serves every server of mcph.yaml as one MCP server: a client has a single entry in its configuration for all of them, and the trace shows what went to each. The global -c goes before the command, and the gateway needs the gateway extra of mcph (see below), which uvx --from 'mcph[gateway]' brings:
{
"mcpServers": {
"mcph": {
"command": "uvx",
"args": ["--from", "mcph[gateway]", "mcph", "-c", "/path/to/mcph.yaml", "proxy", "--gateway"]
}
}
}
A client that connects by URL needs --transport http, with --host, --port, --path and --ready-file as for a URL (the gateway listens on a loopback address and is not reachable by anyone else, unless you give --allow-remote):
$ mcph proxy --gateway --transport http --port 8081
mcph proxy: recording to /path/to/project/.mcph/traces/20261130T101503Z-3f9a1c.jsonl
mcph proxy: starting the gateway for orders (stdio), billing (http)
mcph proxy: the gateway serves orders (2 tools), billing (2 tools)
mcph proxy: listening on http://127.0.0.1:8081/mcp
- It needs the
gatewayextra, which installs FastMCP's server part (15 packages, about 7 MB, that nothing else in mcph uses):pip install 'mcph[gateway]', oruvx --from 'mcph[gateway]' mcph ...to run it without installing. Without itmcph proxy --gatewaysays so and stops before it starts anything (exit code2, no trace); every other command works without it. - Names get the name of their server in front, so that two servers can both have a
get_order: with the serversordersandbillingthe client seesorders_get_orderandbilling_get_order. The same goes for prompts (orders_greet); a resource gets it as the first part of its path (data://orders/items). A call goes to the server it belongs to, under the name that server knows.--no-namespace-toolsleaves the names as the servers have them, to see what a client does when names collide: the first server ofmcph.yamlwins, and mcph says which tools are hidden when it starts. - One session per server for the whole run. All the servers are started and connected when the gateway starts, in parallel, and kept: a
stdioserver is one process for as long as the gateway runs, not one for every request. If one cannot be reached the gateway stops at once, with an error that names it, instead of serving fewer tools than the client expects (exit code1):Error: the server 'billing': cannot reach http://localhost:8080: ConnectError: All connection attempts failed. Every entry is checked first, the same way as for--server, and an entry that cannot be used (a variable that is not set) is named before anything starts. - The gateway is a server of its own towards the client, not a pass-through: the client sees one merged list, whichever generation of the protocol it speaks, and the gateway speaks to each server as a client of the older generation (with the
initializehandshake). Progress that a server reports is passed on to clients of both generations. The questions it asks the client in the middle of a call (elicitation, sampling, roots) are passed on to clients of the older generation only (the one with theinitializehandshake): for a client of the newer one the call ends with an error that says so. - The trace holds both conversations, in one file for the whole run,
reserialized. The frames without aserverare what the client and the gateway say to each other (the client'sinitialize, the merged list of tools with their prefixed names, its calls and the answers), recorded the way--serverrecords its client. The frames with aserverare the traffic between the gateway and that server, under the names that server knows. The two are interleaved in the order they happened, each with its own request ids and its ownlatency_ms, so a call of the client is followed by the calls that the gateway makes to the servers for it. The tokens that go to the servers are hidden, as for--server. With several clients at once on a URL their frames are interleaved, as for a URL. - It ends when the client closes its input (on stdio), or on SIGINT, SIGTERM or SIGHUP, also while the servers are still starting. The sessions at the servers are ended, so no server process is left, and the trace is ended. The exit code is
0, or128 + Nfor a signal on stdio. - Limits: a server that exits while the gateway runs is not started again (its tools disappear from the list, and mcph says so on stderr: restart the gateway); there is no way yet to serve only some of the servers; the output of a
stdioserver on stderr is the gateway's stderr.
The trace
- It goes to
.mcph/traces/<session>.jsonlin the directory where the client starts the proxy, or next to themcph.yamlselected with-c(for--server, always next to it).--trace-out FILEpicks the file instead. An existing file is never overwritten. - Secrets such as tokens, passwords and
Authorizationvalues are hidden unless you pass--no-redact, and so is every token that mcph itself sends to anhttpserver. A trace still holds the arguments and results of tool calls, which can be sensitive: treat it like a log..mcph/gets a.gitignoreso that it is not committed by accident. - The trace format describes the events: every frame with its time, and for a response how long the server took. A trace of the gateway names its servers (
upstreams) and says which server a frame was with (server), or, without one, that it was the client's.
Reading a trace
mcph trace print FILE prints what a trace says, so that you do not have to read the JSON lines:
$ mcph trace print .mcph/traces/20261130T101503Z-3f9a1c.jsonl
Trace 20261130T101503Z-3f9a1c (.mcph/traces/20261130T101503Z-3f9a1c.jsonl)
recorded by mcph 0.3.0 (reserialized); complete: 23 messages in 240 ms
gateway of 2 servers, tool names prefixed with the server
orders uv run python orders.py (stdio, calls itself orders 1.0)
billing https://billing.example/mcp (http, calls itself billing 1.0)
client: demo-client 1.0, MCP 2025-06-18
messages: 7 between the client and the gateway, 7 with orders, 9 with billing
Tools offered to the client (3): orders_get_order, billing_get_order, billing_pay
Requests of the client: initialize 1, tools/list 1, tools/call 1
Tool calls (1: 1 ok):
seq 20 billing.pay {"amount":5} (called as billing_pay)
ok, 30 ms, 79 B: paid 5
Problems: none
- It shows the session (how it ended, the servers, the client), the tools the client was offered, every tool call, and what went wrong: error answers to other requests, requests that were never answered, frames that are not JSON-RPC.
- A tool is named
server.tool: the name of the server inmcph.yaml, a dot, and the tool's own name at that server. Behind a gateway the client uses the prefixed name (billing_pay); mcph works out the server and the tool (billing.pay) from the tool lists of the servers in the same trace, and shows the name the client used next to it. For a trace of one server, the server is the name that the trace records (--server NAME), if it has one. - A call ends in one of four ways: ok; tool error (the result says
isError); protocol error (a JSON-RPC error, such as an unknown tool or arguments the server refused); unanswered. A call to a tool that the client had not been offered says so. - It exits with
0when it could read the trace (the problems it lists do not change that), and with1when it could not: the file is not a trace, or is of a version of the format that this mcph does not know.
Evaluating a server
mcph eval runs tasks against your server with an agent, and checks what happened: the session that the proxy recorded (every call, its arguments and its answer) and what the agent answered. mcph has no agent of its own: you name one (claude, in a sandbox, or any command), and mcph gives it the server to work with.
Two kinds of files say what to do. A suite file says what to check: tasks, and what each session has to show. eval in mcph.yaml has a list of suites, as the top of the file has a list of servers, and says how to run each one: its file, which server the agent gets, which agents (runners) there are for it, and a matrix of runners, models and servers, so that a suite can be run with different agents or models and the results compared side by side.
# mcph.yaml (the servers are above)
eval:
suites:
- name: order-tracking
path: suites/order-tracking.yaml
target: orders
runners:
haiku: {preset: claude, model: haiku}
- name: order-cancellation
path: suites/order-cancellation.yaml
target: orders
runners:
sonnet: {preset: claude, model: sonnet}
haiku: {preset: claude, model: haiku}
matrix:
runner: [sonnet, haiku]
repeat: 5 # and 5 times, unless a task says otherwise
# suites/order-tracking.yaml
tasks:
- id: where-is-my-order
prompt: Where is order 1042, and has it shipped?
expect_tools: [orders.get_order]
forbid_tools: [orders.cancel_order]
max_tool_calls: 4
answer: {contains: in transit}
# suites/order-cancellation.yaml
tasks:
- id: cancel-after-shipping
prompt: Cancel order 1042 and tell me what happened.
expect_tools: [orders.cancel_order]
answer: {contains: shipped}
checks:
allow_tool_errors: [orders.cancel_order] # the tool is meant to say no here
- id: cancel-before-shipping
prompt: Cancel order 1044 and tell me what happened.
expect_tools: [orders.cancel_order]
repeat: 1 # a plain cancellation does not need five runs
$ mcph eval
mcph eval: 13 runs: order-tracking: 1 cell (haiku/orders) x 1 task; order-cancellation: 2 cells (sonnet/orders, haiku/orders) x 2 tasks x 1 to 5 repeats; the runs of claude cost at most $13.00
mcph eval: [1/13] haiku/orders order-tracking where-is-my-order: running claude
mcph eval: [1/13] haiku/orders order-tracking where-is-my-order: done in 7.9 s
mcph eval: [2/13] sonnet/orders order-cancellation cancel-after-shipping (1 of 5): running claude
...
Checks of .mcph/traces/20261202T095905Z-7af762-order-cancellation-sonnet_orders-cancel-after-shipping-r1.jsonl (suite order-cancellation, task cancel-after-shipping, cell sonnet/orders, run 1 of 5)
ran claude in 5.6 s, exit code 0, 2 turns, $0.0151
answer: I didn't cancel order 1042, because it has already shipped. Its status is "in transit" and its tracking number is T-1042-X. The cancel function only works on orders that haven't shipped, so I didn't …
OK agent_finished
FAIL expect_tools: orders.cancel_order was not called
OK answer
...
1 of 9 checks failed, 2 off.
...
Checks of .mcph/traces/20261202T095905Z-7af762-order-cancellation-haiku_orders-cancel-before-shipping.jsonl (suite order-cancellation, task cancel-before-shipping, cell haiku/orders)
ran claude in 4.3 s, exit code 0, 2 turns, $0.0108
answer: Order 1044 has been successfully cancelled.
OK agent_finished
OK expect_tools
OK no_tool_errors
...
8 checks passed, 2 off.
...
Results of each task of order-cancellation in each cell:
sonnet/orders haiku/orders
cancel-after-shipping 1/5 FAIL 5/5
cancel-before-shipping OK OK
4 of 13 traces failed.
That is a real run (13 runs, $0.15; some of the runs and of the check lines are left out): sonnet did not try to cancel the shipped order in 4 of its 5 runs, while haiku tried in all 5 (and was told no, which the suite allows). The pass rate of a task in a cell is how many of its runs passed (1/5); 5/5 is pass^k, that every run passed. One run could not have told whether what sonnet did was its habit or luck. cancel-before-shipping asks for repeat: 1 itself, so it ran once in each cell.
mcph evalruns every suite ofeval.suites, or the ones whose names you give (mcph eval order-cancellation), one after the other. Every task of a suite runs in every cell of its matrix. For each run the agent gets a fresh server: it startsmcph proxyitself, through an MCP configuration that mcph writes, in an empty directory, and the proxy records the session to.mcph/traces/(kept out of Git). If the time is up, or you press Ctrl-C, mcph stops the agent and everything it started (that is done with a process group, somcph evalis for macOS and Linux, or WSL; it has not been tried on Windows).- Repeats:
repeat: 5runs every task of a suite 5 times in each cell, because an agent does not do the same thing every time; a task of the suite file can have arepeatof its own (and apass_rate), for the ones that need fewer or more runs than the rest. A task passes in a cell when its pass rate, the share of its runs that passed, reaches itspass_rateor that of its suite (by default1: every run); pass^k says that all of them did. A run that failed is written out check by check, one that passed in a few lines.--repeat Nreplacesrepeatof every task for one command. Repeats multiply the runs, and what they cost. - The matrix of a suite has the axes
runner,modelandtarget(a server ofmcph.yaml, orgatewayfor all of them), and optionalexcludeandinclude. Without one there is one run of each task.--runner,--modeland--targetreplace an axis for one command:mcph eval order-cancellation --runner haiku --model haiku,sonnet. A matrix multiplies the runs, so mcph says how many there are, and what the runs ofclaudecan cost at most, before it starts. preset: clauderuns in a sandbox:claude -pwith the server under test and nothing else, not the MCP servers that are configured for you (a Jira server, say), not Bash or the file tools, not your settings. mcph does not take that on trust: it reads whatclaudesays it has, and stops the run at once, with exit code2, if there is anything else.- A runner can also be a command that starts any agent:
command: [my-agent, --model, "{model}", "{mcp_config}", "{prompt}"]. mcph tells it where the server is with{mcp_config}; what it prints is its answer. For another agent the sandbox is yours to make. - Checks:
OK,FAIL(with every problem),SKIP(the trace does not have what the check needs) orOFF. The session checks (every call worked, the arguments fit the schema of the tool, no tool that was not offered, no loop,latency_under,response_size_under, ...) need no task; a task addsexpect_tools,expect_sequence,forbid_tools,max_tool_calls,expect_argsandanswer; a run also hasagent_finished. A tool is writtenserver.tool, also behind the gateway. - Exit codes:
0when no check failed (when every task passed in every cell, if it was run),1when one did,2whenmcph evalcould not run (a file it needs cannot be read, an unknown suite, runner, task or target, an agent that cannot start or breaks the sandbox, a report that cannot be written). - A recorded trace is checked with
mcph eval order-tracking --trace FILE(a suite ofmcph.yamlby its name, or a suite file), without running anything: from any client, or a script. Several--trace FILEare checked against the same checks. - Reports:
--report FILEwrites the results as one JSON report (docs/run-report.md: the cells, every run and every check, with a JSON Schema),--junit FILEas JUnit XML for the test reports of CI. Both are written after the text. - Printing a report:
mcph report print report.jsonprints a report asmcph evalprinted it (the same text, made by the same code), so that it can be read later, from a CI artifact or on another machine. - Comparing two runs:
mcph report diff base.json head.jsoncompares two run reports and lists the tasks that passed in a cell before and do not now (a regression), with the checks that failed. What a suite accepts (pass_rate: 0.8) is not a regression.--fail-on-regressionmakes it exit with1,--markdownwrites it for a pull request comment or$GITHUB_STEP_SUMMARY, and it exits with2when it has nothing to compare, so that a comparison of nothing does not pass.
docs/eval-suites.md has the whole reference: the suite file and every check, eval and the matrix, the runners and the sandbox, the results, printing a report, and comparing two runs.
Rules and packs
Rules come from packs. A pack is a directory with a mcph-pack.yaml that lists the Python files defining its rules. Name the packs doctor should use under extends in mcph.yaml:
extends:
- builtin:core # the rules that ship with mcph
- ./packs/acme # a pack of your own, relative to the directory of mcph.yaml
A source is a directory (relative to the directory of mcph.yaml, absolute, or starting with ~) or builtin:<name> for a pack bundled with mcph. Without any pack there is no rule: mcph doctor run then only reaches the servers and warns about it, and the warning fails a --strict run.
mcph pack list shows the packs that are loaded and the rules each one defines:
$ mcph pack list
Packs (from /path/to/mcph.yaml)
core 1.0.0 (builtin:core)
The rules that ship with mcph.
core.tool_name_snake_case
oauth.metadata
oauth.issuer
oauth.pkce
oauth.registration
acme 1.0.0 (./packs/acme)
Our checks.
acme.no_delete
The core pack
builtin:core has the oauth.* checks described above and this rule:
| Rule | Severity | Checks |
|---|---|---|
core.tool_name_snake_case |
warning | Tool names are snake_case, like get_order rather than getOrder. |
Warnings do not fail the run unless you pass --strict.
Writing a pack
packs/acme/
mcph-pack.yaml
rules/no_delete.py
# mcph-pack.yaml
name: acme
version: "1.0.0"
description: Our checks. # optional
rules:
- rules/no_delete.py # the files that define rules
# rules/no_delete.py
from mcph.extensions import doctor_rule
@doctor_rule(id="acme.no_delete", description="No tool deletes data.", severity="error")
def no_delete(context):
return [
f"{tool.name} deletes data"
for tool in context.snapshot.tools
if tool.name.startswith("delete")
]
Rules can look at the arguments and the annotations of a tool too:
@doctor_rule(id="acme.say_read_only", description="Every tool says whether it is read-only.")
def say_read_only(context):
for tool in context.snapshot.tools:
if tool.annotations.read_only_hint is None:
yield f"{tool.name} does not say whether it is read-only"
@doctor_rule(id="acme.describe_parameters", description="Every parameter has a description.")
def describe_parameters(context):
for tool in context.snapshot.tools:
for name, schema in tool.input_schema.get("properties", {}).items():
if not schema.get("description"):
yield f"{tool.name}: parameter {name!r} has no description"
- A rule id looks like
namespace.name(lowercase letters, digits and_, and-in the namespace) and is unique across all packs. Two packs with the same name are an error too. - The function gets a context:
server(the entry ofmcph.yaml),snapshot(what the server exposes:server_name,server_version,protocol_version,startup_secondsandtools;Noneif mcph could not connect),error(why it could not),timeout, and acacheshared by the rules that check one server. - Each tool in
snapshot.toolsis described as the server sent it:name,titleanddescription(each may beNone),input_schema(the JSON Schema of the arguments, a dict),output_schema(a dict, orNone) andannotationswithtitle,read_only_hint,destructive_hint,idempotent_hintandopen_world_hint, eachNonewhen the server did not say. Do not change what you receive: every rule of a server sees the same objects. (ServerSnapshotandToolInfoare inmcph.mcp_client, if you want to build them in tests of your rules.) - It returns a message for each problem, at the rule's severity, or
Issue(message, severity)objects (frommcph.rules) to choose the severity per problem. It may beasync, and it may raiseSkipRule("why")(frommcph.rules) when there is nothing to check. @doctor_rulealso takestransports=["http"]for a rule that only applies to HTTP servers (the default is both kinds), andneeds_connection=Falsefor a rule that is still useful when the server could not be reached (without it, such a rule is skipped, because there is no snapshot).- A rule that raises is reported as an error finding, and the other rules still run.
- A pack file is imported on its own, so it can import
mcphand installed packages but not the other files of the pack. - The Python of a pack runs with your privileges, like the
commandof astdioserver in the same file, so list only packs you trust.
While you write a pack, mcph pack verify packs/acme checks it without a config or a server: the manifest, that every listed file exists, imports and defines rules, and that rule ids are not used twice. It lists every problem (and exits with 1), or the rules it found:
$ mcph pack verify packs/acme
acme 1.0.0: valid, 1 rule
acme.no_delete error No tool deletes data.
$ mcph pack verify packs/other
packs/other: 2 problems
pack 'other': rules/missing.py, listed under rules in mcph-pack.yaml, does not exist
pack 'other': cannot import broken.py: SyntaxError: invalid syntax (broken.py, line 1)
Configuring rules
Under doctor.rules in mcph.yaml, set how serious a rule is, or turn it off. This applies to the rules of every loaded pack, by rule id:
doctor:
rules:
core.tool_name_snake_case: error # a camelCase tool name now fails the run
oauth.registration: off # do not check for dynamic client registration
error: findings of the rule are errors, so the run fails (exit code1).warn: findings are warnings, which fail the run only with--strict.off: the rule does not run, and the report lists it asOFF. Write it without quotes if you like: YAML readsoffas false, and mcph accepts that.
Rules you do not list keep their default severity. A configured severity replaces the default for all findings of that rule, so oauth.issuer: error also makes a trailing-slash difference an error. With all four oauth.* checks off, doctor does not contact an authorization server at all.
A rule id that no loaded pack defines is a config error (exit code 2) that lists the known ids and suggests the closest one. (Without extends no rule is known, and the message says how to add the core pack.)
mcph doctor rules lists the rules of the loaded packs, under the pack each comes from, with the setting that applies and the default next to one you changed. It starts no server:
$ mcph doctor rules
Rules (settings from /path/to/mcph.yaml)
core (builtin:core)
core.tool_name_snake_case error (default: warn) Tool names are snake_case.
oauth.metadata error The authorization server's metadata can be found and has an authorization and a token endpoint.
oauth.issuer error The metadata's issuer is the authorization server the resource announced (a difference of only a trailing slash is a warning).
oauth.pkce error PKCE with S256 is advertised.
oauth.registration off (default: warn) Dynamic client registration is offered.
acme (./packs/acme)
acme.no_delete error No tool deletes data.
Without a mcph.yaml in the current directory, or without extends, no pack is loaded and the listing says so. A -c path that does not exist, a pack that cannot be loaded, or an invalid config is an error (exit code 2).
mcph.yaml
version: optional,"1".servers: a list of servers, each with:name: unique; letters, digits,_and-.transport:stdioorhttp.command,args(stdio): how to start the server.env(stdio, optional): the server's environment variables, in which${NAME}takes a variable.env_file(optional): dotenv files that hold variables, for astdioserver to get and for anhttpserver (with a bearer token) to take the variables of its${...}from (see Environment variables of a server).url(http): the Streamable HTTP endpoint of a server you have already started, such ashttp://localhost:8080/mcp. mcph does not start it.auth(http, optional), one of:type: bearerandtoken, a reference such as${DOCS_TOKEN}to the environment variable that holds the bearer token (the same references as inenvvalues, so it can also sit in other text). mcph takes the token from its own environment or, if that does not have the variable, from theenv_fileof the server, never from the YAML: a token written there is refused. It is sent asAuthorization: Bearer ...to the server's URL only, and never printed. In YAML's{...}style put it in quotes:auth: {type: bearer, token: "${DOCS_TOKEN}"}. Earlier versions wrote this astoken_env: DOCS_TOKEN, which is now an error that says what to write instead.type: oauth, optionalscopesand optionalignore_issuer_trailing_slash: sign in through the browser withmcph server auth login <server>(see OAuth login).
primary: optionaltruefor the server you are developing (at most one).
extends: optional list of the packs whose rules doctor uses: a directory orbuiltin:<name>(see Rules and packs). Without any pack there is no rule;builtin:corehas the rules that ship with mcph.doctor: optional settings formcph doctor.rules: how serious each rule is, asrule id: error | warn | off(see Configuring rules).
eval: optional settings formcph eval(see Evaluating a server).suites: the list of the suites to run, each with:name: unique; letters, digits,_and-.path: the suite file, with its tasks and checks, relative tomcph.yaml.target: the server the agent gets, orgateway(default: the only server, or the gateway when there are several).runners: the ways to run an agent for this suite, by name:preset: claude(withmodel,max_turns,max_budget_usd) or acommand, and atimeout.runner: the runner to use when nothing else says (default: the only one).matrix: the cells to run:runner,modelandtargetlists,excludeandinclude.repeat: how many times every task is run in each cell (default1), andpass_rate: the share of those runs that has to pass (default1, all of them). A task of the suite file may have its ownrepeatandpass_rate, which replace these for it.
stdio servers run from the directory containing mcph.yaml, with a minimal environment (HOME, PATH, ...) plus what env_file and env give them; the rest of your environment is not passed on. Unknown keys are rejected, so typos are reported.
Environment variables of a server
A stdio server starts with a minimal environment (HOME, PATH, ...), so your shell's variables, API keys included, do not reach it by themselves. The bearer token of an http server is a variable too. There are two ways to give a server what it needs, and you can use both.
From the environment mcph runs in, with ${NAME} in an env value (or in a token):
servers:
- name: orders
transport: stdio
command: uv
args: ["run", "python", "src/server.py"]
env:
LOG_LEVEL: WARNING # a plain value
API_KEY: ${API_KEY} # the variable API_KEY of the environment mcph runs in
DATA_DIR: ${HOME}/data # a variable can sit in other text
$ API_KEY=abc123 mcph doctor run
From a dotenv file, with env_file, so the secrets never touch mcph.yaml. Every server has files of its own, and an http server with a bearer token can have one too:
- name: orders
# ...
env_file: .env # or a list of files: [base.env, local.env]
- name: docs
transport: http
url: https://docs.example.com/mcp
env_file: docs.env # the variables that ${...} in the token may use
auth: {type: bearer, token: "${DOCS_TOKEN}"}
# .env (keep it out of Git)
API_KEY=abc123
LOG_LEVEL=DEBUG
${NAME}is replaced by the variableNAMEof the environment mcph runs in and, if that does not have it, by the variableNAMEof theenv_filefiles of the entry. It can sit in other text (Bearer ${TOKEN}),$$is a literal$, and a variable that is set nowhere is an error that names it and the files that were looked in. Values are never printed. In YAML's{...}style, put the value in quotes:env: {API_KEY: "${API_KEY}"}.env_fileis a path, or a list of paths, relative to the directory ofmcph.yaml(~and absolute paths work). It uses dotenv syntax (KEY=value,#comments, quotes,export KEY=value) and nothing in it is expanded. It usually holds secrets, so keep it out of Git with.gitignore. It is read when the server starts (for anhttpserver, when mcph reads its token); a file that is missing is an error for that server.- The precedence is the one of Docker Compose. For
${...}the environment wins over the files: a key or a token that you export beats the one in.env, which is only used when the environment does not have the variable, so a stale.envcannot hide a new value. For astdioserver theenventries win over the variables of the files (asenvironment:wins overenv_file:in Compose), and a later file wins over an earlier one. A variable of a file thatenvdoes not name is passed on as it is. - An
httpserver has no process to give variables to: itsenv_fileonly holds what the${...}of its bearer token may use, so it is an error withoutauth: {type: bearer}. - This is for the servers in
mcph.yaml.mcph proxy -- <command>passes its own environment on to the server unchanged: give that server its variables in the client's ownenvsetting.
Metadata
Release files for mcph 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcph-0.4.0.tar.gz | 174.4 kB | With provenance | Details for mcph-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcph-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for mcph-0.4.0-py3-none-any.whl |
Total release size: 363.9 kB
Release files / mcph-0.4.0.tar.gz
| Download URL | mcph-0.4.0.tar.gz |
|---|---|
| Size | 174.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56955377ce36909d61ea29f4427421b54d4b3b8b01618b5180b746a4fe421c57
|
|
BLAKE2b-256 checksum How to use checksums |
6bedb6c308dfd0f8f7a654fe9b3ca5f96c2f1a7446a2cc8dcbc95210748b5441
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.
Transparency logRelease files / mcph-0.4.0-py3-none-any.whl
| Download URL | mcph-0.4.0-py3-none-any.whl |
|---|---|
| Size | 189.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
20e35afc29c6026e5f0402c7645178c44c52f54d37e95972612f17b700c33b25
|
|
BLAKE2b-256 checksum How to use checksums |
2ae6528beeb4f9ef09e53229cafcc3fbfc25899cd17ab3b20e874957a8c57a25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.
Transparency logSecurity for mcph 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mcph-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.