Use Cases

Can I use Traverse with Python?

Yes. You can call Traverse capabilities from Python even though Traverse is written in Rust. The two practical approaches are calling the CLI as a subprocess or connecting to the MCP server from a Python MCP client. The capability contract is enforced on every call regardless of how you invoke it.

Option 1: CLI subprocess

The simplest approach is to call traverse capability run from Python using subprocess:

import subprocess, json

result = subprocess.run(
    ["traverse", "capability", "run", "calculate_price",
     "--input", json.dumps({"quantity": 10, "unit_price": 5.0})],
    capture_output=True, text=True
)
output = json.loads(result.stdout)

This works but adds subprocess overhead per call. It is fine for batch processing or occasional calls. For high-frequency use, the MCP server approach is better.

Option 2: MCP client

Start the Traverse MCP server once and connect from your Python code using any MCP client library. The MCP protocol communicates over stdio using JSON-RPC. Your Python process sends tools/call messages and reads responses. The server handles contract enforcement.

Option 3: Embed via Wasmtime

Python has Wasmtime bindings. If you want to embed WASM execution directly in Python without the Traverse runtime's full contract enforcement, you can load the capability binary yourself. You lose the contract validation layer, but it is an option for lightweight use cases.

What Python provides vs. what Traverse provides

  • Python handles your application logic, data pipelines, and ML workflows
  • Traverse handles business capability execution with contract enforcement
  • A common pattern: Python orchestrates, Traverse executes critical business rules

A native Python SDK is on the roadmap. See the roadmap for timing.