Skip to main content

Trace2MCP

Teach once. Run forever.

Trace2MCP compiles a successful AI-agent tool-call trace into a deterministic, inspectable, MCP-ready workflow.

An agent can discover a useful procedure once. Trace2MCP then validates the trace, infers data dependencies, deduplicates safe reads, builds a directed acyclic graph (DAG), and identifies work that can run concurrently.

Install

pip install trace2mcp

To run generated MCP servers, install the optional MCP dependency:

pip install "trace2mcp[mcp]"

Python 3.10 or newer is required.

HOL Guard can optionally add a second runtime-policy decision before every managed handler call. Install it in an isolated environment and opt in explicitly:

pipx install hol-guard==2.2.125
$env:TRACE2MCP_HOL_GUARD_EXECUTABLE = (Get-Command hol-guard).Source

It remains disabled when that variable is unset. When enabled, an unavailable guard, error, timeout, malformed response, unknown action, denial, or review requirement prevents handler execution. HOL Guard is not bundled because its current MCP requirement conflicts with the MCP v2 extra used by Trace2MCP-generated servers.

Try it

trace2mcp demo
trace2mcp inspect trace.json
trace2mcp compile trace.json --out build/my-workflow
trace2mcp verify build/my-workflow/workflow.json
trace2mcp replay build/my-workflow/workflow.json --frozen
trace2mcp benchmark trace.json --repetitions 3

trace2mcp demo runs the complete offline path: teach, compile, verify, frozen replay, and a visible safety-gate example. It uses no model, API key, or network.

Or use the Python API:

from trace2mcp import compile_trace, load_trace

trace = load_trace("trace.json")
workflow = compile_trace(trace, allow_side_effects=False)

print(workflow.to_dict())

The compile command produces a portable workflow.json, inert handler stubs, unreviewed contract candidates, and a minimal MCP server skeleton. You provide and review the real implementations and contracts; observed trace outputs are never converted into executable code.

Why compile traces?

  • Lower orchestration overhead: reuse a discovered procedure instead of planning the same tool path on every run.
  • Dependency-aware execution: independent read-only calls can run in parallel.
  • Fail-closed safety: unknown and destructive operations are denied; consequential operations need a reviewed contract and explicit approval.
  • Auditability: tool calls, references, dependencies, and scheduling remain visible as portable JSON.
  • Provider-neutral design: the core compiler does not require a model or an API key.

Live demo

Use the free, browser-only Trace2MCP interactive demo or visit the Hugging Face Space.

The included demo uses synthetic outputs and recorded durations to explain the scheduler. Its speedup is educational, not a production performance claim.

Safety

Trace2MCP is an alpha research tool. Version 0.2.2 routes supported direct and nested capability calls through one dispatcher, verifies structure and integrity, enforces reviewed generated contracts and schemas, and runs local handlers with bounded concurrency, timeouts, safe retries, and an optional fail-closed runtime guard. It does not sandbox trusted Python handlers or provide distributed durability, live remote replay, or proof of semantic equivalence.

Licensed under the MIT License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trace2mcp-0.2.2.tar.gz (85.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trace2mcp-0.2.2-py3-none-any.whl (58.5 kB view details)

Uploaded Python 3

File details

Details for the file trace2mcp-0.2.2.tar.gz.

File metadata

  • Download URL: trace2mcp-0.2.2.tar.gz
  • Upload date:
  • Size: 85.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for trace2mcp-0.2.2.tar.gz
Algorithm Hash digest
SHA256 be8e2ed3ed8cc19ca514a43a5eccb8e70e82afcf39805d59f7dcfc8aeb908b9e
MD5 6dff93d62f5fe1121b7c08facfddb6d5
BLAKE2b-256 0390026e4f2dcc54c0d10a6eac8fca28101a14abc810497da54b9639e50407e3

See more details on using hashes here.

File details

Details for the file trace2mcp-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: trace2mcp-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 58.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for trace2mcp-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b03e51c7e7d9bdea9aa7c2eb5158e52bf52fc9d5f1bd0149904956a6485c483a
MD5 a2007636341e7acb09528f0cf2583dbb
BLAKE2b-256 9273356506e4c0bb06e85351acb1fcaf8e51693651611eb987c855120c7fa1bc

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

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