A PTY runner for MCP
Project description
pty-mcp
A lightweight PTY runner for MCP (Model Context Protocol).
pty-mcp provides terminal session tools over MCP so clients can spawn commands in a pseudo-terminal, read interactive output, send input, resize terminal windows, and manage process lifecycle safely.
Features
- Spawn shell commands in a real PTY
- Read incremental output from a ring buffer
- Wait for pattern matching (
read_until) - Wait for any pattern (
read_until_any) - Send interactive input (
write) - Send input and wait for prompt (
prompt) - Resize terminal (
cols/rows) - Process control (
status,wait,signal,close) - Stream split reads (
read_stdout,read_stderr) - Read with offset (
read_at) - Session tags (
tag,owner) - Dynamic defaults (
set_default_cwd) - Runtime limits (
set_limits) - Metrics and health (
metrics,health)
Requirements
- Python 3.10+
Installation
pip install pty-mcp
CLI Entrypoint
After installation, the package exposes:
pty-mcp
This starts the MCP server over stdio.
MCP Tools
pty_spawnpty_readpty_read_stdoutpty_read_stderrpty_read_atpty_read_untilpty_read_until_anypty_promptpty_writepty_resizepty_closepty_close_allpty_statuspty_waitpty_signalpty_listset_default_cwdget_default_cwdset_limitsget_limitspty_metricspty_health
New Parameters
pty_spawn
cwd— working directoryseparate_streams— split stdout/stderr into separate bufferstag,owner— session labels for filteringscope—read-onlyorread-writemax_output_bytes— ring buffer capspawn_timeout_sec— session runtime caprate_limit_bps— output rate limitinput_rate_bps— input rate limitread_timeout_ms— default read timeout per sessionenv— per-session environment overrides
pty_read / pty_read_stdout / pty_read_stderr
format—jsonortext(default)
Examples
Set default cwd
{"name":"set_default_cwd","arguments":{"cwd":"/root/aa"}}
Spawn with stream split
{"name":"pty_spawn","arguments":{"command":"ls","separate_streams":true}}
Read stdout only
{"name":"pty_read_stdout","arguments":{"session_id":"..."}}
Wait for any prompt
{"name":"pty_read_until_any","arguments":{"session_id":"...","patterns":["OK","ERROR"]}}
Prompt helper
{"name":"pty_prompt","arguments":{"session_id":"...","data":"y\n","patterns":["done","error"]}}
Notes
- PTY sessions are in-memory and have idle timeout cleanup.
- The server is intended for local trusted environments.
separate_streams=truemakes stdout/stderr non-tty (some commands may change output).- If
commandis an absolute path, cwd is inferred from its directory.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 pty_mcp-0.1.8.tar.gz.
File metadata
- Download URL: pty_mcp-0.1.8.tar.gz
- Upload date:
- Size: 57.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f5f8f25f3c756e0ef29b2d673233a75000e1a0cb8af5d895df11d9af7f334da
|
|
| MD5 |
f869a92c693e2f01de243fee958a589b
|
|
| BLAKE2b-256 |
e3975fe176b714db1ec7c1972ee8c736fb5e03b88db36928485e6804d0fa3af7
|
File details
Details for the file pty_mcp-0.1.8-py3-none-any.whl.
File metadata
- Download URL: pty_mcp-0.1.8-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fea886552890d446309b969351075d1c906097fb9c39bef5502a3837f9f3066
|
|
| MD5 |
4be89614df70458d9cc0956c32d7e7db
|
|
| BLAKE2b-256 |
2315466bc839e5492bbe733ecab2ad330588cca487dd8c5c7864d89f417204ff
|