PTY Debug MCP Server

PTY Debug MCP Server

Enables spawning, interacting with, and capturing screen output from terminal-based programs for debugging PTY/TTY/TUI applications.

Category
Visit Server

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+a to ctrl+z
  • Alt: alt+a to alt+z
  • Function: f1 to f12
  • 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)

  1. 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
  2. Add NPM_TOKEN secret at https://github.com/so2liu/pty-mcp/settings/secrets/actions

  3. Set calendar reminder to rotate token every 90 days

Release new version

  1. Update version in package.json
  2. Create a GitHub release with tag (e.g., v1.0.1)
  3. GitHub Actions will automatically publish to npm

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured