Metadata-Version: 2.5
Name: trace2mcp
Version: 0.1.0
Summary: Compile successful AI-agent traces into reusable MCP workflows.
Project-URL: Homepage, https://huggingface.co/spaces/warenterprise/trace2mcp
Project-URL: Repository, https://huggingface.co/spaces/warenterprise/trace2mcp
Project-URL: Live demo, https://warenterprise-trace2mcp.static.hf.space
Author: War Enterprise
License: MIT
License-File: LICENSE
Keywords: agents,mcp,optimization,tracing,workflow
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Code Generators
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Provides-Extra: mcp
Requires-Dist: mcp<3,>=2.0.0; extra == 'mcp'
Provides-Extra: space
Requires-Dist: gradio<7,>=5.0; extra == 'space'
Description-Content-Type: text/markdown

# 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

```bash
pip install trace2mcp
```

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

```bash
pip install "trace2mcp[mcp]"
```

Python 3.10 or newer is required.

## Try it

```bash
trace2mcp inspect trace.json
trace2mcp compile trace.json --out build/my-workflow
trace2mcp benchmark trace.json --repetitions 3
```

Or use the Python API:

```python
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,
and a minimal MCP server skeleton. You provide the real tool implementations;
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:** writes and unknown operations are rejected unless
  explicitly allowed.
- **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](https://warenterprise-trace2mcp.static.hf.space)
or visit the [Hugging Face Space](https://huggingface.co/spaces/warenterprise/trace2mcp).

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 a research prototype. Review generated workflows and implement
authorization, validation, timeouts, and least-privilege access around real
tools before production use.

Licensed under the MIT License.
