Skip to main content

Smart terminal session management for AI assistants

Project description

Terminal MCP Server

License: MIT Python 3.8+

Smart terminal session management for AI assistants. Solve terminal blocking issues with async execution, auto cleanup, and real-time web monitoring.

Support up to 64 concurrent terminals with intelligent idle detection, system monitoring, and auto browser opening.


โœจ Key Features

  • ๐Ÿš€ Async Execution - Commands never block AI operations
  • ๐Ÿ”ข Multi-Terminal - Up to 64 concurrent sessions
  • ๐Ÿงน Auto Cleanup - Intelligent idle session detection
  • โšก Broadcast - Execute commands across multiple terminals
  • ๐Ÿ“Š System Monitor - Real-time CPU/Memory/GPU tracking
  • ๐ŸŒ Web Interface - Auto-open browser with full terminal view
  • ๐Ÿ–ฅ๏ธ Smart Shell - Auto-detect best shell (Git Bash > PowerShell > cmd)
  • ๐Ÿ›‘ Resource Control - One-click shutdown button

๐Ÿš€ Quick Start

Installation

pip install mcp psutil

Cursor Configuration

Add to your Cursor MCP config:

{
  "mcpServers": {
    "terminal": {
      "command": "python",
      "args": ["/absolute/path/to/terminal-mcp/src/terminal_mcp_server/server.py"]
    }
  }
}

Usage

In Cursor:

Create a terminal session named "dev"
Execute "npm run dev" in dev session

Browser auto-opens โ†’ View real-time output โ†’ Monitor system resources!


๐Ÿ“Š Web Interface

Auto-opens at http://localhost:18888

Dashboard Features

Top Panel:

  • ๐Ÿ“Š CPU Usage (real-time)
  • ๐Ÿ’พ Memory Usage (% + GB)
  • ๐Ÿ–ฅ๏ธ GPU Info (Windows)
  • ๐Ÿ“ˆ Session Stats
  • ๐Ÿ›‘ Shutdown Server Button

Layout:

  • Left: Terminal session list
  • Right: Full-screen xterm.js terminal (click to expand)
  • Bottom: Command input

Actions

  • Click session โ†’ Full terminal expands
  • Type commands โ†’ Real-time execution
  • Click ๐Ÿ›‘ โ†’ Shutdown all sessions + release port

๐Ÿ› ๏ธ Available MCP Tools

Tool Description
create_session Create new terminal session
execute_command Execute command (async, non-blocking)
broadcast_command Execute across multiple terminals
get_all_sessions List all sessions
get_session_status Get session status
get_output Get terminal output
kill_session Terminate session
cleanup_idle_sessions Clean idle sessions
get_stats Get statistics

โš™๏ธ Configuration

Edit config.json:

{
  "max_sessions": 64,
  "idle_timeout": 300,
  "auto_cleanup_interval": 60,
  "max_output_lines": 10000,
  "web_port": 18888,
  "auto_open_browser": true
}

๐Ÿ–ฅ๏ธ Smart Shell Detection

Windows Priority:

  1. Git Bash (C:\Program Files\Git\bin\bash.exe)
  2. PowerShell 7 / Windows PowerShell
  3. cmd.exe (fallback)

Linux/Mac: Uses $SHELL environment variable


๐Ÿ“ Project Structure

terminal-mcp/
โ”œโ”€โ”€ src/terminal_mcp_server/
โ”‚   โ”œโ”€โ”€ server.py          # Core MCP server (all-in-one)
โ”‚   โ””โ”€โ”€ config.json        # Default configuration
โ”œโ”€โ”€ config.json            # User configuration
โ”œโ”€โ”€ mcp_config_example.json # Cursor config template
โ”œโ”€โ”€ requirements.txt       # Dependencies
โ””โ”€โ”€ README.md             # This file

๐ŸŽฏ Use Cases

Development Workflow

1. Create "frontend" โ†’ npm run dev
2. Create "backend" โ†’ python manage.py runserver
3. Create "database" โ†’ docker-compose up
4. Monitor all in web interface
5. Click any terminal to view full output

Batch Operations

1. Create 5 sessions
2. Broadcast "git status" to all
3. View results in web interface

Long-running Tasks

1. Create session
2. Execute "npm run build"
3. AI continues other work
4. Check output anytime in browser

๐Ÿ›‘ Resource Management

When switching IDEs or done working:

  1. Open web interface
  2. Click ๐Ÿ›‘ Shutdown Server button
  3. All sessions terminated
  4. Port 18888 released
  5. Process fully exits

No more port conflicts or resource leaks!


๐Ÿ“ฆ Publishing (Coming Soon)

After publishing to PyPI, users can simply:

{
  "mcpServers": {
    "terminal": {
      "command": "uvx",
      "args": ["terminal-mcp-server"]
    }
  }
}

No download, no install, just works!


๐Ÿ”ง Troubleshooting

Web Interface Not Opening

Solution: Manually visit http://localhost:18888

Port Already in Use

Solution:

  1. Change web_port in config.json
  2. Or click shutdown button in existing web interface

Shell Not Detected

Solution: Check that Git Bash/PowerShell is installed


๐Ÿ“„ License

MIT License - see LICENSE file


๐Ÿค Contributing

Contributions welcome! See CONTRIBUTING.md


๐ŸŒŸ Star History

If this helps you, please give it a star! โญ


Made with โค๏ธ for AI Assistants | Report Issues

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

terminal_mcp_server-1.0.0.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

terminal_mcp_server-1.0.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file terminal_mcp_server-1.0.0.tar.gz.

File metadata

  • Download URL: terminal_mcp_server-1.0.0.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for terminal_mcp_server-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ccf0aa0637c70e8193c425da8f1aa8948ff3ee2d2a7d60c594d931fd6ac9ad10
MD5 4e64af736955018dbaa8318dfceee614
BLAKE2b-256 e34d53f81fd94811c21e0660a23f62bcafc2d4413a5b29633a157bc6f92d2acc

See more details on using hashes here.

File details

Details for the file terminal_mcp_server-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for terminal_mcp_server-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 604b5c9d6dbcfb8a432b229b3a8d5e3075b24eb4e0b0599131a1569e53250bbe
MD5 5e5333933583c6364a095de4aed06758
BLAKE2b-256 4dfc42443e86106aba9d8dac6c2bcb8185c9bf302cc43a6aba450d35de4734a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page