PTY Debug MCP Server
Enables spawning, interacting with, and capturing screen output from terminal-based programs for debugging PTY/TTY/TUI applications.
README
PTY Debug MCP Server
MCP server for debugging PTY/TTY/TUI programs. Enables Claude Code to spawn, interact with, and capture screen output from any terminal-based program.
Use Case: TUI Debugging
This MCP server allows Claude Code to control Claude Code itself, vim, top, and other TUI programs. This enables:
- Automated TUI testing
- Debugging terminal applications
- Screen scraping from interactive programs
- CI/CD integration for TUI apps
Demo: Claude Code controlling Claude Code
1. spawn_session({ command: "claude" })
2. send_input({ specialKey: "shift+tab" }) // cycle modes
3. send_input({ input: "what is 1+1?" })
4. send_input({ specialKey: "enter" })
5. get_snapshot() // see Claude's response
Demo: Claude Code controlling vim
1. spawn_session({ command: "vim", args: ["test.txt"] })
2. send_input({ input: "i" }) // enter INSERT mode
3. send_input({ input: "Hello World!" }) // type text
4. send_input({ specialKey: "escape" }) // exit INSERT mode
5. send_input({ input: ":wq" }) // save command
6. send_input({ specialKey: "enter" }) // execute
Installation
Claude Code
claude mcp add pty-debug -- npx -y @so2liu/pty-mcp-server@latest
Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"pty-debug": {
"command": "npx",
"args": ["-y", "@so2liu/pty-mcp-server@latest"]
}
}
}
VS Code / Copilot
Add to VS Code settings or .vscode/mcp.json:
{
"mcpServers": {
"pty-debug": {
"command": "npx",
"args": ["-y", "@so2liu/pty-mcp-server@latest"]
}
}
}
Cursor
Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"pty-debug": {
"command": "npx",
"args": ["-y", "@so2liu/pty-mcp-server@latest"]
}
}
}
Cline
Add to Cline MCP settings:
{
"mcpServers": {
"pty-debug": {
"command": "npx",
"args": ["-y", "@so2liu/pty-mcp-server@latest"]
}
}
}
Gemini CLI
gemini mcp add pty-debug -- npx -y @so2liu/pty-mcp-server@latest
Codex CLI
codex mcp add pty-debug -- npx -y @so2liu/pty-mcp-server@latest
MCP Tools
| Tool | Description |
|---|---|
spawn_session |
Start a TUI program in a PTY |
send_input |
Send text or special keys |
get_snapshot |
Capture current screen state |
resize_terminal |
Change terminal dimensions |
list_sessions |
List active sessions |
close_session |
Terminate a session |
Special Keys
Supports all common shortcuts:
- Basic:
enter,tab,shift+tab,escape,backspace,delete - Arrows:
up,down,left,right - With modifiers:
shift+up,ctrl+right,alt+left, etc. - Control:
ctrl+atoctrl+z - Alt:
alt+atoalt+z - Function:
f1tof12 - Navigation:
home,end,pageup,pagedown
Screen Snapshot Format
-------------------------------------------------------------------------------------
1 |Processes: 643 total, 3 running, 640 sleeping 17:57:23 |
2 |Load Avg: 2.38, 2.75, 2.88 CPU usage: 13.13% user, 4.49% sys |
3 |... |
-------------------------------------------------------------------------------------
Development
# Install dependencies
bun install
# Development mode
bun run dev
# Build
bun run build
# Lint
bun run lint
Tech Stack
- Node.js (runtime)
- TypeScript
- node-pty (PTY spawning)
- @xterm/headless (terminal emulation)
- @modelcontextprotocol/sdk (MCP server)
Publishing
Releases are automatically published to npm via GitHub Actions.
Setup (one-time)
-
Create npm granular token at https://www.npmjs.com/settings/tokens/granular-access-tokens/new
- Expiration: 90 days
- Packages:
@so2liu/pty-mcp-server - Permissions: Read and write
-
Add
NPM_TOKENsecret at https://github.com/so2liu/pty-mcp/settings/secrets/actions -
Set calendar reminder to rotate token every 90 days
Release new version
- Update version in
package.json - Create a GitHub release with tag (e.g.,
v1.0.1) - GitHub Actions will automatically publish to npm
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 模型以安全和受控的方式获取实时的网络信息。