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