What is A robust Model Context Protocol (MCP) server for secure shell command execution.?
mcp-shell is a Model Context Protocol (MCP) server that provides secure shell command execution capabilities to AI assistants and other MCP clients. It creates a bridge between AI systems and your shell environment through the standardized MCP protocol, enabling autonomous workflows and real-world problem solving. Built on the official MCP SDK for Go, it runs isolated via Docker and includes features like command allowlists, structured responses, and audit logging.
Documentation
mcp-shell π
A robust Model Context Protocol (MCP) server that provides secure shell command execution capabilities to AI assistants and other MCP clients. In other words: the brain thinks, this runs the commands.
π§ π₯π₯οΈ Think of mcp-shell as the command-line actuator for your LLM.
While language models reason about the world, mcp-shell is what lets them touch it.
What is this?
This tool creates a bridge between AI systems and your shell environment through the standardized MCP protocol. It exposes the system shell as a structured tool, enabling autonomous workflows, tool-assisted reasoning, and real-world problem solving.
It's written in Go, integrates directly with mcp-go, and provides a clean path from thought to execution. I'm aware similar projects exist β this oneβs mine. It solves the problem the way I want it solved: minimal, composable, auditable.
Out of the box it runs isolated via Docker, but that's just a start. The roadmap includes support for optional jailing mechanisms like chroot, namespaces, and syscall-level confinement β without depending on Docker for everything.
Features
π Security First: Configurable command allowlists, blocklists, and execution constraints
π³ Docker Ready: Lightweight Alpine-based container for secure isolation
π Structured Responses: JSON-formatted output with stdout, stderr, exit codes, and execution metadata
π Binary Data Support: Optional base64 encoding for handling binary command output
β‘ Performance Monitoring: Execution time tracking and resource limits
π― Context Aware: Supports command execution with proper context cancellation
βοΈ Environment Configuration: Full configuration via environment variables
Security Features
Command Validation: Allowlist/blocklist with regex pattern matching
Execution Limits: Configurable timeouts and output size limits
User Isolation: Run commands as unprivileged users
Working Directory: Restrict execution to specific directories
Audit Trail: Complete logging of all command executions
Resource Limits: Memory and CPU usage constraints
Quick Start# Prerequisites
Go 1.23 or later
Unix-like system (Linux, macOS, WSL)
Docker (optional, for containerized deployment)
Installation
git clone https://github.com/sonirico/mcp-shell
cd mcp-shell
make install
Basic Usage
mcp-shell
# Or run locally
make run
# Run with security enabled (creates temporary config)
make run-secure
# Run with custom config file
MCP_SHELL_SEC_CONFIG_FILE=security.json mcp-shell
# Run with environment overrides
MCP_SHELL_LOG_LEVEL=debug mcp-shell
Docker Deployment (Recommended)
make docker-build
# Run in secure container
make docker-run-secure
# Run with shell access for debugging
make docker-shell
Configuration# Environment Variables
Basic server and logging configuration via environment variables:
Server Configuration
MCP_SHELL_SERVER_NAME: Server name (default: "mcp-shell π")
MCP_SHELL_VERSION: Server version (set at compile time)
make build
sudo make install-bin
# Set environment variables for basic config
export MCP_SHELL_LOG_LEVEL=info
export MCP_SHELL_LOG_FORMAT=json
export MCP_SHELL_SEC_CONFIG_FILE=/etc/mcp-shell/config.json
# Security is configured in the JSON file only\n\n# Run service
mcp-shell
Development
make install dev-tools
# Format code
make fmt
# Run tests
make test
# Run linter
make lint
# Build for release
make release
# Generate config example
make config-example
Security Considerations# β οΈ Important Security Notes
Default Mode: Runs with full system access when security is disabled (which is, of course, a terrible idea β unless you're into that).
Container Isolation: Use Docker deployment for additional security layers
User Privileges: Run as non-root user in production
Network Access: Commands can access network unless explicitly restricted
File System: Can read/write files based on user permissions