Shell MCP Server
The Shell MCP Server enables AI applications to securely execute shell commands across Unix and Windows systems. It provides secure command execution restricted to pre-approved directories with built-in validation to prevent directory traversal attacks. The server supports multiple shells (bash, sh, cmd, powershell) and includes timeout control to automatically terminate long-running commands. Key capabilities include basic file operations (listing directories, finding files, content manipulation), project management (Git operations, package management), system monitoring (resource usage, process details), and general command execution with the same permissions as the server process for security isolation.
Allows execution of git commands for repository management, including viewing repository status and differences between commits.
Enables secure execution of shell commands in specified directories with support for multiple shell types, timeout control, and built-in security features to safely run system commands for file operations, git commands, package management, and system monitoring.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Shell MCP Serverlist all Python files in my project directory"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
🖥️ Shell MCP Server
🚀 Add secure shell command execution capabilities to your AI applications with the Shell MCP Server! Built for the Model Context Protocol.
✨ Features
🔒 Secure Execution - Commands run only in specified directories
🐚 Multiple Shells - Support for bash, sh, cmd, powershell
⏱️ Timeout Control - Automatic termination of long-running commands
🌍 Cross-Platform - Works on both Unix and Windows systems
🛡️ Safe by Default - Built-in directory and shell validation
Related MCP server: Terminal MCP Server
🚀 Quick Start
Installation
# Using pip
pip install shell-mcp-server
# Using uv (recommended)
uv pip install shell-mcp-server🔌 Claude Desktop Integration
Add this to your Claude Desktop config to enable shell command execution:
{
"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"
]
}
}
}🎮 Usage Examples
Basic File Operations
# 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"
)Project 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"
)System Information
# 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"
)File Processing
# 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"
)Windows-Specific Examples
# 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"
)⚙️ Configuration
Configure behavior with command-line arguments:
Argument | Description |
| 📁 List of allowed directories |
| 🐚 Shell specifications (name and path) |
Environment variables:
COMMAND_TIMEOUT: ⏱️ Max execution time in seconds (default: 30)
🛡️ Security Features
🔐 Directory Isolation: Commands can only execute in specified directories
🔒 Shell Control: Only configured shells are allowed
⏰ Timeout Protection: All commands have a configurable timeout
🛑 Path Validation: Working directory validation prevents traversal attacks
👤 Permission Isolation: Commands run with the same permissions as the server process
🛠️ Development
Set up your development environment:
# Create and activate virtual environment
uv venv
source .venv/bin/activate
# Install development dependencies
uv pip install -e ".[test]"
# Run tests
python -m pytest
# Run tests with coverage
python -m pytest --cov=shell_mcp_server🤝 Contributing
Contributions are welcome! Feel free to:
🐛 Report bugs
💡 Suggest features
🔧 Submit pull requests
📚 Improve documentation
📜 License
MIT License - see LICENSE for details.
🌟 Enhance Your AI with Secure Shell Access! 🌟
Built for the Model Context Protocol | Made with ❤️ by the MCP Community
Available Tools
1 toolexecute_commandB
Execute a shell command in a specified directory using a specified shell
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | The shell command to execute | |
| shell | Yes | Shell to use for execution. Available: ['bash', 'sh'] | |
| cwd | Yes | Working directory for command execution |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'execute a shell command' implies a potentially risky operation, the description lacks critical details such as security implications, error handling, output format, or execution limits. It fails to address what happens if the command fails or how results are returned.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that directly states the tool's purpose without any unnecessary words. It is front-loaded and appropriately sized for its function, with zero waste.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity of executing shell commands (a high-risk operation with no annotations and no output schema), the description is insufficient. It lacks details on behavioral traits, error handling, security warnings, and output expectations, making it incomplete for safe and effective use by an AI agent.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, meaning the input schema already documents all parameters thoroughly. The description adds no additional meaning beyond what the schema provides, such as examples or edge cases. However, it does not contradict the schema, so it meets the baseline for high coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the specific action ('execute a shell command') and resources involved ('in a specified directory using a specified shell'). It uses precise verbs and distinguishes what this tool does without ambiguity, even though there are no sibling tools to differentiate from.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives, prerequisites, or any context for its application. It simply states what the tool does without indicating appropriate scenarios or constraints.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
1 tool update
- First observed
execute_command
TDQS
With only one tool, there is no possibility of ambiguity or overlap between tools. The single tool has a clear and distinct purpose.
A single tool inherently has perfect naming consistency, as there are no other tools to compare it against for patterns or conventions.
A single tool is generally too few for a server's purpose, as it limits functionality and scope. For a shell server, this feels thin and may not cover common use cases effectively.
The tool surface is severely incomplete for a shell domain. It lacks operations for file management, process control, environment variables, or other common shell tasks, leading to significant gaps that will cause agent failures.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
- emisarOAuthdev.emisar
Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
Security gateway for AI agents: policy, approval, and audited execution, no secrets shared.
Related MCP Servers
- AlicenseBqualityCmaintenanceA secure server for executing terminal commands within predefined paths, allowing safe interaction by Large Language Models with operating system environments.111017MIT
- FlicenseNot gradedqualityDmaintenanceEnables safe execution of terminal commands across different shells (bash, cmd, PowerShell) with configurable timeouts, working directories, and resource limits for command-line operations through AI assistants.-
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables users to execute arbitrary shell commands through a terminal tool. It supports custom working directories, configurable execution timeouts, and safe command parsing using shlex.-
- AlicenseAqualityFmaintenanceEnables AI assistants to execute terminal commands on a host machine with configurable, granular permission controls and safety protections. It features multiple security modes, including allowlists and manual approval, to ensure safe command execution within specified directories.6Apache 2.0
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/blazickjp/shell-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server