Skip to main content

mcp-plan-runner

An MCP proxy that lets a model run a whole plan of tool calls in one call.

A normal agent calls one tool, reads the result, decides, and calls the next tool. Each step costs a model turn, and every intermediate result goes into the context. With run_plan, the model writes the full plan once: calls, loops and conditions. The runner executes it next to the tools and returns only the final value.

It works with any MCP server. The servers need no changes.

Results

On a mail job with about 30 tool calls (read 27 threads in two mailboxes, then build one table), Claude Code with the plan runner needed 3 turns instead of 31 and cost 84% less (median 0.105 USD instead of 0.649), with the same answer totals. A rerun on the final code cost about the same (median 0.111 USD), but took 5 turns: Gmail's per-minute quota rejected some reads, and the model read them again in a second plan. On small jobs the saving is smaller. Details and all rounds: docs/benchmarks.md.

Quick start

You need uv. uvx downloads and runs the package from PyPI.

  1. Write a config file, for example ~/.config/mcp-plan-runner/config.json, with your servers (see Configuration and config.example.json).
  2. Add the runner to an MCP client, for example Claude Code:
claude mcp add plan-runner -- uvx mcp-plan-runner /abs/path/to/config.json

Other clients: the command is uvx and the arguments are mcp-plan-runner /abs/path/to/config.json. The runner talks MCP over stdio. pipx run mcp-plan-runner config.json works too.

From source:

git clone https://github.com/costas1379/mcp-plan-runner
cd mcp-plan-runner
uv sync
cp config.example.json config.json   # edit: your servers and allow list
uv run mcp-plan-runner config.json   # runs the proxy on stdio

Configuration

{
  "servers": {
    "mail": {"command": "uv", "args": ["run", "mail-mcp"], "env": {"TOKEN_FILE": "/path"},
             "cwd": "/path", "max_parallel": 1, "log": "/path/logs/mail.log"},
    "docs": {"url": "https://example.com/mcp"}
  },
  "allow_in_plans": ["mail.search", "mail.get_thread"],
  "schema_cache": true
}
Key Meaning
servers.<name> A stdio server (command, args, env, cwd) or an HTTP server (url). The name may not contain ..
max_parallel Calls in flight to this server (default 4). Use 1 for servers that cannot handle parallel calls.
log Stdio only: append the server's stderr to this file (mode 0600). A relative path starts from the folder the proxy runs in.
allow_in_plans Tools (exact names or fnmatch patterns) that may run in a plan although they are not marked read-only.
schema_cache true (default): learn output schemas, see Learned output schemas. A file path: keep them in that file. false: do not learn.

Tools

Tool Purpose
list_tools(query, server) Find tools. With a query, it returns the best matches (at most 15) with input and output schemas. Without a query and with more than 60 tools, it returns only the names, grouped by server.
call(tool, args) Call one tool and return its result as JSON. Use it to see an output shape.
run_plan(plan) Validate and run a plan. Returns ok, result, calls and a short trace.

Tool names are server.tool, for example mail.search.

The client sees only these three tools, however many tools the servers behind the proxy have. The model finds the tools it needs with list_tools and a query, so the schemas of hundreds of tools never go into its context. Above 60 tools, a list without a query gives only the names.

Learned output schemas

A model writes a plan in one go only when it knows the shape of each tool's result. Many MCP servers do not declare an outputSchema, so the model must first make a probe call to see the shape. To avoid that probe on later runs, the runner learns the shape:

  • Each time a tool without an output schema returns a result (from call or inside a plan), the runner reads the JSON types and keys of the result and adds them to what it saw before.
  • A key becomes a field name only after it was in 3 different results. A result that is the same as a recent one does not count again. Real field names (id, subject, next_page_token) repeat in every result. Most data used as keys (names, ids) does not, so it is not stored.
  • list_tools with a query shows the learned schema as output_schema, with "output_schema_learned": true. Any field in it may be missing in a result. A schema that the server declares always wins.
  • The schemas are kept in ~/.cache/mcp-plan-runner/schemas.json (or under $XDG_CACHE_HOME), file mode 0600 in a 0700 folder, so the next session starts with them. When a tool's input schema changes, its learned schema is dropped. To start again, delete the file.

What the cache file holds:

  • JSON types and field names that were in at least 3 results. Never values.
  • For a key seen fewer times: a hash of it and a count. The hash hides the key from someone who reads the file, but not from someone who guesses it.
  • An object is stored as a map, with no key names at all, when a key does not look like a field name (emails, dates, ids with two or more digits, keys longer than 32 characters or with more than three _ or -), when three or more keys hold objects of the same shape, or when more than 50 different keys never repeat.
  • Stable names that a tool uses as keys in every result, for example {"Alice": 3, "Bob": 5} for the same users each time, look like field names. They are stored after 3 different results.

