# smart-terminal

Gives an agent a persistent PTY shell: send commands, type keys, read output between steps. Useful when interactive tools stall on piped stdin.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 12
- Author: pungggi
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/pungggi/smart-terminal-mcp
- Updated: 2026-10-21
- HTML: https://affpapa.org/en/nevibecode/mcp/smart-terminal

## What it does

This server keeps a shell alive with `node-pty` instead of closing it after each call. The agent types a command, reads the reply, and carries on in the same folder with the same environment and background processes. Separate tools handle the awkward parts: `terminal_write` and `terminal_read` for prompts and REPLs, `terminal_wait` to pause until a pattern shows up, `terminal_watch` to return on a match, silence, timeout or exit.

Big output gets handled too. Passing `since` to `terminal_read` returns only new bytes from the buffer. `terminal_run_paged` walks long read-only output a page at a time, `terminal_diff` produces a unified diff between two runs, and `terminal_exec` trims oversized output to its head and tail. `terminal_retry` repeats a flaky command with bounded backoff.

On Windows the shell is picked in order: `pwsh.exe`, `powershell.exe`, `cmd.exe`. Linux and macOS use `$SHELL`, then `bash`, then `sh`. Up to 10 named sessions can run at once, with readable IDs like `calm-reef`. `terminal_run` starts a binary straight from `cmd + args` with `shell=false`, so anything relying on aliases or pipes has to go through `terminal_exec`.

## Requirements
- Needs: Node.js (commands run via npx)

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add smart-terminal -- npx -y smart-terminal-mcp
```

### Codex

**Platform CLI**
```bash
codex mcp add smart-terminal -- npx -y smart-terminal-mcp
```

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "smart-terminal": {
            "command": "npx",
            "args": [
                "-y",
                "smart-terminal-mcp"
            ]
        }
    }
}
```

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "smart-terminal": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "smart-terminal-mcp"
            ]
        }
    }
}
```

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add smart-terminal npx -y smart-terminal-mcp
```

## When to use it
- drive an interactive installer that hangs on a pipe
- wait for a server's startup line without polling in a loop
- fetch only fresh output after a long build
- diff the output of two identical commands
- keep the working directory across agent steps

## Example prompts
- Start `npm run dev` and wait for the line about the port
- Send Ctrl+C to session `calm-reef` and show the last lines
- Run `git status` twice and diff the two results

## Similar
- [REA](https://affpapa.org/en/nevibecode/mcp/rea.md) — MCP server · ★ 386989
- [GitHub](https://affpapa.org/en/nevibecode/mcp/github.md) — MCP server · ★ 33918
- [Netdata](https://affpapa.org/en/nevibecode/mcp/netdata.md) — MCP server · ★ 81115
- [browser-use](https://affpapa.org/en/nevibecode/mcp/browser-use.md) — MCP server · ★ 119160
- [Codebase Memory](https://affpapa.org/en/nevibecode/mcp/codebase-memory.md) — MCP server · ★ 47392
- [mcp-server](https://affpapa.org/en/nevibecode/mcp/mcp-server.md) — MCP server · ★ 43872

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
