๐ Linux Bash MCP Server
A powerful Model Context Protocol (MCP) server that enables Claude Desktop to execute bash commands and scripts in any WSL2 Linux distribution on Windows. It features universal Linux compatibility, intelligent distribution detection, and comprehensive safety measures.
๐ Quick Start
# 1. Clone the repository
git clone https://github.com/yourusername/linux-bash-mcp-server.git
cd linux-bash-mcp-server
# 2. Run automated setup
npm run fix
# 3. Restart Claude Desktop
# 4. Start using Linux commands in Claude!
โจ Features
- ๐ง Universal Linux Support: Works with Ubuntu, Debian, Fedora, openSUSE, Alpine, and more.
- ๐ Smart Distribution Detection: Automatically detects and configures available WSL distributions.
- ๐ก๏ธ Safe Configuration Merging: Preserves existing MCP servers when setting up.
- ๐ง Comprehensive Diagnostics: Built - in troubleshooting and auto - fix tools.
- โก High Performance: Optimized command execution with configurable timeouts.
- ๐ Detailed Logging: Debug mode for troubleshooting and monitoring.
- ๐ Easy Management: Simple scripts for setup, testing, and maintenance.
๐ ๏ธ Available Tools
| Tool | Description | Example Use |
|---|---|---|
execute_bash_command |
Run single bash commands | ps aux | grep nginx |
execute_bash_script |
Execute bash scripts with args | Run monitoring scripts |
create_bash_script |
Create new bash scripts | Generate automation scripts |
list_directory |
List directory contents | Browse file systems |
get_system_info |
Comprehensive system info | Check OS, memory, disk usage |
check_wsl_status |
WSL and distribution status | Verify connectivity |
๐ Prerequisites
- Windows with WSL2 installed
- Any Linux distribution in WSL2 (Ubuntu, Debian, etc.)
- Node.js 18+
- Claude Desktop App
๐ฆ Installation
Option 1: Automated Setup (Recommended)
git clone https://github.com/yourusername/linux-bash-mcp-server.git
cd linux-bash-mcp-server
npm run fix
Option 2: Manual Setup
# Install dependencies
npm install
# Run interactive setup
npm run setup
# Test functionality
npm test
Option 3: Quick Diagnostics
# Check for issues
npm run debug
# Verify configuration
npm run check-config
๐ง Configuration
The server automatically detects your WSL distributions and configures itself. Manual configuration is available in config.json:
{
"wslDistribution": "auto-detect",
"defaultTimeout": 30000,
"scriptTimeout": 60000,
"maxBufferSize": 10485760,
"debugMode": false
}
๐ป Usage Examples
Basic Usage
Once configured, you can use various commands in Claude Desktop:
System Administration
- "Show comprehensive system information for my Linux environment"
- "Check disk usage and available space"
- "List running processes sorted by CPU usage"
File Operations
- "List all files in /var/log with detailed information"
- "Find files modified in the last 24 hours"
- "Show directory sizes in /home"
Development Tasks
- "Check if Docker is running"
- "Show git status for repositories in my home directory"
- "List installed Python packages"
Automation
- "Create a backup script for my documents"
- "Generate a system monitoring script"
- "Create a log rotation script"
๐ก๏ธ Safety Features
- Configuration Preservation: Never overwrites existing MCP servers.
- Automatic Backups: Creates backups of corrupted configurations.
- Input Validation: Validates all commands and parameters.
- Timeout Protection: Prevents hanging commands.
- Error Handling: Comprehensive error reporting and recovery.
๐ Troubleshooting
Quick Fixes
npm run fix # Auto-resolve common issues
npm run debug # Detailed diagnostics
Common Issues
WSL Not Found
wsl --install
wsl --install -d Ubuntu
Dependencies Missing
npm install
Configuration Issues
npm run check-config
npm run setup
Server Not Starting
npm run debug
See TROUBLESHOOTING.md for detailed solutions.
๐ค Integration with Other MCP Servers
This server works seamlessly alongside:
- PowerShell MCP Server (Windows commands)
- Memory MCP Server (Persistent notes)
- File MCP Server (File operations)
- Git MCP Server (Version control)
- Any other MCP servers
๐ Documentation
Project Structure
linux-bash-mcp-server/
โโโ src/
โ โโโ index.js # Main MCP server
โโโ test/
โ โโโ test.js # Comprehensive tests
โโโ examples/
โ โโโ system_info.sh # Example monitoring script
โ โโโ file_operations.sh # Example file operations
โโโ config.json # Server configuration
โโโ setup.js # Interactive setup
โโโ debug.js # Diagnostic tool
โโโ quick-fix.js # Auto-fix utility
โโโ check-config.js # Configuration checker
โโโ README.md # This file
Version History
v1.0.0 (Current)
- โ Universal Linux distribution support
- โ Intelligent WSL distribution detection
- โ Safe configuration merging
- โ Comprehensive diagnostic tools
- โ Auto-fix utilities
- โ Enhanced error handling
- โ Debug mode support
๐ค Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Update documentation
- Submit a pull request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Support
- Issues: GitHub Issues
- Documentation: Project Wiki
- Discussions: GitHub Discussions
๐ Acknowledgments
- Anthropic for the Model Context Protocol
- Microsoft for WSL2 technology
- The open - source community for Linux distributions and tools
Made with โค๏ธ for the Claude Desktop and Linux community
โญ Star this repository if you find it useful!








