Terminal Mcp

io.github.mkpvishnu由 GitHub 帳號 mkpvishnu 發布v0.3.1更新於 Oct 27, 2026

MCP server for interactive terminal sessions — SSH, REPLs, database CLIs, TUI apps

發布方自己的服務:Terminal Tax

概覽

AI 產生的概覽

為 AI 助理提供可跨工具呼叫維持的互動式終端機(PTY)工作階段,可執行指令、SSH、REPL、資料庫 CLI 與 TUI 程式。

可以做什麼
  • 建立、列出、調整大小與關閉以真實 PTY 為後端的持續性終端機工作階段
  • 傳送文字、特殊按鍵與控制字元,並以串流、快照、自動或差異模式讀取輸出
  • 在一次呼叫中送出輸入並讀取結果,或等待輸出出現正規表示式比對
  • 在單次呼叫中執行一次性指令
  • 適用於 SSH 連線、Python/Node REPL、psql/mysql/redis CLI、htop 或 vim 等 TUI 程式,以及長時間執行的建置或開發伺服器
適用情境
當助理需要跨指令保留狀態時適用:維持開啟的 SSH 工作階段、互動式解譯器、資料庫 CLI 連線、TUI 程式,或需要持續觀察的建置與日誌串流。若只是執行簡單的一次性 shell 指令則不需要。
執行需求
以 stdio 本機程序執行,透過 uvx 或 pip 安裝(Python),需在用戶端的 MCP 設定檔中設定。可選的 TERMINAL_MCP_* 環境變數可調整最大工作階段數、閒置逾時、安全閘門、緩衝區大小與截斷方式。僅支援桌面用戶端。
安裝前請注意
助理將取得本機真實 shell 權限,包括 SSH 至遠端主機與資料庫 CLI,輸入的內容會實際執行。危險指令閘門會攔截 rm -rf、DROP TABLE、curl 管線給 sh 等模式並要求確認,但這只是啟發式規則,且可透過 TERMINAL_MCP_SAFETY_GATE 關閉。工作階段會保留到關閉或閒置逾時,輸出會被緩衝並截斷。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Terminal Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

[terminal-mcp banner]

Give your AI a real terminal. Persistent sessions. Interactive programs. Zero limitations.

[PyPI] [Python 3.10+] [License: MIT] [CI] [CodeQL]

[Install in VS Code] [Install in VS Code Insiders] [Install in Cursor] [Install in Claude Desktop]

[terminal-mcp demo]


The Problem

Every AI coding tool hits the same wall: no real terminal access.

Claude Code's Bash tool, GitHub Copilot, and Codex all run commands in isolated subprocesses. Each command starts fresh. No state carries over. That means:

  • No SSH sessions - Can't connect to a remote server and run multiple commands
  • No REPLs - Can't use Python, Node, or Ruby interpreters interactively
  • No database CLIs - Can't maintain a psql, mysql, or redis-cli connection
  • No TUI apps - Can't navigate htop, vim, or fzf with arrow keys
  • No long-running processes - Can't monitor builds, watch logs, or run dev servers

The Solution

terminal-mcp gives AI agents a real terminal. Persistent PTY sessions that survive across tool calls. Send commands, read output, press keys, navigate TUIs - exactly like a human at a terminal.

uvx terminal-mcp

One command. Works with Claude Code, Claude Desktop, VS Code, Cursor, and Windsurf.


Quick Start

1. Install (30 seconds)

bash
# No install needed - run directlyuvx terminal-mcp
# Or install globallypip install terminal-mcp

2. Connect to Your AI Client

Claude Code

Add to ~/.claude.json or project .mcp.json:

json
{  "mcpServers": {    "terminal": {      "command": "uvx",      "args": ["terminal-mcp"]    }  }}
Claude Desktop

Add to claude_desktop_config.json:

json
{  "mcpServers": {    "terminal": {      "command": "uvx",      "args": ["terminal-mcp"]    }  }}
VS Code / Cursor

Click the one-click install badge above, or add to .vscode/mcp.json:

json
{  "servers": {    "terminal-mcp": {      "command": "uvx",      "args": ["terminal-mcp"]    }  }}
Windsurf

Add to ~/.codeium/windsurf/mcp_config.json:

json
{  "mcpServers": {    "terminal": {      "command": "uvx",      "args": ["terminal-mcp"]    }  }}

3. Verify

session_exec  exec="echo hello from terminal-mcp"

What Can You Do With It?

SSH Into Remote Servers

session_create   command="ssh [email protected]"   label="prod"session_interact session_id="a1b2c3d4"  input="df -h"  wait_for="\$"session_interact session_id="a1b2c3d4"  input="docker ps"  wait_for="\$"session_close    session_id="a1b2c3d4"

Run Interactive REPLs

session_create   command="python3"  label="python"session_interact session_id="e5f6g7h8"  input="import pandas as pd"  wait_for=">>>"session_interact session_id="e5f6g7h8"  input="df = pd.read_csv('data.csv')"  wait_for=">>>"session_interact session_id="e5f6g7h8"  input="df.describe()"  wait_for=">>>"session_close    session_id="e5f6g7h8"

