Skip to main content

mcph

Coverage

MCP Harness: diagnostics, real-client proxy and LLM-as-a-judge evals for MCP servers.

Early development: only mcph doctor does real work so far.

Install

pip install mcph    # Python 3.12+
uvx mcph --help     # or run it without installing

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:
      LOG_LEVEL: WARNING
  - name: docs
    transport: http
    url: http://localhost:8080/mcp
    auth:                      # optional: send a bearer token
      type: bearer
      token_env: DOCS_TOKEN    # name of an environment variable holding the token

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 auth login, status, logout Signs in to an http server that uses OAuth through the browser, shows who is logged in, and signs out again.
mcph version Prints the installed version.
mcph proxy, mcph eval Placeholders, not implemented yet: proxy is planned for 0.3.0 and eval for 0.4.0.

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|oauth picks the starter: one stdio server (the default), a stdio server plus an http server with a bearer token from an environment variable, or an http server that signs in with OAuth. --server-cmd "uv run python src/server.py" sets how the stdio server starts (split like a shell would). --extend SOURCE (repeatable) replaces the default builtin:core, so add --extend builtin:core to keep the core rules next to a pack of your own. --force overwrites an existing mcph.yaml. init writes DIRECTORY/mcph.yaml, so the global -c does not apply to it.
  • -c, --config PATH selects the config file (default ./mcph.yaml). It goes before the command: mcph -c other.yaml doctor run.
  • mcph doctor run --timeout SECONDS limits how long each server may take to start and answer (default 30).
  • mcph doctor run --strict also fails on warnings, which is handy in CI.
  • mcph doctor run exits with 0 if all servers are OK, 1 if a server failed (or, with --strict, if there are warnings), 2 if 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 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 doctor run then uses the stored token. It is an access token that usually expires after a few minutes; when it has, doctor tells you to log in again. mcph auth status shows who is logged in and when each token expires, and mcph auth logout docs deletes the token. For CI use a bearer token from an environment variable instead.

Tokens are kept in a file only you can read, under mcph's state directory (set MCPH_STATE_DIR to put it elsewhere). mcph does not keep refresh tokens.

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.

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 of mcph.yaml), snapshot (what the server exposes: server_name, server_version, protocol_version, startup_seconds and tools; None if mcph could not connect), error (why it could not), timeout, and a cache shared by the rules that check one server.
  • Each tool in snapshot.tools is described as the server sent it: name, title and description (each may be None), input_schema (the JSON Schema of the arguments, a dict), output_schema (a dict, or None) and annotations with title, read_only_hint, destructive_hint, idempotent_hint and open_world_hint, each None when the server did not say. Do not change what you receive: every rule of a server sees the same objects. (ServerSnapshot and ToolInfo are in mcph.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 (from mcph.rules) to choose the severity per problem. It may be async, and it may raise SkipRule("why") (from mcph.rules) when there is nothing to check.
  • @doctor_rule also takes transports=["http"] for a rule that only applies to HTTP servers (the default is both kinds), and needs_connection=False for 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 mcph and installed packages but not the other files of the pack.
  • The Python of a pack runs with your privileges, like the command of a stdio server 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 code 1).
  • warn: findings are warnings, which fail the run only with --strict.
  • off: the rule does not run, and the report lists it as OFF. Write it without quotes if you like: YAML reads off as 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: stdio or http.
    • command, args, env (stdio): how to start the server.
    • url (http): the Streamable HTTP endpoint of a server you have already started, such as http://localhost:8080/mcp. mcph does not start it.
    • auth (http, optional), one of:
      • type: bearer and token_env, the name of an environment variable that holds a bearer token. mcph reads the token from its own environment, never from the YAML, and sends it as Authorization: Bearer ... to the server's URL only; it is never printed.
      • type: oauth, optional scopes and optional ignore_issuer_trailing_slash: sign in through the browser with mcph auth login <server> (see OAuth login).
    • primary: optional true for the server you are developing (at most one).
  • extends: optional list of the packs whose rules doctor uses: a directory or builtin:<name> (see Rules and packs). Without any pack there is no rule; builtin:core has the rules that ship with mcph.
  • doctor: optional settings for mcph doctor.
    • rules: how serious each rule is, as rule id: error | warn | off (see Configuring rules).

stdio servers run from the directory containing mcph.yaml, with a minimal environment (HOME, PATH, ...) plus the env you list. Unknown keys are rejected, so typos are reported.

Metadata

Release files for mcph 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcph 0.2.0
File Size Uploaded Provenance Actions
mcph-0.2.0.tar.gz 51.6 kB With provenance Details for mcph-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mcph 0.2.0
File Interpreter ABI Platform Actions
mcph-0.2.0-py3-none-any.whl Python 3 none any Details for mcph-0.2.0-py3-none-any.whl

Total release size: 107.7 kB

Release files / mcph-0.2.0.tar.gz

Download URL mcph-0.2.0.tar.gz
Size 51.6 kB
Tags Source
SHA-256 checksum
How to use checksums
54b2c327dc536f8d026062f0cdf6a02b501fc92668ca189ba9132efbf78f647d
BLAKE2b-256 checksum
How to use checksums
95dd12258df38eee3da095407b09054b7d716ac070b05c6cbafa1cdcc665b0de
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 Nov 30, 2026.

Transparency log

Release files / mcph-0.2.0-py3-none-any.whl

Download URL mcph-0.2.0-py3-none-any.whl
Size 56.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e27e5ff52df0c0ef19aa9ebaa6be6f8e49341c9211e18a2f87262d86138ec43
BLAKE2b-256 checksum
How to use checksums
771b248c5c32d70afa97aecde17a30cecaab70f27f7712ed85ac2f5ed9fe81ff
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 Nov 30, 2026.

Transparency log

Security for mcph 0.2.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.

Select from 2 files

Attestation for mcph-0.2.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 Nov 30, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page