Skip to main content
Glama
Linux Bash MCP Server

Linux Bash MCP Server

by gunjanjp

Linux Bash MCP Server

Version License Node.js

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!

Related MCP server: Desktop Commander MCP

✨ 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

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:

  1. Fork the repository

  2. Create a feature branch

  3. Make your changes

  4. Add tests if applicable

  5. Update documentation

  6. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

πŸ™ 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!

Available Tools

6 tools
check_wsl_statusB

Check WSL2 status and get distribution information

Inputs: no named parameters.

create_bash_scriptC

Create a bash script file with specified content

Inputs: scriptPath (required), content (required), executable.

execute_bash_commandC

Execute a bash command in WSL2 Linux environment

Inputs: command (required), workingDirectory, timeout.

execute_bash_scriptC

Execute a bash script file in WSL2 Linux environment

Inputs: scriptPath (required), args, workingDirectory, timeout.

get_system_infoB

Get system information about the WSL2 Linux environment

Inputs: no named parameters.

list_directoryB

List contents of a directory in WSL2 Linux environment

Inputs: path, detailed.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no ambiguity: checking WSL status, creating scripts, executing commands, executing scripts, getting system info, and listing directories. The descriptions clearly differentiate between command execution, script handling, and system operations.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern with snake_case naming (e.g., check_wsl_status, execute_bash_command). The naming convention is uniform throughout the set, making it predictable and easy to understand.

    Tool Count5/5

    With 6 tools, this is well-scoped for a Linux/bash server focused on WSL2 operations. Each tool earns its place by covering essential functions like command execution, script management, and system inspection without being overwhelming or too sparse.

    Completeness4/5

    The toolset provides good coverage for core WSL2/bash operations, including execution, scripting, and system info. A minor gap exists in file manipulation (e.g., create/delete files beyond scripts) and process management, but agents can work around this using existing tools like execute_bash_command.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      A custom Model Context Protocol server that gives Claude Desktop and other LLMs access to file system operations and command execution capabilities through standardized tool interfaces.
      23
      Apache 2.0
    • A
      license
      A
      quality
      D
      maintenance
      A server that lets Claude desktop app execute terminal commands on your computer and edit files through Model Context Protocol, featuring command execution, process management, and advanced file operations.
      19
      740,317 npm
      6
      MIT
    • F
      license
      A
      quality
      D
      maintenance
      A local Model Context Protocol server that allows LLMs to securely execute shell commands on remote Linux and Windows systems via SSH connections.
      6
      10 npm
      2
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      A server implementation for the Model Context Protocol (MCP) that allows Claude AI to execute commands through a command-line interface, enabling direct system interactions from within Claude.
      -