ai-mcp-terminal
Click on "Deploy 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., "@ai-mcp-terminalcreate 3 terminals and run system checks in parallel"
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.
AI-MCP Terminal
๐ Multi-threaded terminal management for AI assistants with real-time web monitoring
Solve terminal blocking issues - Commands run async, never block AI operations. Monitor up to 100 concurrent terminals with intelligent cleanup and system tracking.
โจ Key Features
Core Capabilities
๐ Async Execution - Commands never block AI operations
๐ข Multi-Threading - 100 concurrent terminals with ThreadPoolExecutor
๐งน Auto Cleanup - Smart idle session detection & memory management
โก Batch Operations - Execute across multiple terminals simultaneously
๐ Web Monitor - Real-time xterm.js interface with system stats
Smart Execution (v1.0.52+)
๐ Workflow Engine - Execute tasks with dependencies (DAG support)
โณ Smart Waiting - Block until specific tasks complete
๐ Sequential Execution - Run commands in strict order
๐ Auto Retry - Automatic retry on transient failures
๐ Project Lock - Terminals always start in project directory
Platform Support
๐ง WSL Priority - Auto-detect WSL bash on Windows (preferred)
๐ UTF-8 Support - Proper encoding, no garbled text
๐ Anti-Loop Protection - Prevents AI from getting stuck in query loops
Related MCP server: mcp-ssh-multi
๐ Quick Start (1 Minute)
Step 1: Add MCP Configuration
Add to your Cursor/Cline MCP settings:
{
"mcpServers": {
"ai-mcp-terminal": {
"command": "uvx",
"args": ["ai-mcp-terminal"],
"env": {}
}
}
}Step 2: Restart IDE
Step 3: Start Using
In Cursor:
Create 3 terminals and run system checks in parallelAI will use create_batch for true concurrency!
Browser auto-opens โ http://localhost:8000 โ View all terminals in real-time!
๐ Web Interface
Auto-opens at http://localhost:8000
Features:
๐บ Real-time xterm.js terminals
๐ CPU/Memory/System stats
๐ Live output streaming
๐ฏ Click to expand terminals
๐ Shutdown server button
๐ ๏ธ Available MCP Tools
Batch Tools (Recommended)
Tool | Description | Concurrency |
| Create multiple terminals + execute | โ 100 threads |
| Execute across terminals | โ 100 threads |
| Get all outputs | โ 100 threads |
| Check status | โ 100 threads |
| Send to all terminals | โ Async |
Smart Execution Tools (v1.0.52+)
Tool | Description | Use Case |
| DAG-based task execution | Build โ Test โ Deploy pipeline |
| Block until tasks finish | Wait for build before deploy |
| Run commands in order | Step-by-step setup scripts |
| Auto-retry on failure | Network requests, downloads |
Single Tools (Use batch tools instead!)
Tool | Use Instead |
| โ |
| โ |
| โ |
Why batch tools?
10x faster (parallel execution)
1 call instead of 10 calls
Non-blocking design
๐ฏ Use Cases
Multi-Service Development
User: "Start frontend, backend, and database"
AI calls:
create_batch(sessions=[
{name: "frontend", cwd: "./web", initial_command: "npm run dev"},
{name: "backend", cwd: "./api", initial_command: "python app.py"},
{name: "db", cwd: "./", initial_command: "docker-compose up"}
])
Result: 3 services start simultaneously, web interface shows allSystem Information Gathering
User: "Check system info"
AI calls:
create_batch(sessions=[
{name: "cpu", cwd: ".", initial_command: "wmic cpu get name"},
{name: "mem", cwd: ".", initial_command: "wmic memorychip get capacity"},
{name: "disk", cwd: ".", initial_command: "wmic logicaldisk get size,freespace"},
{name: "os", cwd: ".", initial_command: "systeminfo"}
])
Later:
get_batch_output(session_ids=["cpu", "mem", "disk", "os"])
Result: All info gathered in parallel, 4x faster than serialSmart Retry for Network Operations
User: "Download and install dependencies"
AI calls:
execute_with_retry(
session_id: "npm_install",
command: "npm install",
max_retries: 3,
retry_delay: 2.0
)
Result:
- Attempt 1 fails (network error)
- Wait 2 seconds
- Attempt 2 fails
- Wait 2 seconds
- Attempt 3 succeeds โโ๏ธ Configuration
Optional environment variables:
{
"mcpServers": {
"ai-mcp-terminal": {
"command": "uvx",
"args": ["ai-mcp-terminal"],
"env": {
"AI_MCP_PREFERRED_SHELL": "bash"
}
}
}
}Shell Priority:
Windows:
WSL bash(๐ง) โGit Bash(๐) โpowershellโcmdmacOS:
zshโbashโshLinux:
bashโzshโsh
v1.0.52: WSL now displays with penguin icon (๐ง) in web interface, Git Bash with shell icon (๐)
๐ง Installation Options
Option 1: UVX (Recommended)
```json
{
"command": "uvx", "args": ["ai-mcp-terminal"] }
**No installation needed!** UV handles everything.
### Option 2: PIPX
```bash
pipx install ai-mcp-terminal```json
{
"command": "ai-mcp-terminal" }
### Option 3: PIP
```bash
pip install ai-mcp-terminal{
"command": "python",
"args": ["-m", "src.main"]
}๐ก๏ธ Anti-Loop Protection
Problem: AI gets stuck querying terminal repeatedly
Solution: Built-in query counter
Query 1-2: Normal
Query 3-4: โ ๏ธ Warning + stop instruction
Query โฅ5: ๐ช Auto-terminate process
Result: AI never loops, always proceeds with tasks
๐ฆ How AI Should Use This
โ Correct Pattern
Dialog 1:
User: "Deploy React app"
AI:
1. create_batch(...)
2. Reply: "Deploying in background..."
3. END conversation
Dialog 2 (later):
User: "Is it done?"
AI:
1. check_completion(...)
2. Reply: "Still running..." or "Done!"
3. END conversationโ Wrong Pattern (Fixed by protection)
Dialog 1:
User: "Deploy React app"
AI:
1. execute_command(...)
2. get_output(...) โ running
3. get_output(...) โ running [Query 2]
4. get_output(...) โ running [Query 3 - WARNING]
5. get_output(...) โ running [Query 4]
6. get_output(...) โ AUTO-KILLED [Query 5]
7. Error: "Loop detected, process terminated"๐ Project Structure
ai-mcp-terminal/
โโโ src/
โ โโโ main.py # Entry point
โ โโโ mcp_server.py # MCP protocol handler (30+ tools)
โ โโโ terminal_manager.py # Terminal management (3400+ lines)
โ โโโ web_server.py # FastAPI + WebSocket
โ โโโ key_mapper.py # Keyboard interaction support
โ โโโ static/ # Web UI (xterm.js)
โโโ docs/ # Documentation (15+ guides)
โโโ examples/ # Usage examples
โโโ CHANGELOG.md # Detailed version history
โโโ README.md
โโโ LICENSE
โโโ pyproject.toml๐ง Troubleshooting
Web Interface Not Opening
Solution: Visit http://localhost:8000 manually
Port Already in Use
Solution:
Auto-finds next available port
Or click shutdown in existing interface
AI Keeps Using Single Tools
Solution:
Restart IDE (MCP caches tool definitions)
Check tool descriptions loaded correctly
๐ License
MIT License - see LICENSE
๐ค Contributing
Contributions welcome! See CONTRIBUTING.md
๐ Links
Issues: https://github.com/kanniganfan/ai-mcp-terminal/issues
Changelog: CHANGELOG.md
๐ What's New in v1.0.53
๐ฏ Production-Ready Improvements
Based on real PyPI release testing, v1.0.53 brings battle-tested improvements that solve actual production issues:
๐ Enhanced Debugging
Detailed Statistics: Every command returns
output_bytes,output_lines,execution_time,encoding_usedClear Status: Explicit
success: true/falseinstead of ambiguousexit_code: nullNo More Guessing: Know exactly what happened with every command
๐ก๏ธ Smart Error Prevention
Shell Type Detection: Warns when PowerShell command sent to Bash terminal (and vice versa)
Quick Fix Suggestions: Provides exact commands to fix common errors
7 Error Categories: PyPI duplicates, encoding errors, permissions, network, syntax, etc.
๐ Zero-Config UTF-8 (Windows)
Auto Setup: Sets
PYTHONIOENCODING=utf-8andPYTHONUTF8=1automaticallyNo More Encoding Errors: twine, pip, and other Python tools just work
80% Fewer Errors: Eliminates common
UnicodeEncodeErrorissues
๐ Intelligent Batch Execution
Smart Queueing: Same terminal โ sequential, different terminals โ concurrent
Zero Race Conditions: No more "upload before build finishes" issues
Maximum Efficiency: Still fully concurrent across different terminals
Previous Features (v1.0.52)
โจ execute_workflow() - DAG-based task orchestration
โณ wait_until_complete() - Smart blocking wait
๐ execute_sequence() - Sequential execution with error handling
๐ execute_with_retry() - Automatic retry mechanism
See CHANGELOG.md for complete details.
Made with โค๏ธ for AI Assistants
If this helps you, please give it a โญ star!
This server cannot be deployed
Maintenance
Related MCP Connectors
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
MCP server for Gainium โ manage trading bots, deals, and balances via AI assistants
MCP server for building and testing AI agents with multi-model experimentation and insights.
MCP server unifying ERPs, CRMs, APIs and knowledge base for Claude, ChatGPT and Gemini.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceTerminal MCP server for AI coding agents with persistent PTY sessions, ring-buffer incremental reads, headless xterm screen capture, multi-agent orchestration, and a real-time web dashboard.14 npm28MIT
- AlicenseAqualityBmaintenanceMCP server for managing multiple SSH servers via AI assistants, offering tools for remote command execution, file operations, and system monitoring.1141 PyPI2MIT
- AlicenseBqualityAmaintenanceA secure MCP server for shell operations, terminal management, and process control, enabling AI assistants to safely execute commands and manage interactive sessions.1355 npm6MIT
- AlicenseAqualityBmaintenanceA high-performance MCP server that manages persistent SSH sessions via a local tmux instance, enabling command execution, file transfer, and session monitoring for AI agents.957 PyPI6MIT