terminal-bridge-mcp
An MCP server that bridges AI assistants to real terminal sessions, enabling creation, management, and interaction with persistent PTY processes for running commands, monitoring output, and debugging.
README
terminal-bridge-mcp
An MCP (Model Context Protocol) server that bridges AI assistants to real terminal sessions — create, manage, read, and interact with persistent PTY processes.
Built with TypeScript, node-pty, and the MCP SDK.
Why terminal-bridge-mcp?
AI coding assistants can write code, but they usually can't run it. terminal-bridge-mcp closes this gap by giving your AI a real terminal — not a sandboxed exec, but a full PTY session with persistent state.
This means your AI assistant can:
- Start dev servers and monitor their output in real time
- Run tests across multiple projects simultaneously
- Manage long-running processes (databases, queues, background workers)
- Debug interactively — send input to running programs, read responses
- Monitor deployments — tail logs, check health endpoints, watch for errors
All from within your existing MCP-compatible AI workflow (Claude Desktop, Cursor, Windsurf, etc.).
Key Features
- Multiple persistent sessions — each terminal lives independently with its own state
- Real PTY — full pseudo-terminal support, not just
child_process.exec - Regex search — search across all sessions to find errors, warnings, or any pattern
- ANSI stripping — output is cleaned automatically for AI consumption
- Output buffering — up to 50,000 lines / 10MB per session, ring buffer with no memory leaks
- Configurable — custom working directory, environment variables, terminal dimensions
Use Cases
1. Start and Monitor Dev Servers
Let your AI start a frontend dev server and check when it's ready:
> terminal_create {"command": "pnpm dev", "cwd": "/projects/my-app", "name": "frontend"}
→ Created session: term-1-abc123 (pid: 42000)
> terminal_read {"session_id": "term-1-abc123"}
→ VITE v7.3.1 ready in 2430ms
➜ Local: http://localhost:5173/
2. Run Backend Services with Virtual Environments
Activate a Python virtual environment and start the backend:
> terminal_create {"command": ".venv\\Scripts\\activate && fba run", "cwd": "/projects/backend", "name": "backend"}
→ Created session: term-2-def456 (pid: 43000)
> terminal_read {"session_id": "term-2-def456"}
→ API running at http://127.0.0.1:8000/api/v1
3. Run Tests in Parallel Across Projects
Start test runners for multiple services and monitor results:
> terminal_create {"command": "pytest -x", "cwd": "/projects/api", "name": "api-tests"}
> terminal_create {"command": "vitest run", "cwd": "/projects/web", "name": "web-tests"}
> terminal_create {"command": "go test ./...", "cwd": "/projects/worker", "name": "worker-tests"}
> terminal_search {"pattern": "PASS|FAIL|error|panic"}
→ [api-tests] 12 passed, 0 failed
[web-tests] FAIL src/auth.test.ts
[worker-tests] panic: nil pointer dereference
4. Manage Long-Running Infrastructure
Start databases, message queues, or background workers:
> terminal_create {"command": "docker compose up", "cwd": "/projects/my-stack", "name": "infra"}
> terminal_create {"command": "celery -A tasks worker", "cwd": "/projects/worker", "name": "celery"}
> terminal_read {"session_id": "term-infra", "filter": "ready|listening|started"}
→ postgres is ready to accept connections
redis is ready to accept connections
5. Interactive Debugging
Send commands to a running REPL or CLI tool:
> terminal_create {"command": "python", "name": "repl"}
> terminal_write {"session_id": "term-repl", "text": "import pandas as pd"}
> terminal_write {"session_id": "term-repl", "text": "df = pd.read_csv('data.csv')"}
> terminal_write {"session_id": "term-repl", "text": "df.describe()"}
> terminal_read {"session_id": "term-repl"}
→ count mean std min max
age 1000 35.2 12.1 18.0 89.0
6. Monitor Logs and Tail Output
Watch for specific patterns in running services:
> terminal_read {"session_id": "term-backend", "filter": "ERROR|WARN|exception", "lines": 200}
→ [ERROR] Connection refused to database replica
[WARN] Retry attempt 3/5 for external API
> terminal_search {"pattern": "OOM|out of memory|killed"}
→ [worker] Process killed (OOM)
Requirements
- Node.js >= 22.0.0
- Windows (uses PowerShell as the default shell)
Install
git clone https://github.com/dividduang/terminal-bridge-mcp.git
cd terminal-bridge-mcp
npm install
npm run build
Configure
Add to your MCP client configuration (.mcp.json, Claude Desktop settings, Cursor, Windsurf, etc.):
{
"mcpServers": {
"terminal-bridge": {
"command": "node",
"args": ["path/to/terminal-bridge-mcp/dist/index.js"]
}
}
}
Tools
terminal_create
Create a new managed terminal session.
| Parameter | Type | Default | Description |
|---|---|---|---|
command |
string | - | Command to run on start |
cwd |
string | - | Working directory |
name |
string | - | Friendly name for the session |
env |
object | - | Additional environment vars |
cols |
number | 120 | Terminal columns |
rows |
number | 40 | Terminal rows |
Returns a session ID, PID, and session name.
terminal_list
List all managed terminal sessions with their status, names, PIDs, and output line counts.
terminal_read
Read output from a terminal session.
| Parameter | Type | Default | Description |
|---|---|---|---|
session_id |
string | - | Session ID (required) |
lines |
number | 100 | Number of recent lines to return |
filter |
string | - | Regex pattern to filter lines |
raw |
boolean | false | Include ANSI escape codes |
terminal_search
Search across terminal sessions for lines matching a regex pattern.
| Parameter | Type | Default | Description |
|---|---|---|---|
pattern |
string | - | Regex pattern (required) |
session_id |
string | - | Limit to a specific session |
max_results |
number | 50 | Maximum number of results |
terminal_write
Send input text to a running terminal session.
| Parameter | Type | Default | Description |
|---|---|---|---|
session_id |
string | - | Session ID (required) |
text |
string | - | Text to send (required) |
press_enter |
boolean | true | Append Enter key after text |
terminal_kill
Kill a terminal session and remove it from management.
| Parameter | Type | Description |
|---|---|---|
session_id |
string | Session ID (required) |
Architecture
src/
├── index.ts # MCP server and tool definitions
├── pty-manager.ts # PTY process lifecycle management
├── output-buffer.ts # Ring buffer for terminal output
└── types.ts # TypeScript interfaces
- OutputBuffer — ring buffer that stores up to 50,000 lines / 10MB, strips ANSI codes, supports regex search
- PtyManager — manages multiple sessions, resolves shell to
pwsh.exeorpowershell.exe
Comparison
| Feature | terminal-bridge-mcp | child_process.exec |
IDE Terminal |
|---|---|---|---|
| Full PTY support | Yes | No | Yes |
| AI can read output | Yes | Manual | No |
| Multiple sessions | Yes | One-shot | Manual |
| Regex search across sessions | Yes | No | No |
| Persistent state | Yes | No | Yes |
| Interactive input (write back) | Yes | No | Manual |
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。