UNPKG

terminal-x-mcp

Version:

Multi-agent terminal automation system with command planning, security validation, and real-time monitoring - A Model Context Provider (MCP) server for intelligent terminal management

327 lines (249 loc) โ€ข 10.2 kB
![Terminal[X]MCP Banner](assets/logo/terminal-x-mcp-banner.png) **Multi-Agent Terminal Automation System with Command Planning and Security Validation** ![License](https://img.shields.io/badge/license-MIT-blue.svg) ![Node.js](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg) ![Version](https://img.shields.io/badge/version-0.1.0--alpha.1-orange.svg) ![Status](https://img.shields.io/badge/status-alpha-red.svg) Terminal[X]MCP is a Model Context Provider (MCP) server that enables intelligent terminal automation through a multi-agent system with distributed specialized roles for command execution, security validation, and real-time monitoring. **Automate your terminal workflows intelligently** - Works seamlessly with Cursor, Claude Desktop, VS Code, and other MCP-compatible applications while providing secure command execution and comprehensive monitoring. ## โœจ Features ### ๐Ÿค– **Multi-Agent Architecture** - **Terminal Coordinator**: Intelligent command planning and workflow orchestration - **Command Executor**: Safe command execution with environment management - **Security Monitor**: Command security analysis and risk prevention - **Terminal Monitor**: Real-time process monitoring and performance tracking ### ๐Ÿง  **Auto-Intelligence** - **Command Planning**: Automatic command sequence optimization - **Security Validation**: Real-time command risk assessment - **Workflow Orchestration**: Multi-step terminal automation - **Error Recovery**: Intelligent failure handling and retry strategies ### ๐Ÿ”„ **Agent Coordination** - **Distributed Processing**: Specialized agents with focused responsibilities - **Task Distribution**: Intelligent workload balancing across terminal sessions - **Result Aggregation**: Comprehensive output collection and analysis - **Resource Management**: Efficient terminal resource allocation ### ๐Ÿ›ก๏ธ **Security First** - **Command Validation**: Real-time security analysis before execution - **Privilege Management**: Safe execution with appropriate permissions - **Sandbox Execution**: Isolated command execution environments - **Risk Assessment**: Intelligent command risk scoring ### ๐Ÿ“Š **Terminal Management** - **Multi-Session Support**: Concurrent terminal session management - **Process Monitoring**: Real-time process tracking and analysis - **Performance Metrics**: Terminal performance optimization - **Logging System**: Comprehensive command and output logging ### ๐Ÿ’ก **Intelligent Automation** - **Workflow Automation**: Complex multi-step terminal workflows - **Environment Detection**: Automatic environment configuration - **Dependency Resolution**: Smart command dependency management - **Error Handling**: Robust error detection and recovery ## ๐Ÿš€ Quick Start ### Installation ```bash # Clone the repository git clone https://github.com/rnd-pro/terminal-x-mcp.git cd terminal-x-mcp # Install dependencies npm install # Copy environment configuration cp .env.example .env # Start the server npm start ``` ### MCP Client Configuration Add to your MCP client configuration: ```json { "mcpServers": { "terminal-x-mcp": { "command": "node", "args": ["/path/to/terminal-x-mcp/src/server/index.js"], "env": { "NODE_ENV": "production" } } } } ``` ### Basic Usage ```javascript // Example: Execute secure command workflow await mcp.request("execute_command", { command: "npm install && npm test", security_level: "high", timeout: 60000 }); // Example: Monitor terminal processes await mcp.request("monitor_processes", { filter: "node", metrics: ["cpu", "memory", "duration"] }); ``` ## ๐Ÿ—๏ธ Architecture ### Agent Communication Flow ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ MCP Client โ”‚โ”€โ”€โ”€โ–ถโ”‚ Terminal[X]MCP โ”‚โ”€โ”€โ”€โ–ถโ”‚ Command Executorโ”‚ โ”‚ (Cursor/CLI) โ”‚ โ”‚ Coordinator โ”‚ โ”‚ Agent โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ–ผ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚Security โ”‚ โ”‚Terminal โ”‚ โ”‚Monitor Agent โ”‚ โ”‚Monitor Agentโ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ–ผ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚Command โ”‚ โ”‚Process โ”‚ โ”‚Validation โ”‚ โ”‚Monitoring โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ### Multi-Agent Roles 1. **Terminal Coordinator Agent** - Main command planning and orchestration 2. **Command Executor Agent** - Safe command execution and output handling 3. **Security Monitor Agent** - Command security analysis and validation 4. **Terminal Monitor Agent** - Process monitoring and performance tracking ## ๐Ÿ› ๏ธ Available Tools ### Core Terminal Tools - `execute_command` - Secure command execution with validation - `plan_workflow` - Multi-step command workflow planning - `monitor_processes` - Real-time process monitoring - `validate_security` - Command security assessment ### Agent Coordination Tools - `coordinate_execution` - Multi-agent command coordination - `aggregate_outputs` - Command output collection and analysis - `manage_sessions` - Terminal session management ### Monitoring Tools - `track_performance` - Terminal performance metrics - `analyze_logs` - Command execution log analysis - `monitor_resources` - System resource monitoring ## โš™๏ธ Configuration ### Environment Variables ```bash # MCP Server Configuration MCP_PORT=3003 NODE_ENV=development # Agent Configuration AGENT_MAX_CONCURRENCY=3 AGENT_TIMEOUT=30000 # Terminal Settings TERMINAL_MAX_SESSIONS=10 TERMINAL_COMMAND_TIMEOUT=60000 # Security Configuration SECURITY_VALIDATION_ENABLED=true SECURITY_RISK_THRESHOLD=0.7 # Monitoring Settings MONITORING_ENABLED=true MONITORING_INTERVAL=5000 # Logging Configuration LOG_LEVEL=info LOG_TERMINAL_OUTPUT=true ``` ## ๐Ÿงช Testing ```bash # Run all tests npm test # Test multi-agent coordination npm run test:agents # Test terminal automation npm run test:terminal # Run security validation tests npm run test:security ``` ## ๐Ÿ“ Project Structure ``` terminal-x-mcp/ โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ server/ # MCP server implementation โ”‚ โ”œโ”€โ”€ agents/ # Multi-agent system โ”‚ โ”œโ”€โ”€ core/ # Core functionality โ”‚ โ””โ”€โ”€ utils/ # Utilities and helpers โ”œโ”€โ”€ test/ # Test suites โ”œโ”€โ”€ docs/ # Documentation โ”œโ”€โ”€ examples/ # Usage examples โ””โ”€โ”€ assets/ # Assets and resources ``` ## ๐Ÿค Integration Examples ### Command Workflow Automation ```javascript // Automated build and deploy workflow const result = await terminalXMCP.executeWorkflow({ commands: [ "git pull origin main", "npm install", "npm run build", "npm run test", "npm run deploy" ], securityLevel: "high", failFast: true }); ``` ### Process Monitoring ```javascript // Monitor development server const monitoring = await terminalXMCP.monitorProcess({ command: "npm run dev", metrics: ["cpu", "memory", "network"], alertThresholds: { cpu: 80, memory: 1024 } }); ``` ## ๐Ÿ”ฎ Roadmap ### Phase 1: Foundation โœ… - [x] Project structure setup - [x] Basic MCP server implementation - [x] Agent framework foundation ### Phase 2: Core Agents (In Progress) - [ ] Terminal Coordinator implementation - [ ] Command Executor with security validation - [ ] Basic monitoring capabilities ### Phase 3: Advanced Features - [ ] Multi-session terminal management - [ ] Advanced security monitoring - [ ] Workflow automation engine ### Phase 4: Optimization - [ ] Performance optimization - [ ] Advanced command planning - [ ] Production deployment ## ๐Ÿค Contributing We welcome contributions! Please see our [Contributing Guide](docs/CONTRIBUTING.md) for details. ### Development Setup ```bash # Clone the repository git clone https://github.com/rnd-pro/terminal-x-mcp.git cd terminal-x-mcp # Install dependencies npm install # Start development server npm run dev ``` ### Submitting Changes 1. Fork the repository 2. Create a feature branch: `git checkout -b feature/amazing-terminal-feature` 3. Commit changes: `git commit -m 'Add amazing terminal feature'` 4. Push to branch: `git push origin feature/amazing-terminal-feature` 5. Open a Pull Request ## ๐Ÿ“„ License MIT License - see [LICENSE](LICENSE) file for details. ## ๐Ÿ‘ฅ Development Team **Developed by RND-PRO Team** - ๐ŸŒ Website: [rnd-pro.com](https://rnd-pro.com) - ๐Ÿ’ผ Professional development team specializing in innovative AI solutions - ๐Ÿค– Experts in multi-agent systems and terminal automation - ๐Ÿš€ Leaders in MCP protocol implementations and secure command execution ## ๐Ÿ™ Acknowledgments - Built on [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) - Inspired by multi-agent AI architectures and secure terminal automation - Command execution powered by Node.js process management - Security validation using advanced risk assessment algorithms ## ๐Ÿ“ž Support - ๐Ÿ“ง **Issues**: [GitHub Issues](https://github.com/rnd-pro/terminal-x-mcp/issues) - ๐Ÿ’ฌ **Discussions**: [GitHub Discussions](https://github.com/rnd-pro/terminal-x-mcp/discussions) - ๐Ÿ“– **Documentation**: [Wiki](https://github.com/rnd-pro/terminal-x-mcp/wiki) --- **Made with โค๏ธ by RND-PRO Team for the terminal automation community**