Terminal MCP
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
๐งฉ Terminal MCP
A production-grade Model Context Protocol (MCP) server with PTY-native execution designed specifically for Cursor IDE. Provides a unified interactive terminal for Cursor's AI assistant and humans, enabling seamless command execution in shared terminal environments.
โจ Features
PTY-native execution - Commands run directly in PTY terminals (single source of truth)
Multi-project support - On-demand PTY per project root with shared state
Real environment - AWS SSO, exports, credentials all work correctly
Shared visibility - You and AI assistants see the exact same terminal
HTTP transport - Deploy anywhere, access from any machine
WebSocket support - Real-time terminal attachment and monitoring
Context-aware execution - Enhanced tools that provide terminal context before execution
Daemon mode - Run as a background service with CLI management
Graceful shutdown - Proper cleanup of PTY processes and connections
Related MCP server: AdminMCP
๐ Prerequisites
Node.js (v16 or higher)
A Unix-like system (macOS, Linux) with PTY support
๐ Quick Start
Installation
npm install -g terminal-mcpOr clone and install locally:
git clone https://github.com/yourusername/terminal-mcp.git
cd terminal-mcp
npm installBasic Usage
Start the daemon:
npm run daemon
# Or run in background:
npm run daemon:bgConfigure Cursor MCP settings (Cursor โ Settings โ Features โ Model Context Protocol):
{
"mcpServers": {
"pty-terminal": {
"url": "http://localhost:3333/mcp"
}
}
}Restart Cursor
CLI Commands
# Start daemon
npm run daemon
# Start daemon in background
npm run daemon:bg
# Check status
npm run status
# List active terminals
npm run list
# Stop daemon
npm run stop๐๏ธ Architecture
Cursor/AI Assistant
โ
โผ
MCP HTTP Server (Express)
โ
โโ HTTP Transport (JSON + SSE)
โโ WebSocket Transport (real-time)
โ
โผ
PTY Manager
โ
โโ On-demand PTY creation per project root
โโ Shared PTY state (env vars, cwd, auth tokens)
โโ Terminal Event Journal (output history)
โ
โผ
PTY Processes (node-pty)
โ
โผ
Real Shell EnvironmentKey Components:
PTY Manager: Manages multiple PTY instances, one per project root
Terminal Event Journal: Captures and stores terminal output history
MCP Tools:
execute,execute2,interrupt,list_terminals,read_terminalHTTP Server: Express-based server with MCP transport and WebSocket support
๐ How It Works
MCP server starts and creates a default PTY for the default project root
AI assistants send commands via the MCP
executeorexecute2toolCommands are executed in the appropriate PTY (based on project root)
Output is captured via PTY event listeners and stored in the event journal
Results are returned to the AI assistant via MCP
Humans can attach to terminals via WebSocket or CLI to monitor activity
๐ฏ Usage Examples
For AI Assistants (Automatic)
AI assistants automatically use this terminal for all commands. Just ask:
"Run tests"
"Install dependencies"
"Start the server"
"Check the logs"
"Build the project"
For Humans (Manual Terminal Access)
Attach to a terminal via WebSocket:
# Using the CLI
mcp-terminal attach
# Or connect directly via WebSocket
wscat -c ws://localhost:3333/attach?projectRoot=/path/to/project๐ง Configuration
Environment Variables
PORT: Server port (default: 3333)PROJECT_ROOT: Default project root path (default: home directory)SHELL: Shell to use for PTY (default:/bin/zsh)
Project-Specific Terminals
The server automatically creates separate PTY instances for different project roots. Specify the project root when calling MCP tools:
{
"command": "npm test",
"projectRoot": "/path/to/my/project"
}๐ Deployment
Docker
docker build -t terminal-mcp .
docker run -p 3333:3333 \
-e PROJECT_ROOT=/app \
-e PORT=3333 \
terminal-mcpCloud Platforms
Works on:
AWS EC2 / GCP VM / DigitalOcean
Cloud Run / Fly.io / Render
Docker Compose / Kubernetes
All support HTTP + SSE transport.
๐ Security
Important Security Considerations:
โ ๏ธ No authentication by default - Add authentication for production use
โ ๏ธ No rate limiting - Implement rate limiting for public deployments
โ ๏ธ Full command execution access - Commands run with the same privileges as the daemon user
For production, add:
API key header authentication
IP allowlist
Command denylist/filtering
Read-only mode toggle
TLS/HTTPS encryption
See SECURITY.md for more information.
๐งช Development
Setup
git clone https://github.com/yourusername/terminal-mcp.git
cd terminal-mcp
npm installRunning Tests
npm testCode Quality
# Linting (if configured)
npm run lint
# Formatting (if configured)
npm run formatSee CONTRIBUTING.md for detailed development guidelines.
๐ API Reference
MCP Tools
execute
Execute a command in the shared PTY terminal.
Parameters:
command(required): Shell command to executeprojectRoot(optional): Project root path
execute2
Context-aware execution that shows terminal history before executing.
Parameters:
command(required): Shell command to executeprojectRoot(optional): Project root pathcontextChars(optional): Maximum characters of context to show (default: 2000)
interrupt
Send Ctrl+C to interrupt the currently running command.
Parameters:
projectRoot(optional): Project root path
list_terminals
List all active PTY terminals managed by the server.
read_terminal
Read terminal output history without executing any command.
Parameters:
projectRoot(optional): Project root pathmaxChars(optional): Maximum characters to return (default: 8000)mode(optional): Read mode -tail,since_last, orfull(default:tail)
HTTP Endpoints
GET /health- Health check endpointPOST /mcp- MCP protocol endpointGET /terminals- List active terminalsWS /attach- WebSocket endpoint for terminal attachment
๐ ๏ธ Troubleshooting
Terminal not found
The server automatically creates PTY instances on demand. If you encounter issues:
Check that the daemon is running:
npm run statusVerify the project root path exists
Check server logs for errors
Commands not executing
Make sure:
The MCP server is configured correctly in Cursor settings
The PROJECT_ROOT path is absolute and correct
You've restarted Cursor after configuration
The daemon is running and accessible
Check active terminals
npm run list
# Or via HTTP:
curl http://localhost:3333/terminals๐ค Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
๐ Found a bug? Open an issue
๐ก Have an idea? Start a discussion
๐ Want to contribute code? Read the contributing guide
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
Built with Model Context Protocol
Uses node-pty for PTY support
Inspired by the need for seamless AI-human terminal collaboration
๐ Support
๐ Documentation
๐ฌ Discussions
๐ Issue Tracker
๐ Security Issues
Made with โค๏ธ for the open source community
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
This server cannot be deployed
Maintenance
Related MCP Connectors
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Develop, manage, and debug Railway projects, services, and deployments from within agents.
Persistent cloud workspaces for AI agents: run commands, edit files, use git and a browser.
Use your own Windows, Mac or Linux computer from ChatGPT, Claude, Cursor or Gemini CLI: run commands, read, write and search files, run long processes. Your computer only makes an outgoing connection (no open ports or VPN). Read-only mode, allowed folders, blocked commands and an action log keep you in control. Free plan available.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with terminal environments through multiple concurrent PTY sessions. Supports cross-platform terminal operations including command execution, session management, and real-time communication.2MIT
- FlicenseNot gradedqualityNot gradedmaintenanceProvides LLMs with administrative capabilities to execute shell commands on local systems through a pseudo-terminal environment with Unix Domain Socket communication.-
- FlicenseAqualityDmaintenanceEnables AI agents to start and manage pseudo-terminal sessions, run shell commands and interact with REPLs programmatically.7-
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to execute commands in a shared tmux session that is simultaneously visible to a human via a web-based terminal UI.1MIT