High-performance Python SDK for the vterm-rs PTY orchestrator
Project description
vterm-rs
The High-Performance Rust PTY Orchestrator for AI Agents.
vterm-rs is a state-aware terminal host built specifically for AI agents (and the humans who build them). It transforms the terminal from a "blind black box" into a State Machine that agents can inspect, reason about, and control fluently.
Why vterm-rs?
- Safety (Guardrails): Prevent "Infinite Log Floods" with
max_linesandmax_durationlimits. - Truth (State Machine): Don't guess if a command finished. Use
wait_untilandscreen_readto inspect the visual grid. - Fluent Fleet: Orchestrate multiple terminals atomically with the high-performance
batch()API. - Headless-First: Designed for CI/CD and AI backends, with optional
--visiblemode for debugging.
Quick Start (Python SDK)
import vterm_python
client = vterm_python.VTermClient()
# The "Fluent Fleet" way: Atomically set up your session
ops = [
client.spawn_op("Build", visible=True),
client.write_op(1, "cargo build<Enter>"),
client.wait_until_op(1, "Finished", timeout_ms=30000)
]
result = client.batch(ops)
print(f"Build status: {result['sub_results'][2]['status']}")
graph LR
Agent["AI agent<br/>(Claude/IDE/MCP)"]
Term["vterm.exe<br/>(PTY pool, vt100, reaper)"]
Shell["powershell.exe<br/>(your real shell)"]
Agent -- "NDJSON over named pipe" --> Term
Term -- "CommandResult" --> Agent
Term -- "ConPTY" --> Shell
Shell -- "bytes" --> Term
Why
Existing tools either capture command output (no interactivity, no signals, no TUI) or
embed a shell as a library (no real PTY semantics, no parity with what a user sees).
vterm-rs is neither — it's the actual terminal, scriptable.
What you can do that you couldn't before:
- Tell an agent "the build is hung, send Ctrl-C and try again" and have it work.
- Have an agent exit
vimfor you.:wq, problem solved. - Boot a microservice fleet — Redis, Postgres, three services, one log-tailer — in one command. Reap the whole tree with one disconnect.
- Run the same playbook headlessly in CI that you ran with visible windows locally.
Quickstart
# 1. Build
cargo build --release
# 2. Start the orchestrator (visible windows by default)
.\target\release\vterm.exe
# 2. Or start it headless, no windows ever appear
.\target\release\vterm.exe --headless
# 3. From another shell, drive it
.\tests\playbook_tests.ps1 -Headless
The protocol in 30 seconds
Every line on the pipe is one JSON command. Every command produces exactly one response.
Both sides may include a req_id for correlation.
// → request
{"req_id": 7, "type": "Spawn", "payload": {"title": "build", "visible": false}}
// ← response
{"req_id": 7, "status": "success", "duration_ms": 11, "id": 1}
Composite work uses Batch, which returns one aggregate response, not N+1 lines:
// → request
{"req_id": 8, "type": "Batch", "payload": {"commands": [
{"type": "ScreenWrite", "payload": {"id": 1, "text": "cargo build<Enter>"}},
{"type": "WaitUntil", "payload": {"id": 1, "pattern": "Compiling", "timeout_ms": 30000}},
{"type": "ScreenRead", "payload": {"id": 1}}
]}}
// ← response
{"req_id": 8, "status": "success", "duration_ms": 1247, "sub_results": [ … ]}
Full spec: docs/protocol.md.
Three ways to consume it
-
Python SDK & FastMCP Bridge (New!) Build custom MCP servers or automate terminal operations using the blazing fast Python PyO3 bindings.
pip install vterm-rs-python-mcp
import vterm_python from fastmcp import FastMCP mcp = FastMCP("vterm") client = vterm_python.VTermClient() @mcp.tool() def run_build() -> str: # Using the new atomic batch API ops = [ client.spawn_op("build", max_lines=500), client.write_op(1, "cargo build<Enter>"), client.wait_until_op(1, "Finished", timeout_ms=30000) ] res = client.batch(ops) return "Build triggered" if res["status"] == "success" else "Error"
-
Direct MCP Server (Plug-and-Play) Use it directly in your AI client (like Claude Desktop) without writing code.
{ "mcpServers": { "vterm": { "command": "vterm-mcp" } } }
-
Rust Native MCP Server For maximum performance, use the native Rust MCP binary.
cargo run --bin vterm-mcp
Examples: Explore the examples/python_sdk directory for typical DevOps and CI use cases.
Tests: To run the Python tests locally, navigate to vterm-python and run uv run maturin develop, followed by uv run ../tests/python_sdk/test_mcp.py.
-
Raw pipe. Connect, write JSON, read JSON. The PowerShell harness in
tests/playbook_tests.ps1is the canonical example. -
Skill manifest.
skill.tomldeclares each command as an AI skill — useful for non-MCP agents.
Project structure
See AGENTS.md for the layout, code style, and invariants you must respect
when editing.
Status
| Area | State |
|---|---|
| Windows + ConPTY | works |
| Python Bridge | works (v0.7.10, available via PyPI vterm-rs-python-mcp) |
| Linux / macOS | planned (v0.8.0) |
| Wire protocol | unstable, will be pinned at v1.0 |
| Test coverage | smoke (PowerShell) + Rust integration + Python FastMCP |
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vterm_rs_python_mcp-0.7.12.tar.gz.
File metadata
- Download URL: vterm_rs_python_mcp-0.7.12.tar.gz
- Upload date:
- Size: 127.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
310a96e153fcebc9fd4030a879e9c8444aff173409316213fe714cc16616ca3c
|
|
| MD5 |
0953bdeae437cf9ea086e2663081bbb5
|
|
| BLAKE2b-256 |
80b85b7dd4676a6a88cb571104485d4d375173ae88dc5c31766113fd90f7bb7f
|
Provenance
The following attestation bundles were made for vterm_rs_python_mcp-0.7.12.tar.gz:
Publisher:
pypi-publish.yml on margusmartsepp/vterm-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vterm_rs_python_mcp-0.7.12.tar.gz -
Subject digest:
310a96e153fcebc9fd4030a879e9c8444aff173409316213fe714cc16616ca3c - Sigstore transparency entry: 1394030632
- Sigstore integration time:
-
Permalink:
margusmartsepp/vterm-rs@8051a9499f70d535d88b994e70c7bc1e5dfde9f1 -
Branch / Tag:
refs/tags/v0.7.12 - Owner: https://github.com/margusmartsepp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@8051a9499f70d535d88b994e70c7bc1e5dfde9f1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file vterm_rs_python_mcp-0.7.12-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: vterm_rs_python_mcp-0.7.12-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 534.0 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb06fa6f678983e6f586b4ae9748ab4ed4ac1dca086d46463fa1a3f37bb37c5f
|
|
| MD5 |
cb397eaa3796a7fbc2dcf19f8d92aeeb
|
|
| BLAKE2b-256 |
52ac052045f694abd2f77c829607026830303f2f77f2d72864a7958fe513e855
|
Provenance
The following attestation bundles were made for vterm_rs_python_mcp-0.7.12-cp310-abi3-win_amd64.whl:
Publisher:
pypi-publish.yml on margusmartsepp/vterm-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vterm_rs_python_mcp-0.7.12-cp310-abi3-win_amd64.whl -
Subject digest:
bb06fa6f678983e6f586b4ae9748ab4ed4ac1dca086d46463fa1a3f37bb37c5f - Sigstore transparency entry: 1394030644
- Sigstore integration time:
-
Permalink:
margusmartsepp/vterm-rs@8051a9499f70d535d88b994e70c7bc1e5dfde9f1 -
Branch / Tag:
refs/tags/v0.7.12 - Owner: https://github.com/margusmartsepp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@8051a9499f70d535d88b994e70c7bc1e5dfde9f1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file vterm_rs_python_mcp-0.7.12-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: vterm_rs_python_mcp-0.7.12-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 479.0 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b48c5752d4fc51ea7a6bff600100394a61634336772211b8003d5c33550974e8
|
|
| MD5 |
f4155248ec26c3e037d31570688e957b
|
|
| BLAKE2b-256 |
6f66f33f488be21b78632a5a3977d0b4d14abaf33627464fe75329cb1fbcd626
|
Provenance
The following attestation bundles were made for vterm_rs_python_mcp-0.7.12-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
pypi-publish.yml on margusmartsepp/vterm-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vterm_rs_python_mcp-0.7.12-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
b48c5752d4fc51ea7a6bff600100394a61634336772211b8003d5c33550974e8 - Sigstore transparency entry: 1394030665
- Sigstore integration time:
-
Permalink:
margusmartsepp/vterm-rs@8051a9499f70d535d88b994e70c7bc1e5dfde9f1 -
Branch / Tag:
refs/tags/v0.7.12 - Owner: https://github.com/margusmartsepp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@8051a9499f70d535d88b994e70c7bc1e5dfde9f1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file vterm_rs_python_mcp-0.7.12-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: vterm_rs_python_mcp-0.7.12-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 431.9 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75bd5008d975fe61fcc9e8ba503a4f10a1a2cb20669ca6c5281f83bdc855c594
|
|
| MD5 |
6c7fa6645a5b40e745caee56b0665294
|
|
| BLAKE2b-256 |
9346db2c55a0b04a2b506e9d440316cfcd31e716bd8303bc41c33a07163226eb
|
Provenance
The following attestation bundles were made for vterm_rs_python_mcp-0.7.12-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
pypi-publish.yml on margusmartsepp/vterm-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vterm_rs_python_mcp-0.7.12-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
75bd5008d975fe61fcc9e8ba503a4f10a1a2cb20669ca6c5281f83bdc855c594 - Sigstore transparency entry: 1394030692
- Sigstore integration time:
-
Permalink:
margusmartsepp/vterm-rs@8051a9499f70d535d88b994e70c7bc1e5dfde9f1 -
Branch / Tag:
refs/tags/v0.7.12 - Owner: https://github.com/margusmartsepp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@8051a9499f70d535d88b994e70c7bc1e5dfde9f1 -
Trigger Event:
push
-
Statement type: