io.github.mkpvishnu/terminal-mcp

平台与服务

by mkpvishnu

用于交互式终端会话的MCP服务器,支持SSH、REPL、数据库CLI与TUI应用。

什么是 io.github.mkpvishnu/terminal-mcp

用于交互式终端会话的MCP服务器,支持SSH、REPL、数据库CLI与TUI应用。

README

<!-- mcp-name: io.github.mkpvishnu/terminal-mcp --> <p align="center"> <img src="assets/banner.svg" width="800" alt="terminal-mcp banner"/> </p> <h3 align="center">Give your AI a real terminal. Persistent sessions. Interactive programs. Zero limitations.</h3> <p align="center"> <a href="https://pypi.org/project/terminal-mcp/"><img src="https://img.shields.io/pypi/v/terminal-mcp.svg" alt="PyPI"/></a> <a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.10%2B-blue.svg" alt="Python 3.10+"/></a> <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License: MIT"/></a> <a href="https://github.com/mkpvishnu/terminal-mcp/actions/workflows/ci.yml"><img src="https://github.com/mkpvishnu/terminal-mcp/actions/workflows/ci.yml/badge.svg" alt="CI"/></a> <a href="https://github.com/mkpvishnu/terminal-mcp/actions/workflows/codeql.yml"><img src="https://github.com/mkpvishnu/terminal-mcp/actions/workflows/codeql.yml/badge.svg" alt="CodeQL"/></a> </p> <p align="center"> <a href="https://insiders.vscode.dev/redirect/mcp/install?name=terminal-mcp&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22terminal-mcp%22%5D%7D"><img src="https://img.shields.io/badge/VS_Code-Install-007ACC?logo=visual-studio-code&logoColor=white" alt="Install in VS Code"/></a> <a href="https://insiders.vscode.dev/redirect/mcp/install?name=terminal-mcp&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22terminal-mcp%22%5D%7D"><img src="https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?logo=visual-studio-code&logoColor=white" alt="Install in VS Code Insiders"/></a> <a href="cursor://anysphere.cursor-mcp/install?name=terminal-mcp&config=eyJjb21tYW5kIjoidXZ4IiwiYXJncyI6WyJ0ZXJtaW5hbC1tY3AiXX0="><img src="https://img.shields.io/badge/Cursor-Install-F37626?logo=cursor&logoColor=white" alt="Install in Cursor"/></a> <a href="#install-in-claude-desktop"><img src="https://img.shields.io/badge/Claude_Desktop-Install-cc785c?logo=claude&logoColor=white" alt="Install in Claude Desktop"/></a> </p> <p align="center"> <img src="assets/demo.gif" alt="terminal-mcp demo" width="700"/> </p>

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.

code
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 directly
uvx terminal-mcp

# Or install globally
pip install terminal-mcp

2. Connect to Your AI Client

<details open> <summary><strong>Claude Code</strong></summary>

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

json
{
  "mcpServers": {
    "terminal": {
      "command": "uvx",
      "args": ["terminal-mcp"]
    }
  }
}
</details> <details> <summary><strong>Claude Desktop</strong></summary>

Add to claude_desktop_config.json:

json
{
  "mcpServers": {
    "terminal": {
      "command": "uvx",
      "args": ["terminal-mcp"]
    }
  }
}
</details> <details> <summary><strong>VS Code / Cursor</strong></summary>

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

json
{
  "servers": {
    "terminal-mcp": {
      "command": "uvx",
      "args": ["terminal-mcp"]
    }
  }
}
</details> <details> <summary><strong>Windsurf</strong></summary>

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

json
{
  "mcpServers": {
    "terminal": {
      "command": "uvx",
      "args": ["terminal-mcp"]
    }
  }
}
</details>

3. Verify

code
session_exec  exec="echo hello from terminal-mcp"

What Can You Do With It?

SSH Into Remote Servers

code
session_create   command="ssh user@prod-server.com"   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

code
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

code
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

code
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

code
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

code
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

常见问题

io.github.mkpvishnu/terminal-mcp 是什么?

用于交互式终端会话的MCP服务器,支持SSH、REPL、数据库CLI与TUI应用。

相关 Skills

MCP构建

by anthropics

Universal
热门

聚焦高质量 MCP Server 开发,覆盖协议研究、工具设计、错误处理与传输选型,适合用 FastMCP 或 MCP SDK 对接外部 API、封装服务能力。

想让 LLM 稳定调用外部 API,就用 MCP构建:从 Python 到 Node 都有成熟指引,帮你更快做出高质量 MCP 服务器。

平台与服务
未扫描176.4k

Slack动图

by anthropics

Universal
热门

面向Slack的动图制作Skill,内置emoji/消息GIF的尺寸、帧率和色彩约束、校验与优化流程,适合把创意或上传图片快速做成可直接发送的Slack动画。

帮你快速做出适配 Slack 的动图,内置约束规则和校验工具,少踩上传与播放坑,做表情包和演示都更省心。

平台与服务
未扫描176.4k

接口测试套件

by alirezarezvani

Universal
热门

扫描 Next.js、Express、FastAPI、Django REST 的 API 路由,自动生成覆盖鉴权、参数校验、错误码、分页、上传与限流场景的 Vitest 或 Pytest 测试套件。

帮你把API与集成测试自动化跑顺,减少回归漏测;能力全面,尤其适合复杂接口场景的QA团队。

平台与服务
未扫描26.0k

相关 MCP Server

Slack 消息

编辑精选

by Anthropic

热门

Slack 是让 AI 助手直接读写你的 Slack 频道和消息的 MCP 服务器。

这个服务器解决了团队协作中需要 AI 实时获取 Slack 信息的痛点,特别适合开发团队让 Claude 帮忙汇总频道讨论或发送通知。不过,它目前只是参考实现,文档有限,不建议在生产环境直接使用——更适合开发者学习 MCP 如何集成第三方服务。

平台与服务
89.7k

by netdata

热门

io.github.netdata/mcp-server 是让 AI 助手实时监控服务器指标和日志的 MCP 服务器。

这个工具解决了运维人员需要手动检查系统状态的痛点,最适合 DevOps 团队让 Claude 自动分析性能数据。不过,它依赖 NetData 的现有部署,如果你没用过这个监控平台,得先花时间配置。

平台与服务
80.0k

by d4vinci

热门

Scrapling MCP Server 是专为现代网页设计的智能爬虫工具,支持绕过 Cloudflare 等反爬机制。

这个工具解决了爬取动态网页和反爬网站时的头疼问题,特别适合需要批量采集电商价格或新闻数据的开发者。不过,它依赖外部浏览器引擎,资源消耗较大,不适合轻量级任务。

平台与服务
72.9k

评论