Cover image
Try Now
2024-12-31

Secure shell command execution MCP server for Claude AI. Enables controlled shell access within specified directories.

3 years

Works with Finder

1

Github Watches

1

Github Forks

9

Github Stars

🖥️ Shell MCP Server

PyPI version License: MIT Python Code style: black

🚀 Add secure shell command execution capabilities to your AI applications with the Shell MCP Server! Built for the Model Context Protocol.

✨ Features

  • 🔒 Secure Execution - Commands run only in specified directories
  • 🐚 Multiple Shells - Support for bash, sh, cmd, powershell
  • ⏱️ Timeout Control - Automatic termination of long-running commands
  • 🌍 Cross-Platform - Works on both Unix and Windows systems
  • 🛡️ Safe by Default - Built-in directory and shell validation

🚀 Quick Start

Installation

# Using pip
pip install shell-mcp-server

# Using uv (recommended)
uv pip install shell-mcp-server

🔌 Claude Desktop Integration

Add this to your Claude Desktop config to enable shell command execution:

📝 Click to view configuration
{
    "mcpServers": {
        "shell-mcp-server": {
            "command": "uv",
            "args": [
                "--directory",
                "/path/to/shell-mcp-server",
                "run",
                "shell-mcp-server",
                "/path/to/allowed/dir1",
                "/path/to/allowed/dir2",
                "--shell", "bash", "/bin/bash",
                "--shell", "zsh", "/bin/zsh"
            ]
        }
    }
}

🎮 Usage Examples

Basic File Operations

# List directory contents
result = execute_command(
    command="ls -la",
    shell="bash",
    cwd="/path/to/project"
)

# Find files by pattern
result = execute_command(
    command="find . -name '*.py'",
    shell="bash",
    cwd="/path/to/project"
)

Project Management

# Git operations
result = execute_command(
    command="git status && git diff",
    shell="bash",
    cwd="/path/to/repo"
)

# Package management
result = execute_command(
    command="pip list --outdated",
    shell="bash",
    cwd="/path/to/python/project"
)

System Information

# Resource usage
result = execute_command(
    command="df -h && free -h",
    shell="bash",
    cwd="/path/to/dir"
)

# Process monitoring
result = execute_command(
    command="ps aux | grep python",
    shell="bash",
    cwd="/path/to/dir"
)

File Processing

# Search file content
result = execute_command(
    command="grep -r 'TODO' .",
    shell="bash",
    cwd="/path/to/project"
)

# File manipulation
result = execute_command(
    command="awk '{print $1}' data.csv | sort | uniq -c",
    shell="bash",
    cwd="/path/to/data"
)

Windows-Specific Examples

# List processes
result = execute_command(
    command="Get-Process | Where-Object {$_.CPU -gt 10}",
    shell="powershell",
    cwd="C:\\path\\to\\dir"
)

# System information
result = execute_command(
    command="systeminfo | findstr /B /C:'OS'",
    shell="cmd",
    cwd="C:\\path\\to\\dir"
)

⚙️ Configuration

Configure behavior with command-line arguments:

Argument Description
directories 📁 List of allowed directories
--shell name path 🐚 Shell specifications (name and path)

Environment variables:

  • COMMAND_TIMEOUT: ⏱️ Max execution time in seconds (default: 30)

🛡️ Security Features

  • 🔐 Directory Isolation: Commands can only execute in specified directories
  • 🔒 Shell Control: Only configured shells are allowed
  • Timeout Protection: All commands have a configurable timeout
  • 🛑 Path Validation: Working directory validation prevents traversal attacks
  • 👤 Permission Isolation: Commands run with the same permissions as the server process

🛠️ Development

Set up your development environment:

# Create and activate virtual environment
uv venv
source .venv/bin/activate

# Install development dependencies
uv pip install -e ".[test]"

# Run tests
python -m pytest

# Run tests with coverage
python -m pytest --cov=shell_mcp_server

🤝 Contributing

Contributions are welcome! Feel free to:

  • 🐛 Report bugs
  • 💡 Suggest features
  • 🔧 Submit pull requests
  • 📚 Improve documentation

📜 License

MIT License - see LICENSE for details.


🌟 Enhance Your AI with Secure Shell Access! 🌟

Built for the Model Context Protocol | Made with ❤️ by the MCP Community

🎉 Star us on GitHub!
If you find this tool useful, consider giving it a star! It helps others discover the project.

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Navid RezaeiSarchoghaei
  • Professional Flask/SQLAlchemy code guide. Follow: https://x.com/navid_re

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://tovuti.be
  • Oede knorrepot die vasthoudt an de goeie ouwe tied van 't boerenleven

  • Khalid kalib
  • Write professional emails

  • Gil kaminski
  • Make sure you are post-ready before you post on social media

  • Yasir Eryilmaz
  • AI scriptwriting assistant for short, engaging video content.

  • Daren White
  • A supportive coach for mastering all Spanish tenses.

  • oatpp
  • Anthropic’s Model Context Protocol implementation for Oat++

  • huahuayu
  • A unified API gateway for integrating multiple etherscan-like blockchain explorer APIs with Model Context Protocol (MCP) support for AI assistants.

  • ShrimpingIt
  • Micropython I2C-based manipulation of the MCP series GPIO expander, derived from Adafruit_MCP230xx

  • deemkeen
  • control your mbot2 with a power combo: mqtt+mcp+llm

  • zhaoyunxing92
  • 本项目是一个钉钉MCP(Message Connector Protocol)服务,提供了与钉钉企业应用交互的API接口。项目基于Go语言开发,支持员工信息查询和消息发送等功能。

  • justmywyw
  • Short and sweet example MCP server / client implementation for Tools, Resources and Prompts.

    Reviews

    5 (1)
    Avatar
    user_pFLV3mG0
    2025-04-15

    The MCP Terraform Assistant by guilhermeyoshida is a game-changer for anyone working with Terraform. Its intuitive interface and comprehensive support make managing infrastructure as code effortless. The automation features save me hours of manual work, and the resource documentation is extremely thorough. Highly recommended for boosting productivity and efficiency! Check it out here: https://mcp.so/server/mcp-terraform-assistant/guilhermeyoshida.