Query Databases

session_create   command="psql -U admin mydb"  label="db"session_interact session_id="x1y2z3w4"  input="SELECT count(*) FROM users;"  wait_for="row"session_interact session_id="x1y2z3w4"  input="\dt"  wait_for="#"session_close    session_id="x1y2z3w4"

Navigate TUI Apps

session_create   command="htop"  label="monitor"session_read     session_id="a1b2c3d4"# Auto-detects TUI, returns screen snapshot
session_send     session_id="a1b2c3d4"  key="F6"session_read     session_id="a1b2c3d4"  mode="diff"# Returns only changed lines - saves tokens
session_send     session_id="a1b2c3d4"  key="F10"session_close    session_id="a1b2c3d4"

Monitor Long-Running Builds

session_create   command="bash"  label="build"session_send     session_id="a1b2c3d4"  input="npm run build"session_wait_for session_id="a1b2c3d4"  pattern="Build complete|ERROR"  timeout=120

Run One-Off Commands

session_exec  exec="git log --oneline -10"session_exec  exec="docker compose ps"  timeout=10

Features at a Glance

FeatureWhat It Does
Persistent SessionsReal PTY sessions that survive across tool calls
Send + Read in One Callsession_interact halves LLM round trips
Pattern-Based Readswait_for blocks until regex matches - no guessing timeouts
Auto TUI DetectionDetects htop, vim, etc. and auto-switches to screen snapshot mode
Output Diff ModeReturns only changed screen lines - minimizes tokens
Special KeysArrow keys, Tab, F1-F12, Home/End, Page Up/Down
Control CharactersCtrl-C, Ctrl-D, Ctrl-Z, Ctrl-L, telnet escape
Dangerous Command GateBlocks rm -rf, DROP TABLE, curl|sh - requires confirmation
OSC 133 Shell IntegrationAuto-detects command boundaries and exit codes
Smart TruncationFour strategies to prevent context overflow
Secret InputSend passwords without logging
Dynamic ResizeResize terminal on the fly with SIGWINCH
Idle CleanupAuto-closes idle sessions
Cross-PlatformLinux, macOS, and Windows support

Tools Reference

terminal-mcp exposes 9 MCP tools. Full details in docs/tools.md.

ToolPurpose
session_createSpawn a persistent terminal session
session_sendSend text, keys, or control characters
session_readRead output (stream, snapshot, auto, diff modes)
session_interactSend + read in one call
session_wait_forWait for regex pattern in output
session_execOne-shot command execution
session_closeClose a session gracefully
session_resizeResize terminal dimensions
session_listList active sessions

Architecture

mermaid
flowchart LR    Client[AI Client] -->|MCP JSON-RPC| Server[terminal-mcp]    Server --> SM[Session Manager]    SM --> S1[PTY 1: bash]    SM --> S2[PTY 2: python3]    SM --> S3[PTY 3: ssh user@host]    S1 & S2 & S3 -.->|PTY output| Reader[Reader Thread]    Reader -.->|buffer| Server

Each session is backed by a real PTY via pexpect.spawn (or PopenSpawn on Windows). For full architecture details, see docs/architecture.md.


Configuration

All settings configurable via TERMINAL_MCP_* environment variables. Full reference in docs/configuration.md.

SettingEnv VarDefault
Max sessionsTERMINAL_MCP_MAX_SESSIONS10
Idle timeoutTERMINAL_MCP_IDLE_TIMEOUT1800 (30 min)
Safety gateTERMINAL_MCP_SAFETY_GATEon
Buffer capTERMINAL_MCP_MAX_BUFFER_BYTES1000000 (1MB)
TruncationTERMINAL_MCP_TRUNCATION_MODEtail

Example with custom settings:

json
{  "mcpServers": {    "terminal": {      "command": "uvx",      "args": ["terminal-mcp"],      "env": {        "TERMINAL_MCP_MAX_SESSIONS": "20",        "TERMINAL_MCP_IDLE_TIMEOUT": "3600",        "TERMINAL_MCP_TRUNCATION_MODE": "head_tail"      }    }  }}

Documentation

DocumentDescription
Tools ReferenceComplete API for all 9 MCP tools
ArchitectureHow terminal-mcp works under the hood
ConfigurationAll settings and environment variables
Safety & SecurityDangerous command detection and safety gate
Use Cases & ExamplesReal-world recipes and patterns
ChangelogVersion history and release notes
ContributingHow to contribute

Supported Clients

ClientStatusInstall
Claude Code (CLI)Supported~/.claude.json or .mcp.json
Claude DesktopSupportedOne-click install
VS Code (Copilot Chat)SupportedOne-click install or .vscode/mcp.json
CursorSupportedOne-click install or Settings
WindsurfSupported~/.codeium/windsurf/mcp_config.json

Running Tests

bash
pip install -e ".[dev]"pytest tests/ -v

Contributing

Contributions welcome! See docs/contributing.md for guidelines.

License

MIT

來源:README.md,提交 6e094a2

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.3.1最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Terminal 整合