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.

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.1 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, and safe retries. 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.1.tar.gz (75.1 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.1-py3-none-any.whl (53.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: trace2mcp-0.2.1.tar.gz
  • Upload date:
  • Size: 75.1 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.1.tar.gz
Algorithm Hash digest
SHA256 24b4a4d389771282f81ee6129717c76c44e01e7d755436e9ab52d922c7aa5932
MD5 63dd1d70ed1c16e796376ef1aa9c89fa
BLAKE2b-256 fd099054df47a70bbe799be4a5d9fd316136f40cff2ad0b2b80ee6c66e4da529

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trace2mcp-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 53.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7136704c9ddae74f98ae8c621e697d3a8a6254411e5d3cb26c7a8c94d43d96b4
MD5 b8c999367cdf6183ba22a6c256123a28
BLAKE2b-256 2a0b787daa0c8fb0a58cf3b094ec8f4d74eb1b76605f8b59de56dcb17e4dd95e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page