Execute a shell command with optional stdin input, working directory, and timeout
Shell Command Executor provides a secure way to execute shell commands through a Model Context Protocol (MCP) server. It allows for remote execution of whitelisted shell commands with support for stdin input, working directory specification, and timeout controls. The server implements robust security measures including command whitelisting and shell operator validation to prevent unauthorized command execution.
Shell Command Executor is a secure MCP server that allows AI assistants to execute shell commands on your system in a controlled manner. It provides a safe interface for running commands with comprehensive security features to prevent unauthorized access or potentially harmful operations.
You can install the Shell Command Executor in several ways:
pip install mcp-shell-server
For an automated installation with Claude Desktop:
npx -y @smithery/cli install mcp-shell-server --client claude
To configure the Shell Command Executor, you need to specify which commands are allowed to be executed. This is done through the ALLOW_COMMANDS
(or its alias ALLOWED_COMMANDS
) environment variable.
Edit your Claude Desktop configuration file:
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
Add the following configuration:
{
"mcpServers": {
"shell": {
"command": "uvx",
"args": [
"mcp-shell-server"
],
"env": {
"ALLOW_COMMANDS": "ls,cat,pwd,grep,wc,touch,find"
}
}
}
}
The ALLOW_COMMANDS
variable accepts a comma-separated list of commands:
ALLOW_COMMANDS="ls,cat,echo" # Basic format
ALLOWED_COMMANDS="ls ,echo, cat" # With spaces (using alias)
ALLOW_COMMANDS="ls, cat , echo" # Multiple spaces
The Shell Command Executor implements several security measures:
The AI assistant can use the Shell Command Executor to run various commands:
Basic command execution:
Input processing:
grep
or wc
File operations:
For local development or custom setups, you can configure the server with additional options:
{
"mcpServers": {
"shell": {
"command": "uv",
"args": [
"--directory",
".",
"run",
"mcp-shell-server"
],
"env": {
"ALLOW_COMMANDS": "ls,cat,pwd,grep,wc,touch,find",
"TIMEOUT": "30" // Default timeout in seconds
}
}
}
}
The repository includes a Dockerfile for containerized deployment. This can be useful for running the server in isolated environments or cloud deployments.