Secure shell command execution for AI applications with cross-platform, secure, and configurable features
Shell MCP Server is a powerful and secure tool designed to integrate shell command execution capabilities into your AI applications through the Model Context Protocol (MCP). Built specifically for developers who need reliable, controlled access to system commands within an application environment, this server ensures that all commands run in specified directories, enhancing security and reliability. The Shell MCP Server supports multiple shells—bash, sh, cmd, and powershell—and includes features such as timeout control and safe default modes, making it a comprehensive solution for AI applications needing secure shell command execution.
The Shell MCP Server offers several key features that align perfectly with the Model Context Protocol (MCP) requirements:
graph TD
A[AI Application] -->|MCP Client| B[MCP Server]
B --> C[Shell Command Execution Environment]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#f3e5f5
style D fill:#e8f5e8
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
{
"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"
]
}
}
}
Install the Shell MCP Server via pip or use uv
for recommended installation:
# Using pip
pip install shell-mcp-server
# Using uv (recommended)
uv pip install shell-mcp-server
Perform common file operations such as listing directory contents and finding specific files.
# 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"
)
Execute standard project management tasks like running Git operations and package 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"
)
Retrieve system information such as resource usage and process monitoring.
# 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"
)
Manipulate files and perform content searches.
# 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"
)
Execute specific commands on Windows.
# 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"
)
Integrate the Shell MCP Server into your MC clients like Claude Desktop, Continue, and Cursor by adding appropriate 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"
]
}
}
}
The Shell MCP Server is tested and compatible with a range of environments and tools:
Compatibility | Supported Tools | Status |
---|---|---|
Bash | ✅ | Full |
Zsh | ✅ | Full |
CMD/POWERSHELL | ✅ | Full |
Configure the server using command-line arguments to tailor its behavior:
directories
: List of allowed directories--shell name path
: Shell specifications (name and path)COMMAND_TIMEOUT=30s # Default timeout is 30 seconds
Q1: How do I secure my shell command execution environment? A1: The Shell MCP Server provides robust security features such as directory isolation, shell control, and timeouts to ensure a safe, controlled execution environment.
Q2: What shells are supported by the server? A2: Supported shells include bash, sh, cmd, and powershell. You can configure multiple shells for different needs within your application.
Q3: How do I troubleshoot command timeout issues?
A3: Timeout issues can be resolved by adjusting the COMMAND_TIMEOUT
environment variable to a higher value or investigating long-running processes that may cause delays.
Q4: Can I use this server with Windows environments? A4: Yes, the Shell MCP Server supports both Unix and Windows systems. Detailed configurations are provided for Windows-specific needs.
Q5: How do I integrate this server into an existing AI application? A5: Integration involves configuring your MCP client to include the Shell MCP Server details in its configuration file as shown in the compatibility matrix section.
Contributions are welcome! Below are steps for contributing:
Explore more about Model Context Protocol (MCP) and its ecosystem:
MIT License - see LICENSE for details.
🎉 Star us on GitHub!
If you find this tool useful, consider giving it a star or sharing feedback to help improve our offerings.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods