Sundeepg98/pty-mcp-server
If you are the rightful owner of pty-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Model Context Protocol (MCP) server providing 32 tools for terminal, process, network, and serial communication with perfect dependency injection architecture.
PTY MCP Server
A secure Model Context Protocol (MCP) server providing terminal, process, network, and serial communication capabilities for AI assistants.
✨ Features
- 🖥️ Terminal Operations: PTY sessions, SSH, Telnet
- ⚙️ Process Management: Spawn and control processes
- 🌐 Network Tools: TCP/UDP sockets, messaging
- 📡 Serial Communication: RS232/USB serial device control
- 🔧 System Utilities: File operations, environment management
- 🔒 Security: Removed dangerous exec tool, all operations sandboxed
📦 Installation
Via PyPI (Recommended)
pip install pty-mcp-server
Using UV Tools
uv tool install pty-mcp-server
From Source
git clone https://github.com/Sundeepg98/pty-mcp-server
cd pty-mcp-server
uv tool install .
🚀 Quick Start
Configure with Claude
Add to your Claude configuration (~/.claude.json):
{
"mcp_servers": {
"pty": {
"command": "pty-mcp-server"
}
}
}
Test Installation
# Verify server responds
echo '{"jsonrpc":"2.0","method":"initialize","id":1}' | pty-mcp-server
🛠️ Available Tools (37)
System Tools (6)
env- Environment variable managementfile- File operations (read/write/list/delete)status- Get session statusactivate- Activate a projectprojects- List registered projectssessions- List all active sessions
Terminal Tools (8)
bash- Start interactive bash shellconnect- Connect to PTY with custom commanddisconnect- Terminate PTY sessionsend- Send input to PTYssh- SSH connection via PTYtelnet- Telnet connection via PTYclear- Clear terminal screenresize- Resize terminal dimensions
Process Tools (6)
spawn- Spawn a process (non-PTY)kill-proc- Kill active processsend-proc- Send to process stdinssh-proc- SSH as subprocessproc-cmd- Windows CMD (Windows only)proc-ps- Windows PowerShell (Windows only)
Network Tools (6)
socket-open- Open TCP/UDP socketsocket-close- Close socket connectionsocket-read- Read from socketsocket-write- Write to socketsocket-message- Send message, wait for responsesocket-telnet- Telnet with IAC handling
Serial Tools (5)
serial-open- Open serial portserial-close- Close serial connectionserial-read- Read from serial portserial-write- Write to serial portserial-message- Send message, wait for response
Tmux Tools (6)
tmux-start- Start new tmux sessiontmux-list- List all tmux sessionstmux-send- Send commands to sessiontmux-capture- Capture session outputtmux-attach- Get attach command for manual accesstmux-kill- Kill tmux session
📚 Usage Examples
Terminal Operations
# Start bash session
bash()
send(message="ls -la")
send(message="echo 'Hello World'")
disconnect()
# SSH connection
ssh(host="server.example.com", user="admin")
send(message="uptime")
disconnect()
Process Management
# Spawn a Python script
spawn(command="python", args=["script.py"])
send-proc(message="input data\n")
kill-proc()
# Run SSH command
ssh-proc(host="server.example.com", command="df -h")
Network Operations
# HTTP request
socket-open(host="example.com", port=80)
socket-write(data="GET / HTTP/1.0\r\n\r\n")
socket-read()
socket-close()
# Telnet session
socket-telnet(host="telnet.example.com")
socket-message(message="help")
socket-close()
Serial Communication
# Arduino/Microcontroller
serial-open(device="/dev/ttyUSB0", baudrate=9600)
serial-message(message="AT")
serial-read()
serial-close()
🏗️ Architecture
Clean Separation (Dependency Injection)
pty_mcp_server/
├── core/ → Domain Logic
│ ├── manager.py → Session coordinator
│ └── sessions/ → Connection types
├── lib/ → Infrastructure
│ ├── config.py → Configuration
│ └── registry.py → Plugin loader
└── plugins/ → MCP Tools
├── system/ → System utilities
├── terminal/ → Terminal operations
├── process/ → Process management
├── network/ → Network operations
└── serial/ → Serial communication
⚙️ Configuration
Environment Variables
PTY_MCP_BASE_DIR- Base directory for config/statePTY_DEFAULT_TIMEOUT- Read timeout in seconds (default: 0.5)PTY_MAX_BUFFER- Max buffer size (default: 4096)
Project Management
Projects can be registered with their own environments:
{
"projects": {
"myproject": "/path/to/project"
}
}
Each project can have a .env file that's loaded when activated:
activate(project_name="myproject")
# Now project-specific environment is available
🔄 Migration from v3.x
Breaking Changes
- Removed dangerous
exectool - Changed from source-based to package installation
- Configuration moved to XDG-compliant paths
Upgrade Steps
- Uninstall old version
- Install v4.0.0:
pip install pty-mcp-server - Update Claude configuration to use
pty-mcp-servercommand - Migrate any custom project configurations
📋 Requirements
- Python 3.8+
- Linux/macOS/WSL
- Optional:
pyserialfor serial communication
🤝 Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new features
- Submit a pull request
📄 License
MIT License - See LICENSE file for details
🔖 Version History
- v4.0.0 - Package distribution, removed exec tool, tmux integration, 37 secure tools
- v3.1.0 - Added dynamic environment loading
- v3.0.0 - MCP SDK integration
- v2.0.0 - Plugin architecture
- v1.0.0 - Initial release
🔗 Links
Security Note: This server is designed for local development use with AI assistants. Never expose it to untrusted networks or use in production without proper security measures.