# SmartCLI — drive terminal TUIs

Enables AI agents to operate interactive terminal applications like vim, lazygit, or htop. Sends keystrokes and reads terminal cell grids directly.

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

## What it does

SmartCLI links AI agents to interactive terminal software through a PTY backend and `pyte`. It avoids raw byte streams. Instead, the driver builds a structured cell grid so agents track highlighted menu rows and alternate screens. Keystrokes drive real binaries like `lazygit` or `vim`.

The tool relies on a perceive-and-confirm loop. After dispatching keystrokes, the agent waits for screen text to match a regex pattern. Blind sleep calls are avoided completely. Sessions run on Linux via POSIX PTYs and on Windows through ConPTY.

Setup requires Python 3.10 or newer. Without proper alternate screen buffer support, terminal editors like `vim` fail silently and drop unsaved edits. The toolkit resolves this by fixing 12 VT emulation bugs against reference terminal implementations.

## Requirements
- Needs: Python and uv (commands run via uvx)

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add smartcli -- uvx smartcli-toolkit
```
uvx runs the command named after the package; if the README names another one, use uvx --from smartcli-toolkit <command>

### Codex

**Platform CLI**
```bash
codex mcp add smartcli-drive-terminal-tuis -- uvx smartcli-toolkit
```
uvx runs the command named after the package; if the README names another one, use uvx --from smartcli-toolkit <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "smartcli-drive-terminal-tuis": {
            "command": "uvx",
            "args": [
                "smartcli-toolkit"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from smartcli-toolkit <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "smartcli-drive-terminal-tuis": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "smartcli-toolkit"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from smartcli-toolkit <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add smartcli-drive-terminal-tuis uvx smartcli-toolkit
```
uvx runs the command named after the package; if the README names another one, use uvx --from smartcli-toolkit <command>

## When to use it
- drive interactive terminal utilities inside a managed PTY
- wait for expected screen patterns before sending the next keystroke
- read highlighted menu items and alternate screen buffers
- verify on-disk file updates after exiting terminal text editors

## Example prompts
- Start lazygit in a SmartCLI session and inspect the latest commit diff
- Open config.py in vim, insert a configuration line, and write to disk
- Launch htop in a managed PTY and check which process consumes the most memory

## Similar
- [REA](https://affpapa.org/en/nevibecode/mcp/rea.md) — MCP server · ★ 392262
- [GitHub](https://affpapa.org/en/nevibecode/mcp/github.md) — MCP server · ★ 33989
- [Netdata](https://affpapa.org/en/nevibecode/mcp/netdata.md) — MCP server · ★ 81163
- [browser-use](https://affpapa.org/en/nevibecode/mcp/browser-use.md) — MCP server · ★ 119231
- [Codebase Memory](https://affpapa.org/en/nevibecode/mcp/codebase-memory.md) — MCP server · ★ 47577
- [mcp-server](https://affpapa.org/en/nevibecode/mcp/mcp-server.md) — MCP server · ★ 43902

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