Skip to main content
Glama

Tmux MCP Server

OVERVIEW.md8.7 kB
# Tmux MCP Server - Project Overview A Model Context Protocol (MCP) server that provides programmatic control over tmux terminal sessions, enabling Claude to interact with command-line applications, SSH sessions, and specifically Cisco Modeling Labs (CML) devices. ## What This Solves **Problem**: Claude needs terminal access to interact with network devices, particularly CML nodes via console server SSH connections. **Solution**: This MCP server gives Claude full control over tmux sessions, enabling: - SSH to CML console servers - Interactive device configuration - Command output capture - Multi-device monitoring - Automated testing workflows ## Architecture ``` Claude Desktop ↓ MCP Protocol (stdio) ↓ Tmux MCP Server (Node.js) ↓ Tmux Sessions (Linux/WSL2) ↓ SSH Connections ↓ CML Console Server ↓ Network Devices ``` ## Key Features ### Session Management - Create named tmux sessions - List all active sessions - Kill sessions when done - Persistent sessions across commands ### Command Execution - Send keys/commands to sessions - Literal mode for special characters - Automatic Enter key appending - Support for Ctrl sequences ### Output Capture - Capture visible pane content - Capture scrollback history - Capture specific line ranges - Capture entire session history ### Pane Management - Split windows (horizontal/vertical) - Select specific panes - List all panes in session - Multi-pane monitoring ## Use Cases ### 1. CML Device Configuration ``` Claude creates session → SSHs to console server → Opens device console → Applies configuration → Verifies with show commands → Saves config ``` ### 2. Network Troubleshooting ``` Claude accesses multiple devices → Captures diagnostic output → Analyzes issues → Applies fixes → Verifies resolution ``` ### 3. Automated Testing ``` Claude builds lab (cml-toolkit) → Configures devices (tmux) → Runs test suite → Captures results → Reports pass/fail ``` ### 4. Multi-Device Monitoring ``` Claude creates split panes → Opens console to each device → Enables debug logging → Captures all output simultaneously ``` ## Technical Stack - **Language**: JavaScript (Node.js) - **MCP SDK**: @modelcontextprotocol/sdk - **Terminal**: tmux (required) - **Transport**: stdio - **Platform**: Linux, macOS, WSL2 (Windows) ## Tools Provided | Tool | Purpose | |------|---------| | `tmux_create_session` | Create new tmux session | | `tmux_list_sessions` | List all active sessions | | `tmux_send_keys` | Send commands to session | | `tmux_capture_pane` | Capture pane output | | `tmux_kill_session` | Terminate session | | `tmux_split_window` | Split window into panes | | `tmux_select_pane` | Switch active pane | | `tmux_list_panes` | List panes in session | ## Integration Points ### With CML-Toolkit When used with cml-toolkit MCP server: 1. cml-toolkit creates/manages lab infrastructure 2. tmux-mcp provides device access and configuration 3. Complete lab lifecycle automation ### With SSH - Direct SSH connection support - Password and key-based authentication - Interactive login handling - Persistent connections ### With Network Devices - Cisco IOS/IOS-XE consoles - Any SSH-accessible device - Interactive configuration - Command output parsing ## File Structure ``` tmux-mcp-server/ ├── src/ │ └── index.js # Main server implementation ├── package.json # Node.js dependencies ├── README.md # General documentation ├── QUICKSTART.md # Fast setup guide ├── WINDOWS_SETUP.md # Windows/WSL2 specific ├── CML_EXAMPLES.md # CML usage examples ├── INTEGRATION.md # Integration with cml-toolkit ├── TROUBLESHOOTING.md # Problem solving guide ├── test.js # Test script └── .gitignore # Git ignore file ``` ## Documentation Quick Reference - **Getting Started**: Read `QUICKSTART.md` - **Windows Users**: Read `WINDOWS_SETUP.md` - **CML Users**: Read `CML_EXAMPLES.md` - **Using Both Servers**: Read `INTEGRATION.md` - **Problems**: Read `TROUBLESHOOTING.md` - **General Info**: Read `README.md` ## Requirements ### System Requirements - Node.js 16+ - tmux 2.0+ - Linux, macOS, or WSL2 ### For CML Usage - CML 2.x console server access - SSH connectivity to console server - Network device credentials ## Installation Summary 1. Install tmux and Node.js 2. Extract tmux-mcp-server 3. Run `npm install` 4. Configure in Claude Desktop config 5. Restart Claude Desktop See QUICKSTART.md for detailed steps. ## Example Workflow ``` User: "Create a lab with 2 routers, configure OSPF, verify they become neighbors" Claude: 1. [cml-toolkit] Creates lab, adds routers, links them 2. [cml-toolkit] Starts lab and waits for boot 3. [tmux] Creates session "ospf-lab" 4. [tmux] SSHs to console server 5. [tmux] Opens R1, configures OSPF 6. [tmux] Opens R2, configures OSPF 7. [tmux] Checks neighbors on both routers 8. [tmux] Verifies with ping test 9. Reports: "Lab ready, OSPF established" ``` ## Advantages ### Over Manual Console Access - Programmatic control - Automated workflows - Parallel operations - Output capture for analysis ### Over Direct API - Interactive troubleshooting - Access to CLI-only features - Natural command flow - Legacy device support ### Over SSH Libraries - Session persistence - Window management - Scrollback access - Split pane monitoring ## Limitations - Requires tmux (not native Windows) - Depends on stable SSH connections - Text-based interaction only - No GUI element access ## Performance Characteristics - **Session Creation**: ~100ms - **Command Execution**: Network latency dependent - **Output Capture**: ~50ms for visible pane - **Large Captures**: ~500ms for 1000 lines - **Concurrent Sessions**: Supports many (limited by system resources) ## Security Considerations 1. **Credentials**: SSH passwords sent through tmux - Use SSH keys when possible - Don't log credentials - Clean up sessions promptly 2. **Session Persistence**: Sessions persist until killed - Always kill when done - Don't leave sensitive data in scrollback - Use unique session names 3. **Access Control**: Direct device access - Verify user permissions - Use appropriate privilege levels - Log configuration changes ## Future Enhancements Potential additions: - WebSocket support for better integration - Session recording/playback - Built-in configuration templates - Automated test framework - Integration with other MCP servers - GUI for session management - Cloud deployment options ## Comparison to Alternatives ### vs. iTerm2-MCP - Platform: Works on Linux/WSL2 (iTerm2 is macOS only) - Portability: More portable across systems - Features: Similar capabilities ### vs. Direct SSH - Session Management: Persistent sessions - Window Control: Split panes, multiple views - Output Capture: Scrollback access - Automation: Easier scripting ### vs. Expect/Ansible - Interactivity: Real-time interaction - Debugging: Direct console access - Flexibility: Natural language control - Integration: Works with other MCP tools ## Success Metrics This tool is successful if it enables: - ✅ Claude to access CML devices via console server - ✅ Interactive configuration of network devices - ✅ Automated lab testing workflows - ✅ Multi-device monitoring - ✅ Integration with cml-toolkit for complete automation ## Community & Support ### Getting Help 1. Read TROUBLESHOOTING.md 2. Check examples in CML_EXAMPLES.md 3. Test components individually 4. Review Claude Desktop logs ### Contributing Potential contributions: - Additional use case documentation - Performance optimizations - Additional tmux features - Integration with other tools - Bug fixes and testing ## Acknowledgments Built on: - Anthropic's Model Context Protocol - tmux by Nicholas Marriott - Node.js ecosystem - Cisco Modeling Labs platform ## Version History - **1.0.0** (2025-11-10): Initial release - 8 core tools - Full session management - Pane control - Output capture - Comprehensive documentation ## Project Status **Status**: Ready for use **Stability**: Beta - core functionality complete, tested **Platform Support**: - ✅ Linux (native) - ✅ macOS (native) - ✅ Windows (via WSL2) **CML Compatibility**: - ✅ CML 2.x console servers - ✅ IOS, IOS-XE, NX-OS devices - ✅ Any SSH-accessible network device --- For detailed setup instructions, see QUICKSTART.md For CML-specific usage, see CML_EXAMPLES.md For integration with cml-toolkit, see INTEGRATION.md

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MediocreTriumph/tmux-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server