# Terminal MCP Server

An MCP server that hands an AI agent live terminal sessions plus a structured screen snapshot, so it can press keys, click on found elements and wait for output.

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

## What it does

Each session comes back as a state tree, and the agent works through tools. `terminal_session_create` opens it, `terminal_snapshot` captures the screen with detected UI elements, `terminal_press_key` sends arrows, F-keys or combos like Ctrl+X, `terminal_click` targets an element, `terminal_wait_for` blocks until text, an element or an idle state appears. Alongside sit `terminal_type`, `terminal_read_output`, session listing, closing and resizing.

A visible xterm window spawns by default. Pass `--headless` when there is no display to show. Visual mode on Linux and WSL needs X11, so `DISPLAY` goes into the MCP config. Native Windows gets headless only; the authors point Windows users to WSL for the full toolset.

Set `RUST_LOG` to `error`, `warn`, `info`, `debug` or `trace` for logging. Log lines go to stderr because stdout carries the MCP protocol. Miss `DISPLAY` in the config on Linux and the visual session simply will not start.

## Requirements
- Needs: Node.js (commands run via npx)
- Environment variables: `DISPLAY`, `RUST_LOG` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add --env DISPLAY=<DISPLAY> --env RUST_LOG=<RUST_LOG> --transport stdio terminal-mcp-server -- npx -y mcp-server-terminal
```
Replace <…> with your own values

### Codex

**Platform CLI**
```bash
codex mcp add terminal-mcp-server --env DISPLAY=<DISPLAY> --env RUST_LOG=<RUST_LOG> -- npx -y mcp-server-terminal
```
Replace <…> with your own values

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "terminal-mcp-server": {
            "command": "npx",
            "args": [
                "-y",
                "mcp-server-terminal"
            ],
            "env": {
                "DISPLAY": "<DISPLAY>",
                "RUST_LOG": "<RUST_LOG>"
            }
        }
    }
}
```
Replace <…> with your own values

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "terminal-mcp-server": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "mcp-server-terminal"
            ],
            "env": {
                "DISPLAY": "<DISPLAY>",
                "RUST_LOG": "<RUST_LOG>"
            }
        }
    }
}
```
Replace <…> with your own values

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e DISPLAY=<DISPLAY> -e RUST_LOG=<RUST_LOG> terminal-mcp-server npx -y mcp-server-terminal
```
Replace <…> with your own values

## When to use it
- drive an interactive program like htop and capture its screen
- send a down arrow and wait for the list to redraw
- run a shell command and read back its output
- click a menu entry the agent found on screen
- keep several terminal sessions open and close the extra ones

## Example prompts
- Start a terminal session running htop and take a snapshot
- Press the down arrow and wait until the table updates
- Type `ls -la`, hit Enter, then show me the output

## 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
