
Linux Bash MCP Server
A Model Context Protocol server that enables Claude Desktop to execute bash commands and scripts in WSL2 Linux distributions on Windows.
README
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. 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 & Setup
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
}
🔧 Available Scripts
Command | Description |
---|---|
npm run fix |
Auto-fix common issues and setup |
npm run setup |
Interactive configuration wizard |
npm run debug |
Comprehensive diagnostics |
npm run test |
Test all functionality |
npm run check-config |
Verify configurations |
npm start |
Start the MCP server |
🐧 Supported Linux Distributions
- Ubuntu (most common)
- Debian
- Fedora
- openSUSE
- Alpine Linux
- Kali Linux
- Oracle Linux
- And many more...
💡 Usage Examples
Once configured, use these 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
📚 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!
推荐服务器

Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。