shell
Secure shell command execution MCP server for Claude AI. Enables controlled shell access within specified directories.
claude mcp add --transport stdio blazickjp-shell-mcp-server uv --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
How to use
The Shell MCP Server provides secure, sandboxed execution of shell commands for AI applications. It restricts command execution to pre-approved directories and a set of allowed shells (bash, sh, cmd, powershell), with a configurable timeout to prevent long-running processes. To use it, install the server (via pip or uv) and run it under uv as shown in the Quick Start example. The server exposes an interface that your AI tool can call with a command, a chosen shell, and a working directory. Examples in the repository show common workflows such as listing directory contents, searching files, and performing project management tasks, all while honoring directory isolation and per-command timeouts. You can integrate this MCP server with Claude Desktop or other clients by pointing them to the configured mcpServers entry, including the command (uv) and arguments to launch the server with the allowed directories and shells.
How to install
Prerequisites:
- Python 3.11 or newer
- Internet access to install packages
Installation steps:
-
Create and activate a virtual environment (optional but recommended):
Python-based setup
python -m venv .venv source .venv/bin/activate # on Unix or macOS .venv\Scripts\activate.bat # on Windows
-
Install the Shell MCP Server (Python package):
Using pip (Python package manager)
pip install shell-mcp-server
-
Alternatively, install and run using uv (recommended): uv pip install shell-mcp-server
-
Verify installation by listing installed package or running a test command as documented by the project.
-
Create your mcp_config (see JSON example) and start the server with the appropriate command and environment variables.
Additional notes
Tips and considerations:
- Ensure the directories you allow for command execution are correct and secure.
- Use the COMMAND_TIMEOUT environment variable to limit execution time per command (default is 30 seconds).
- If you update allowed shells, keep the paths to the shell executables accurate (e.g., /bin/bash, /bin/zsh).
- For Claude Desktop integration, follow the provided example to add your mcpServer entry to Claude’s config, adjusting directory and shell paths as needed.
- If you encounter permission or path validation errors, verify that the server process has access to the configured directories and that the shell paths exist on the target system.
- Development and testing can be performed in a virtual environment to avoid system-wide changes.
Related MCP Servers
mcp-vegalite
MCP server from isaacwasserman/mcp-vegalite-server
github-chat
A Model Context Protocol (MCP) for analyzing and querying GitHub repositories using the GitHub Chat API.
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
pagerduty
PagerDuty's official local MCP (Model Context Protocol) server which provides tools to interact with your PagerDuty account directly from your MCP-enabled client.
futu-stock
mcp server for futuniuniu stock
mcp -boilerplate
Boilerplate using one of the 'better' ways to build MCP Servers. Written using FastMCP