DE

Depyler MCP Server: Energy-Efficient Python-to-Rust with Progressive Verification

Convert Python to safe, performant Rust with the Depyler MCP server using progressive verification to cut energy use by 75–85%.

Quick Install
npx -y @docs/mcp-integration.md

Overview

The Depyler MCP Server provides a developer-friendly service for converting Python code to memory-safe, high-performance Rust while minimizing verification energy costs. It exposes Depyler’s translation and verification capabilities over a lightweight Model Context Protocol (MCP) endpoint so tools and LLM-driven workflows can request translation, incremental verification, and compiled outputs programmatically.

A key innovation is progressive verification: Depyler performs fast, low-cost checks first and escalates to more thorough proofs only when needed. This staged approach reduces total CPU and verification effort, which in practice cuts energy use substantially (reported reductions on the order of 75–85% versus always-running full verification). The MCP server is useful for migration tooling, CI pipelines, notebooks, and interactive developer assistants that demand responsiveness and energy efficiency.

Features

  • Convert Python functions/modules to idiomatic, safe Rust
  • Progressive verification: fast initial checks with optional deeper verification
  • HTTP/JSON MCP endpoint for programmatic integration
  • Configurable verification timeouts and verification levels
  • Outputs: Rust source, compile artifacts, verification reports
  • Integrates with CI and LLM-based developer tooling
  • Lightweight, runnable locally or in CI containers

Installation / Configuration

Minimal steps to get the MCP server running locally. Adjust commands to match your environment (virtualenv, container, or system Python).

Clone and install (editable mode for development):

git clone https://github.com/paiml/depyler.git
cd depyler
python -m venv .venv
source .venv/bin/activate
pip install -e .

Start the MCP server with a config file:

# example: start server using Python module entrypoint
python -m depyler.mcp.server --config ./configs/mcp-server.yaml

Example config (configs/mcp-server.yaml):

host: 127.0.0.1
port: 8080
workers: 4
model_path: ./models/translation-model
progressive_verification: true
verify_levels:
  - quick
  - full
verify_timeout_seconds: 60
log_level: info
output_dir: ./artifacts

Configuration options (summary):

OptionTypeDefaultDescription
hoststring127.0.0.1Bind address
portint8080HTTP port
workersint4Concurrent request handlers
model_pathstringPath to any translation/checker models
progressive_verificationboolfalseEnable staged verification
verify_levelslistOrdered verification stages
verify_timeout_secondsint60Per-request verification timeout
output_dirstring./artifactsWhere to save generated files

Available Resources

  • Repository and source docs: https://github.com/paiml/depyler/blob/main/docs/mcp-integration.md
  • Example configs and sample workflows shipped in the repo (look under docs/ and examples/)
  • Issue tracker and contributions: GitHub Issues/PRs on the main repo
  • Local artifacts: compiled Rust output, verification logs, and reports saved to output_dir

Using the MCP Endpoint (Examples)

A typical interaction is an HTTP POST to the MCP endpoint with a JSON payload describing the tool action and code to translate.

Example request (curl):

curl -X POST http://127.0.0.1:8080/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "depyler.translate",
    "input": "def add(a, b):\\n    return a + b",
    "options": {
      "emit": ["rust", "verification_report"],
      "verify_mode": "progressive"
    }
  }'

Example (simplified) response:

{
  "status": "ok",
  "outputs": {
    "rust": "pub fn add(a: i64, b: i64) -> i64 { a + b }",
    "verification_report": {
      "stage": "quick",
      "result": "verified",
      "notes": "Quick checks passed; full verification optional"
    }
  },
  "artifacts": ["./artifacts/add.rs", "./artifacts/add_report.json"]
}

Error handling: responses include an error field with diagnostics and any verifier logs to help triage failures or unsupported Python patterns.

Use Cases

  • Migrating numeric kernels: Translate compute-heavy Python numeric loops to Rust for performance while using progressive verification to avoid long verification runs during early development.
  • CI safety gates: Run quick verification on PRs to catch common errors; escalate to full proofs only for mainline merges or release branches to save energy.
  • Interactive developer assistants: LLM-powered tools can request a fast translation and a lightweight verification report, yielding quick feedback during refactor cycles.
  • Edge deployments: Convert critical code paths to Rust and run the minimal required verification to meet certification or safety constraints without constantly consuming high compute resources.

For more examples and detailed integration patterns, see the project docs and examples folder in the GitHub repository.