
The ultimate harness agent tool. A headless, in-memory terminal emulator for AI agents, exposed via MCP (Model Context Protocol).
NPCterm gives AI agents full terminal access. The ability to spawn shells, run arbitrary commands, read screen output, send keystrokes, and interact with TUI applications. This is one of the most powerful capabilities you can grant an AI agent: it is effectively equivalent to giving it access to a computer.
Use with precautions. A terminal is an unrestricted execution environment. Any command the agent can type, the system will run. This includes installing software, modifying files, accessing the network, and anything else a shell user can do. Deploy NPCterm in sandboxed or controlled environments, and always apply the principle of least privilege. Do not expose it to untrusted agents without appropriate safeguards.

Full system monitoring with btop, launched, read, and navigated entirely by an AI agent through MCP tools.
portable-pty2024-11-05, 2025-06-18, or 2025-11-25 spec versionscargo install npcterm
Installs the binary and auto-configures it for every MCP client detected: Claude Code, Claude Desktop, Codex, OpenCode, OpenClaw.
curl -fsSL https://raw.githubusercontent.com/alejandroqh/marketplace/main/h39.sh | bash
Pre-built binaries are available in the dist/ directory for:
Download the binary for your platform and place it somewhere in your PATH.
cargo build --release
The binary will be at target/release/npcterm.
Add to your MCP client config:
{
"mcpServers": {
"npcterm": {
"command": "npcterm"
}
}
}
NPCterm is an MCP server. It communicates over stdin/stdout using JSON-RPC. To use it, configure it as an MCP server in your AI agent's MCP configuration (see install instructions above).
| Tool | Description |
|---|---|
terminal_create |
Spawn a new terminal (80x24, 120x40, 160x40, or 200x50). Optional shell param to specify shell path |
terminal_destroy |
Destroy a terminal and its PTY |
terminal_list |
List all active terminals |
terminal_send_key |
Send a single keystroke |
terminal_send_keys |
Send a sequence of keystrokes |
terminal_mouse |
Send mouse events (click, scroll, drag) |
terminal_read_screen |
Read the screen with coordinate overlay (full or mode: "changes" for incremental reads) |
terminal_show_screen |
Read screen as plain text without coordinates |
terminal_read_rows |
Read specific rows from the screen |
terminal_read_region |
Read a rectangular region of the screen |
terminal_status |
Get terminal status, process state, and has_new_content flag |
terminal_poll_events |
Poll the event queue |
terminal_select |
Select text on screen |
terminal_scroll |
Scroll the terminal viewport |
viewer_start |
Start the web debug viewer (default port 8039, auto-probes if busy) |
viewer_stop |
Stop the web debug viewer |
viewer_open |
Open the debug viewer in the system browser (starts it if needed) |
// MCP Flow
// 1. Create a terminal
// -> terminal_create {}
// <- {"id": "a0", "cols": 80, "rows": 24}
// 2. Open vim
// -> terminal_send_keys {"id": "a0", "input": [{"text": "vim"}, {"key": "Enter"}]}
// <- {"success": true}
// 3. Read the screen to confirm vim is open
// -> terminal_show_screen {"id": "a0"}
// <- ~ VIM - Vi IMproved
// <- ~ version 9.2.250
// <- ~ by Bram Moolenaar et al.
// <- ~ type :q<Enter> to exit
// <- ...
// 4. Quit vim (the hard part, apparently)
// -> terminal_send_keys {"id": "a0", "input": [{"text": ":q"}, {"key": "Enter"}]}
// <- {"success": true}
// Back at the shell. First try.

NPCterm gives AI agents full TUI interaction: opening, navigating, and closing interactive programs like vim, htop, less, or any curses-based application.
NPCterm includes a built-in web-based debug viewer that lets you watch your agent work in real time. Start it on-demand with the viewer_start MCP tool or open it directly in your browser with viewer_open.

The viewer provides:
viewer_start and open your browser.viewer_start (default port 8039), stop with viewer_stop, or let viewer_open handle both starting and opening the browser in one call. If the default port is taken, it automatically tries the next 10 ports.The viewer is especially useful for:
Video coming soon
TurboMCP Server (stdio JSON-RPC)
|
NpcTermServer (17 #[tool] methods)
|
TerminalRegistry (concurrent terminal management)
|
TerminalInstance (emulator + mouse + selection + events)
|
TerminalEmulator (PTY spawn, I/O threads, grid)
|-- TerminalGrid (screen buffer, scrollback, dirty tracking)
| '-- AnsiHandler (VTE parser)
|-- TerminalCell (character + style attributes)
'-- PTY (portable-pty)
The MCP layer is powered by TurboMCP 3.0, which handles JSON-RPC protocol framing, tool schema generation, and request dispatch. Each terminal spawns a background PTY reader thread. A global tick thread (10ms interval) drains PTY output through the VTE parser, detects process state changes, and emits events.
Features designed for efficient, long-running AI agent workflows:
terminal_read_screen with mode: "changes" returns only new output since the last read, capped to max_lines (default 50, max 200). No need to re-read the entire screen after every command.has_new_content flag -- terminal_status includes a boolean flag so agents can skip screen reads entirely when nothing changed. Cheap polling without wasting tokens.terminal_read_screen adds column/row headers so agents can target specific cells with terminal_read_region or terminal_select without manual counting.terminal_show_screen returns raw screen content without coordinates, ideal for piping output to other tools or summarization.Running, Idle (no output >500ms), WaitingForInput (shell prompt detected), Exited (with exit code). Agents know exactly when a command finishes and the shell is ready for the next one.terminal_poll_events drains events like CommandFinished, WaitingForInput, Bell, ProcessStateChanged, and ScreenChanged (with row indices). Build event-driven agents instead of blind polling loops.shell: "/bin/zsh", shell: "/usr/local/bin/fish", or any path to terminal_create. Defaults to the system shell if omitted.a0, b3) minimize token overhead vs UUIDs.viewer_start launches a browser-based UI showing real-time terminal output with cursor position, process state, and full color rendering.viewer_start, viewer_stop, viewer_open). Default port 8039, auto-probes next 10 ports if busy.Ported from project term39
NPCterm provides unrestricted shell access to whatever agent connects to it. Before deploying:
Apache 2
$ claude mcp add npcterm \
-- python -m otcore.mcp_server <graph>