interactive-process-mcp
The interactive-process-mcp server enables AI agents to start, control, and interact with long-running terminal processes via SSE over HTTP transport (allowing agents and server to run on different machines).
Start processes (
start_process): Launch any command in PTY (full terminal emulation) or pipe mode, with configurable working directory, environment variables, terminal size, and startup timeout.Send input (
send_input): Write text to a running process's stdin, optionally appending a newline.Read output (
read_output): Retrieve new output since the last read, with configurable timeout, line limits, and optional ANSI escape code stripping.Atomic send & read (
send_and_read): Combine sending input and reading the response in a single operation — ideal for SSH sessions or REPLs.List & inspect sessions (
list_sessions,get_session_info): View all active/past sessions and retrieve metadata (status, PID, exit code, command, timestamps).Terminate processes (
terminate_process): Stop a process gracefully (SIGTERM) or forcefully (SIGKILL) with a configurable grace period.Resize terminal (
resize_pty): Dynamically adjust PTY dimensions (rows/columns) for terminal-aware programs liketoporhtop.Multi-agent collaboration (
register_reader,unregister_reader): Multiple agents can independently read output from the same session, each maintaining its own output cursor.Session persistence (
list_messages,get_message): Sessions and I/O are stored to local JSON files, enabling message history retrieval for auditing or debugging.Cleanup: Delete exited sessions to free resources.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@interactive-process-mcp start an SSH session to user@host"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
interactive-process-mcp
Introduction
interactive-process-mcp is an MCP (Model Context Protocol) server that enables AI Agents (like Claude Code) to start, control, and manage long-running interactive processes.
Why Do You Need It?
AI Agents can natively only execute one-shot commands — they run and immediately return results. But many real-world scenarios require multi-turn interaction:
SSH into a remote server, enter a password first, then run commands
Debug code line by line in a Python REPL
Answer
[Y/n]prompts in interactive installersUse terminal-dependent commands like
top,htopRun security tools (e.g., impacket) for multi-step operations
In these scenarios, the process keeps running, and the AI Agent needs to repeatedly read and write the process's I/O across multiple conversation turns. interactive-process-mcp is the bridge designed precisely for this purpose.
Key Features
Feature | Description |
Multi-agent session sharing | Multiple AI agents read from the same session simultaneously, each with an independent cursor — no output stealing |
PTY and Pipe dual mode | PTY mode emulates a real terminal; Pipe mode for simple stdin/stdout interaction |
Remote deployment | SSE over HTTP transport — Agent and Server can run on different machines |
Multi-session management | Manage multiple independent processes simultaneously without interference |
Message persistence | Session records and I/O messages persisted to local JSON files |
ANSI escape code stripping | Optional automatic removal of terminal control sequences for clean text output |
Blocking reads with timeout | Agents wait for new output up to a configurable timeout; returns promptly via sync.Cond |
Atomic send-and-read |
|
Graceful termination | SIGTERM first, then SIGKILL after a configurable grace period |
PTY resize | Dynamically adjust terminal rows and columns at runtime |
Session cleanup | Delete exited sessions to prevent resource accumulation |
Related MCP server: MCP Shell Server
Architecture
┌──────┐ SSE/HTTP ┌──────────────┐ Internal SSH ┌──────────┐
│Agent │ ──────────> │ Go Server │ ──────────────> │ PTY/ │
│(MCP) │ │ - MCP API │ (localhost) │ Process │
└──────┘ │ - SSH Server │ └──────────┘
└──────────────┘
│
▼
┌──────────────┐
│ JSON Storage │
│ - sessions │
│ - messages │
└──────────────┘Project Structure
.
├── cmd/server/main.go # Entry point
├── internal/
│ ├── config/config.go # Configuration with validation
│ ├── mcp/
│ │ ├── server.go # MCP SSE server & tool registration
│ │ └── handlers.go # 13 tool handlers
│ ├── sshserver/server.go # Internal SSH server (gliderlabs/ssh)
│ ├── sshclient/client.go # Internal SSH client (crypto/ssh)
│ ├── session/
│ │ ├── session.go # Session lifecycle (goroutine-safe)
│ │ └── manager.go # Thread-safe session registry
│ ├── buffer/buffer.go # Multi-reader ring buffer (1MB per reader)
│ ├── storage/store.go # Atomic JSON file persistence
│ ├── message/message.go # Message management (per-session mutex)
│ └── ansi/strip.go # ANSI escape code removal
├── pkg/api/types.go # Public types (Session, Message, SessionMode)
├── go.mod
└── go.sumKey Design Decisions
Multi-Reader Ring Buffer: Each agent registers as an independent reader with its own
ringbuffer.RingBufferinstance. Writes broadcast to all readers. Slow readers lose oldest data (overwrite mode) rather than blocking the writer.Internal SSH Architecture: The server starts a gliderlabs/SSH server on localhost. Each
start_processcreates an SSH session via crypto/ssh client, leveraging SSH's mature PTY allocation, window resize, signal forwarding, and environment variable passing.SSE over HTTP Transport: Unlike traditional stdio-based MCP servers, this server exposes an HTTP endpoint supporting MCP SSE transport. Agents connect remotely, enabling cross-machine deployment.
Atomic JSON Persistence: Session metadata and I/O messages are stored via temp-file + fsync + rename, preventing half-written files on crash:
data/sessions.json— Session listdata/messages/{session_id}/index.json— Message indexdata/messages/{session_id}/messages/{msg_id}.json— Message content
Session Lifecycle Safety: Exit goroutine is the single authority for
Status/ExitCode(viasync.Once). Terminate is idempotent. Stdin writes are serialized via a dedicated mutex.
Examples
Example 1: SSH Remote Operations
AI Agent Flow Process Output
───────────────── ────────────────
start_process(
command="ssh",
args=["deploy@192.168.1.100"],
mode="pty"
)
← "deploy@192.168.1.100's password: "
send_and_read(
text="my_secret_pass",
press_enter=true
)
← "Welcome to Ubuntu 22.04 LTS
deploy@web-server:~$ "
send_and_read(
text="df -h",
press_enter=true
)
← "Filesystem Size Used Avail Use% Mounted on
/dev/sda1 100G 45G 55G 45% /
deploy@web-server:~$ "
terminate_process(session_id="abc123")Example 2: Python REPL Debugging
start_process(command="python3", mode="pty")
← "Python 3.10.12\n>>> "
send_and_read(text="data = [1, 2, 3, 4, 5]", press_enter=true)
← ">>> "
send_and_read(text="sum(data)", press_enter=true)
← "15\n>>> "Example 3: Multi-Agent Collaboration
# Agent A starts a monitoring process
start_process(command="top", mode="pty")
→ session_id: "sess-001"
# Agent B joins the same session without stealing output
register_reader(session_id="sess-001")
→ reader_id: 2
# Agent A reads its own cursor
read_output(session_id="sess-001", reader_id=1)
→ "PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND..."
# Agent B reads from the beginning independently
read_output(session_id="sess-001", reader_id=2)
→ "top - 14:32:10 up 3 days, 2:15, 1 user, load average: 0.52, 0.58, 0.59..."
# Agent B is done
unregister_reader(session_id="sess-001", reader_id=2)
# Agent A terminates the session
terminate_process(session_id="sess-001")
delete_session(session_id="sess-001")Example 4: Multi-session Parallel Management
start_process(command="ping", args=["-c", "5", "google.com"], name="ping-test")
→ session_id: "a1b2c3"
start_process(command="python3", args=["-m", "http.server", "8080"], name="web-server")
→ session_id: "d4e5f6"
list_sessions()
→ [{id: "a1b2c3", status: "running"}, {id: "d4e5f6", status: "running"}]
read_output(session_id="a1b2c3") → ping statistics
terminate_process(session_id="a1b2c3")
terminate_process(session_id="d4e5f6")Tool Reference
start_process
Start an interactive process.
Parameter | Type | Required | Default | Description |
| string | Yes | — | Command to execute |
| string[] | No |
| Command arguments |
| "pty" | "pipe" | No |
| I/O mode |
| string | No | Auto-generated | Session name |
| integer | No |
| PTY row count (1–1000) |
| integer | No |
| PTY column count (1–1000) |
Returns: { session_id, pid, initial_output }
send_input
Send text to a process.
Parameter | Type | Required | Default | Description |
| string | Yes | — | Session ID |
| string | Yes | — | Text to send |
| boolean | No |
| Whether to append a newline |
read_output
Read new output since the last read for the given reader.
Parameter | Type | Required | Default | Description |
| string | Yes | — | Session ID |
| integer | No |
| Reader ID (0 = default) |
| boolean | No |
| Strip ANSI escape codes |
| number | No |
| Wait time in seconds (0.1–60) |
| integer | No |
| Max lines (0 = unlimited) |
Returns: { output, has_more, lines_returned, bytes_returned }
send_and_read
Atomic operation: send input + wait + read output. Parameters are the union of send_input and read_output.
list_sessions
List all sessions. Returns: { sessions: [...] }
get_session_info
Get session details. Returns: { id, name, command, args, mode, status, exit_code, pid, created_at }
terminate_process
Terminate a process.
Parameter | Type | Required | Default | Description |
| string | Yes | — | Session ID |
| boolean | No |
| Use SIGKILL directly |
| number | No |
| Seconds to wait after SIGTERM (0–60) |
delete_session
Remove an exited session from the registry.
Parameter | Type | Required | Default | Description |
| string | Yes | — | Session ID |
resize_pty
Resize PTY dimensions (PTY mode only).
Parameter | Type | Required | Default | Description |
| string | Yes | — | Session ID |
| integer | No |
| Row count |
| integer | No |
| Column count |
register_reader
Register a new independent reader for a session.
Parameter | Type | Required | Default | Description |
| string | Yes | — | Session ID |
Returns: { reader_id }
unregister_reader
Unregister a reader to free resources.
Parameter | Type | Required | Default | Description |
| string | Yes | — | Session ID |
| integer | Yes | — | Reader ID |
list_messages
List the message index for a session.
Parameter | Type | Required | Default | Description |
| string | Yes | — | Session ID |
Returns: { messages: [{id, type, created_at, byte_size}, ...] }
get_message
Get the content of one or more messages.
Parameter | Type | Required | Default | Description |
| string | Yes | — | Session ID |
| string[] | No | — | Message IDs to retrieve |
Returns: { messages: [{id, session_id, type, content, created_at, byte_size}, ...] }
Installation
Build from source
go build -o server ./cmd/serverRequirements: Go >= 1.21 / macOS or Linux
Run
./server --host 127.0.0.1 --port 8080 --data-dir ./dataOptions:
Flag | Default | Description |
|
| HTTP server host |
|
| HTTP server port |
|
| JSON storage directory |
|
| Internal SSH server host |
|
| Internal SSH server port |
Configuration
Claude Code
In .claude/settings.json or .mcp.json:
{
"mcpServers": {
"interactive-process": {
"type": "sse",
"url": "http://your-server:8080/sse"
}
}
}Or via CLI:
claude mcp add --transport sse interactive-process http://localhost:8080/sseOther MCP Clients
Any MCP client that supports SSE transport can connect to http://<host>:<port>/sse.
Community
linux.do — Chinese tech community
License
MIT
Available Tools
8 toolsget_session_infoB
Get detailed information about a session.
Args: session_id: The session ID to query.
Inputs: session_id (required).
list_sessionsB
List all interactive process sessions.
Inputs: no named parameters.
read_outputA
Read new output from an interactive process since last read.
If no new output is available, waits up to timeout seconds. Returns empty output on timeout (not an error).
Args: session_id: The session ID returned by start_process. strip_ansi: Remove ANSI escape codes from output. Default True. timeout: Seconds to wait for new output. Default 5. max_lines: Max lines to return (0 = unlimited).
Inputs: session_id (required), strip_ansi, timeout, max_lines.
resize_ptyC
Resize the PTY terminal dimensions for a session.
Only works in pty mode.
Args: session_id: The session ID. rows: New row count. cols: New column count.
Inputs: session_id (required), rows, cols.
send_and_readA
Send input to a process and immediately read its response.
Atomic operation: sends text, waits briefly, then reads new output.
Args: session_id: The session ID returned by start_process. text: Text to send. press_enter: Append newline after text. strip_ansi: Remove ANSI escape codes. Default True. timeout: Seconds to wait for response. Default 5. max_lines: Max lines to return (0 = unlimited).
Inputs: session_id (required), text (required), press_enter, strip_ansi, +2 more.
send_inputA
Send text input to a running interactive process.
Args: session_id: The session ID returned by start_process. text: Text to send to the process stdin. press_enter: Whether to append a newline after the text.
Inputs: session_id (required), text (required), press_enter.
start_processA
Start an interactive process and return its session info.
Args: command: The command to execute. args: Command arguments. mode: I/O mode — "pty" (pseudo-terminal) or "pipe". Default "pty". name: Optional human-readable session name. cwd: Working directory for the process. env: Environment variables (dict of string key-value pairs). timeout: Process startup timeout in seconds. rows: PTY row count (pty mode only). cols: PTY column count (pty mode only).
Inputs: command (required), args, mode, name, +5 more.
terminate_processA
Terminate an interactive process.
Args: session_id: The session ID to terminate. force: Use SIGKILL instead of SIGTERM. Default False. grace_period: Seconds to wait after SIGTERM before SIGKILL. Default 5.
Inputs: session_id (required), force, grace_period.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a distinct and clear purpose: starting, listing, inspecting, sending input, reading output, resizing, and terminating sessions. No overlap or ambiguity.
All tool names follow a consistent verb_noun pattern in snake_case, such as start_process, read_output, and terminate_process. The naming is predictable and uniform.
With 8 tools, the set is well-scoped for managing interactive processes. It covers essential operations without being overwhelming or sparse.
The tool surface covers core lifecycle operations (start, interact, read, resize, terminate). Minor gaps exist, such as explicit process status checking, but overall it is comprehensive.
Maintenance
Related MCP Connectors
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
MCP server for building and testing AI agents with multi-model experimentation and insights.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that enables coding agents to execute and manage long-running shell commands asynchronously with capabilities for process monitoring, interaction, and lifecycle management.719 PyPI14MIT
- AlicenseBqualityCmaintenanceA secure MCP server for shell operations, terminal management, and process control, enabling AI assistants to safely execute commands and manage interactive sessions.13158 npm6MIT
- AlicenseAqualityDmaintenanceMCP server that gives AI agents real interactive terminal sessions for running REPLs, SSH, database clients, and any interactive CLI with clean text output and smart completion detection.791 npm20MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that enables AI agents to run fully interactive SSH sessions (via tmux) and execute commands like a human operator, with persistent sessions and multiple concurrent connections.6MIT