MCP Shell Server
A secure server for executing shell commands that implements the Model Context Protocol (MCP). This server allows remote execution of authorized shell commands with support for input via stdin.
Features
- Secure Command Execution : Only authorized commands can be executed
- Standard Input Support : Passes input to commands via stdin
- Comprehensive Output : Returns stdout, stderr, exit code and execution time
- Security with Shell Operators : Validates commands after shell operators (;, &&, ||, |)
- Timeout Control : Sets maximum execution time for commands
Configuring the MCP client in your Claude.app
Published version
Local version
Settings
Installation
Use
Starting the Server
The ALLOW_COMMANDS
environment variable (or its alias ALLOWED_COMMANDS
) specifies which commands can be executed. Commands can be separated by commas with optional spaces around them.
Valid formats for ALLOW_COMMANDS or ALLOWED_COMMANDS:
Request Format
Response Format
Successful response:
Error response:
Security
The server implements several security measures:
- Command Whitelist : Only explicitly allowed commands can be executed
- Shell Operator Validation : Commands after shell operators (;, &&, ||, |) are also validated against the whitelist
- No Shell Injection : Commands are executed directly without shell interpretation
Development
Setting Up the Development Environment
- Clone the repository
- Install dependencies including test requirements
Running Tests
API Reference
Request Arguments
Field | Type | Mandatory | Description |
---|---|---|---|
command | string[] | Yes | Command and its arguments as array elements |
stdin | string | No | Input to be passed to the command |
directory | string | No | Working directory for executing the command |
timeout | whole | No | Maximum execution time in seconds |
Response Fields
Field | Type | Description |
---|---|---|
stdout | string | Standard output of the command |
stderr | string | Command error output |
status | whole | Exit status code |
execution_time | float | Time taken to execute (in seconds) |
error | string | Error message (present only if failed) |
Requirements
- Python 3.11 or higher
- mcp>=1.1.0
License
MIT License - See LICENSE file for details
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
A secure server that implements the Model Context Protocol (MCP) to enable controlled execution of authorized shell commands with stdin support.
Related MCP Servers
- AsecurityAlicenseAqualityA secure shell command execution server implementing the Model Context Protocol (MCP). This server allows remote execution of whitelisted shell commands with support for stdin input.Last updated -174PythonMIT License
- AsecurityAlicenseAqualityA secure terminal execution server that enables controlled command execution with security features and resource limits via the Model Context Protocol (MCP).Last updated -1121JavaScriptMIT License
- AsecurityFlicenseAqualityA Model Context Protocol server implementation that enables secure remote command execution via SSH, with features for managing and using SSH credentials.Last updated -53JavaScript
- -securityAlicense-qualityAn MCP server that enables secure execution of shell commands across Windows, macOS, and Linux with built-in whitelisting and approval mechanisms for enhanced security.Last updated -13JavaScriptMIT License