Field names come from tool results, which can contain untrusted text (a web page, an email). A source that puts the same short key in 3 different results can get it into a learned schema, and the model reads it there. If your servers return text from untrusted sources and that matters to you, turn learning off.

To turn learning off, set "schema_cache": false in the config.

A plan

{"start": "find", "steps": {
  "find": {"call": "mail.search", "args": {"q": "invoice"},
           "next": [{"if": "length(find.messages) == `0`", "goto": "none"}, {"else": "read"}]},
  "read": {"for_each": "find.messages", "as": "m", "call": "mail.get_thread",
           "args": {"id": "{{m.thread_id}}"}, "parallel": 4, "retry": 2, "next": "out"},
  "out":  {"return": "read[].{subject: subject, from: from}"},
  "none": {"return": "'no invoices'"}}}

Step kinds:

  • call: one tool call.
  • for_each: one tool call for each item of a list, optionally in parallel. Gives a list. With "do": {"start", "steps"} instead of call, it runs a small sub-plan for each item (at most 2 levels deep).
  • paginate: calls a tool again with the cursor from the last page until there is no cursor. Gives one list.
  • return: ends the plan with a value.

Options: retry (0 to 5) tries a failed tool call again after 1 s, 2 s, 4 s ... (each try counts as a call); on_error is stop (default) or skip.

Flow: next is a step id or a list of if/goto branches with a final else. A branch may go back to an earlier step, for example to poll a status.

Expressions use JMESPath. In args, "{{expr}}" is replaced by the value. The full grammar is in the run_plan tool description, which the model reads.

Safety

  • A plan may only call tools that are marked read-only (readOnlyHint) or match allow_in_plans. Other tools are rejected before the plan runs. Call write tools on their own server, so that the normal approval prompt of your client applies. Note: readOnlyHint is the server's own claim. Only connect servers you trust, and prefer exact tool names in allow_in_plans over wildcards.
  • Hard limits stop runaway plans: maximum steps, maximum tool calls (each loop item counts), a timeout, and a maximum result size. A plan may lower these limits, never raise them. Sub-plan steps and calls count toward the same limits. The loop items of a whole run (all levels) are capped, and so are the calls in flight across the run.

To report a security problem, see SECURITY.md.

How it compares to code mode

Another way to cut tool-call turns is to let the model write code that calls the tools, and run that code in a sandbox (for example Cloudflare's "Code Mode"). Code is more flexible. A plan is less flexible, but it needs no sandbox, it can be checked before it runs (allowed tools, limits, structure), and every run gives a short, readable trace.

Benchmark your own servers

bench/bench.py runs the same task in headless Claude Code (claude -p) once per variant and run, and saves every run as stream-json so you can trace each tool call. Copy bench/spec.example.json, point each variant at an MCP config file (files named *.local.json are ignored by git), then:

uv run python bench/bench.py bench/my-spec.local.json --runs 3

Each run is a real, paid model session.

Tests

uv run pytest

Limits of version 0.1

  • Results are best when tools return structured output (outputSchema). For text results, the runner tries to parse JSON. Otherwise the step result is the text, and a plan cannot filter inside it. A learned schema cannot help with plain text. docs/server-guide.md lists what a server can add to work well in plans, with examples and a text to send to a server's maintainer.
  • Remote servers that need OAuth are not supported yet. Stdio servers and plain HTTP URLs work.

License

MIT

Metadata

Release files for mcp-plan-runner 0.1.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 mcp-plan-runner 0.1.0
File Size Uploaded Provenance Actions
mcp_plan_runner-0.1.0.tar.gz 22.3 kB With provenance Details for mcp_plan_runner-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mcp-plan-runner 0.1.0
File Interpreter ABI Platform Actions
mcp_plan_runner-0.1.0-py3-none-any.whl Python 3 none any Details for mcp_plan_runner-0.1.0-py3-none-any.whl

Total release size: 46.6 kB

Release files / mcp_plan_runner-0.1.0.tar.gz

Download URL mcp_plan_runner-0.1.0.tar.gz
Size 22.3 kB
Tags Source
SHA-256 checksum
How to use checksums
57067678790988854e7236b3e2885cc801f65735e53c30d283553032a2827711
BLAKE2b-256 checksum
How to use checksums
7de07d061992eec609156c69d64de4c09874d4b1e5559bc87c931ca203ed0f12
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 1, 2026.

Transparency log

Release files / mcp_plan_runner-0.1.0-py3-none-any.whl

Download URL mcp_plan_runner-0.1.0-py3-none-any.whl
Size 24.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de38ea026d7d6189e2cb9573f84506f59081f8971d694902ec46045d9d0febbc
BLAKE2b-256 checksum
How to use checksums
e4112dc591fca5cf6de24662027f2a6b03e1d2fe49b753b5e4419050761ff001
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 1, 2026.

Transparency log

Security for mcp-plan-runner 0.1.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 mcp_plan_runner-0.1.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 1, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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