Allows running and interacting with the htop system monitor through an interactive pseudo-terminal session.
Enables interactive text editing via the nano editor using full terminal emulation.
Supports interactive Python REPL sessions, enabling line-by-line code execution and stateful interaction with the interpreter within the terminal.
Provides the ability to run and interact with the Vim text editor, supporting complex escape sequences for command modes and navigation.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@PTY MCP ServerOpen config.json in vim"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
PTY MCP Server
An MCP (Model Context Protocol) server that provides interactive PTY (pseudo-terminal) sessions for AI assistants like Claude Code. This enables interaction with programs that require full terminal emulation such as vim, ssh, less, top, interactive REPLs, and more.
LLM Deployment Instructions
This section provides complete step-by-step instructions for an LLM to deploy this MCP server autonomously.
Prerequisites
Before starting, ensure the system has:
Node.js >= 18.0.0 (
node --versionto check)npm (comes with Node.js)
Build tools for native modules
To check/install prerequisites:
Step 1: Clone the Repository
Step 2: Install Dependencies
This installs:
@modelcontextprotocol/sdk- The MCP SDK for server implementationnode-pty- Native PTY bindings (requires build tools)
Troubleshooting
Step 3: Register with Claude Code
CRITICAL: Claude Code does NOT use ~/.claude/.mcp.json directly. You MUST use the CLI:
If using a different installation path, adjust accordingly:
Step 4: Verify Installation
Step 5: Test the Server
After restarting Claude Code, test with:
Tools Reference
pty_spawn
Create a new interactive PTY session.
Parameter | Type | Required | Default | Description |
| string | No | User's shell | Command to run |
| string[] | No | [] | Command arguments |
| string | No | Current dir | Working directory |
| number | No | 120 | Terminal columns (max: 500) |
| number | No | 30 | Terminal rows (max: 200) |
| object | No | {} | Additional environment variables |
Returns:
pty_write
Send input to a PTY session. Supports escape sequences.
Parameter | Type | Required | Description |
| string | Yes | Session ID from |
| string | Yes | Input to send |
Escape Sequences:
Sequence | Key | Use Case |
| Enter | Execute commands |
| Newline | Multi-line input |
| Tab | Autocomplete |
| Ctrl-C | Interrupt/cancel |
| Ctrl-D | EOF/exit |
| Escape | Exit modes (vim, less) |
| Arrow Up | History/navigation |
| Arrow Down | History/navigation |
| Arrow Right | Cursor movement |
| Arrow Left | Cursor movement |
Returns:
pty_read
Read buffered output from a PTY session.
Parameter | Type | Required | Default | Description |
| string | Yes | - | Session ID |
| number | No | 100 | Wait time for output (max: 5000) |
| boolean | No | true | Clear buffer after reading |
Returns:
pty_resize
Resize a PTY terminal for full-screen applications.
Parameter | Type | Required | Description |
| string | Yes | Session ID |
| number | Yes | New columns (max: 500) |
| number | Yes | New rows (max: 200) |
pty_kill
Terminate a PTY session and clean up resources.
Parameter | Type | Required | Default | Description |
| string | Yes | - | Session ID |
| string | No | SIGHUP | Signal: SIGHUP, SIGTERM, SIGKILL, SIGINT |
pty_list
List all active PTY sessions. No parameters required.
Usage Examples
SSH Session
Python REPL
Vim Editing
Interactive Program (top, htop)
Configuration
Setting | Value | Description |
Max sessions | 10 | Maximum concurrent PTY sessions |
Session timeout | 30 minutes | Idle sessions auto-cleanup |
Buffer size | 1 MB | Max output buffer per session |
Input size | 1 MB | Max input per write |
Default terminal | 120x30 | Default cols x rows |
Max terminal | 500x200 | Maximum cols x rows |
Troubleshooting
Server not found after registration
node-pty build fails
Session commands not working
Ensure you're using the correct
session_idfrompty_spawnCheck if session exited:
pty_listor checkexitedfield inpty_readFor password prompts, use longer
timeout_ms(e.g., 5000)
Output contains escape codes
Terminal output includes ANSI escape sequences for colors and formatting. This is normal behavior for terminal applications.
Security
Commands restricted to standard system paths
Shell metacharacters rejected in command names
Environment variable names validated
Input/buffer sizes limited
Sessions auto-expire after 30 minutes
Claude Code Integration (CLAUDE.md snippet)
Add this to your project's CLAUDE.md file to help Claude Code understand how to use this MCP server:
License
MIT