SmartCLI — drive terminal TUIs — Claude Code MCP server
Enables AI agents to operate interactive terminal applications like vim, lazygit, or htop. Sends keystrokes and reads terminal cell grids directly.
claude mcp add smartcli -- uvx smartcli-toolkitWhat SmartCLI — drive terminal TUIs 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.
What it helps with
- 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 for the agent
- 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
How to install SmartCLI — drive terminal TUIs
Platform CLI
claude mcp add smartcli -- uvx smartcli-toolkituvx runs the command named after the package; if the README names another one, use uvx --from smartcli-toolkit <command>
Platform CLI
codex mcp add smartcli-drive-terminal-tuis -- uvx smartcli-toolkituvx runs the command named after the package; if the README names another one, use uvx --from smartcli-toolkit <command>
Config file
{
"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>
Config file
{
"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>
Platform CLI
gemini mcp add smartcli-drive-terminal-tuis uvx smartcli-toolkituvx runs the command named after the package; if the README names another one, use uvx --from smartcli-toolkit <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about SmartCLI — drive terminal TUIs
How to install SmartCLI — drive terminal TUIs in Claude Code?
Run claude mcp add smartcli-drive-terminal-tuis -- uvx smartcli-toolkit in your terminal.
What does SmartCLI do?
It runs interactive terminal tools inside a managed pseudo-terminal, passes keyboard input, and tracks screen state through the pyte cell emulator.
How does SmartCLI differ from regular tools like pexpect?
Instead of inspecting raw byte streams, SmartCLI constructs a full two-dimensional grid of terminal cells. This allows AI models to distinguish highlighted rows and interact with full-screen console apps.