A secure Model Context Protocol (MCP) server that provides Linux shell command execution capabilities for Claude Desktop on Linux
- Safe Shell Execution: Execute Linux commands with proper error handling
- Directory Management: Change and query current working directory
- MCP Protocol Compliant: Full compatibility with the Model Context Protocol
- Async Architecture: Built with modern async/await patterns
- Comprehensive Testing: Well-tested with 89% code coverage
- Python 3.8 or higher
- Debian GNU/Linux 12 (bookworm) x86_64 or Later
- Claude Desktop (for integration) There is no official Claude Desktop app for Linux; the following repository works but is no longer maintained by the creator. claude-desktop-debian
git clone https://github.com/Frost26/mcp-linux-shell-server.git
cd mcp-linux-shell-server
python3 -m venv mcpEnv
source mcpEnv/bin/activate
# Install core dependencies
pip install -r requirements.txt
# Install development dependencies (optional)
pip install -r requirements-dev.txt
# Run tests to ensure everything works
python -m pytest tests/ -v --cov=linux_shell_server
The configuration file is typically located at:
~/.config/claude/claude_desktop_config.json
Add the following to your Claude Desktop config file:
{
"mcpServers": {
"linux-shell": {
"command": "/path/to/your/mcp-linux-shell-server/mcpEnv/bin/python",
"args": [
"-m",
"linux_shell_server.main"
],
"env": {
"PYTHONPATH": "/path/to/your/mcp-linux-shell-server"
}
}
}
}
Replace /path/to/your/mcp-linux-shell-server
with your actual project directory path.
Example for this project:
{
"mcpServers": {
"linux-shell": {
"command": "/home/AI/Documents/CodeProjects/mcp-linux-shell-server/mcpEnv/bin/python",
"args": [
"-m",
"linux_shell_server.main"
],
"env": {
"PYTHONPATH": "/home/AI/Documents/CodeProjects/mcp-linux-shell-server"
}
}
}
}
After updating the configuration, restart Claude Desktop to load the MCP server.
The MCP server provides three main tools:
Tool | Description | Parameters |
---|---|---|
execute_command |
Execute shell commands | command (string) |
change_directory |
Change working directory | path (string) |
get_current_directory |
Get current working directory | None |
# Run all tests
python -m pytest tests/
# Run with coverage
python -m pytest tests/ --cov=linux_shell_server --cov-report=html
# Run specific test file
python -m pytest tests/test_main.py -v
# Format code with Black
black linux_shell_server/ tests/
# Check code style with Ruff
ruff check linux_shell_server/ tests/
# Sort imports with isort
isort linux_shell_server/ tests/
mypy linux_shell_server/
- Commands are executed in the context of the user running the MCP server
- No built-in command filtering or sandboxing (use with caution)
- Error outputs are captured and returned safely
- Working directory changes are isolated to the server process
1. Claude Desktop can't connect to MCP server
- Verify the paths in your Claude Desktop config are correct
- Check that the virtual environment is properly activated
- Ensure all dependencies are installed
2. Permission errors when executing commands
- The MCP server runs with the same permissions as the user
- Ensure the user has appropriate permissions for the commands being executed
3. Module not found errors
- Verify
PYTHONPATH
is set correctly in the Claude Desktop config - Ensure the virtual environment contains all required dependencies
To run the server in debug mode for troubleshooting:
# Activate virtual environment
source yourEnv/bin/activate
# Run server directly
python -m linux_shell_server.main
This project is licensed under the MIT License