home / mcp / terminal mcp server
Terminal MCP Server - Model Context Protocol server for TUI/CLI automation with structured Terminal State Tree (TST)
Configuration
View docs{
"mcpServers": {
"aybelatchane-mcp-server-terminal": {
"command": "npx",
"args": [
"mcp-server-terminal"
],
"env": {
"DISPLAY": ":0",
"RUST_LOG": "info"
}
}
}
}You run a Terminal MCP Server to let AI agents interact with terminal applications through a structured Terminal State Tree. This enables conversational control of terminal sessions, execution of commands, and dynamic UI interactions across supported MCP clients using a common protocol.
Ask your AI agent to manage terminal sessions, create interactive shells, or perform scripted actions. Typical tasks include starting a session with a command, typing input, sending keystrokes, resizing the terminal, taking snapshots of the UI, and reading terminal output. The server exposes a set of tools that your agent can invoke to control terminal behavior and respond to UI elements.
Common usage patterns include starting a session with a specific command, interacting with the session by typing commands, and capturing terminal state for visualization or decision making. You can also run the session in headless mode for environments without a visible display, which is useful for automated workflows and remote execution.
Prerequisites: ensure you have Node.js installed on your system. You can verify by running node -v and npm -v in your terminal.
Install the MCP server by running the runtime command: npx mcp-server-terminal.
(Optional) Build from source if you prefer building from the repo and running the binary instead of the npm package. Use your preferred language toolchain as shown in the instructions for the source project.
Connect your MCP client by configuring it to point at this server using the standard MCP connection method. The server is started locally by the command shown above, and you can pass additional flags as needed to tailor behavior.
Visual mode is enabled by default and opens a visible terminal window. To run headless for environments without a display, start the server with the --headless flag.
By default, sessions spawn a visible terminal window. To run without a UI, use headless mode.
npx mcp-server-terminal --headlessIf you need visual output in a Linux environment, ensure X11 is available and the DISPLAY variable is set in your MCP client configuration.
{
"mcpServers": {
"terminal": {
"command": "npx",
"args": ["mcp-server-terminal"],
"env": {
"DISPLAY": ":0"
}
}
}
}Control logging verbosity by setting the RUST_LOG environment variable when starting the server. Levels include error, warn, info, debug, and trace.
{
"mcpServers": {
"terminal": {
"command": "npx",
"args": ["mcp-server-terminal"],
"env": {
"RUST_LOG": "info"
}
}
}
}The server supports Linux, macOS, and Windows (via WSL for full visual mode). See the platform table for details on architecture and capabilities.
The server provides a comprehensive set of terminal-related actions that you can command from your MCP client, including creating sessions, listing sessions, resizing, typing input, pressing keys, clicking UI elements, waiting for text or UI state, and reading terminal output.
Start a new terminal session with a specified command or shell.
List all active terminal sessions managed by the MCP server.
Close a running terminal session by its identifier.
Resize the terminal viewport to new width and height.
Capture the current terminal state including visible UI elements.
Type text into the active terminal session.
Simulate pressing a key or key sequence (arrows, F-keys, Ctrl combos).
Interact with detected UI elements by clicking them.
Wait for specific text, element, or idle state before continuing.
Read the raw terminal output for processing.