Shell MCP Server
🖥️ Shell MCP 服务器
🚀 使用 Shell MCP 服务器为您的 AI 应用程序添加安全的 Shell 命令执行功能!专为模型上下文协议构建。
✨ 特点
🔒安全执行- 命令仅在指定目录中运行
🐚多 Shell - 支持 bash、sh、cmd、powershell
⏱️超时控制- 自动终止长时间运行的命令
🌍跨平台- 适用于 Unix 和 Windows 系统
🛡️默认安全- 内置目录和 shell 验证
Related MCP server: Terminal MCP Server
🚀 快速入门
安装
# Using pip
pip install shell-mcp-server
# Using uv (recommended)
uv pip install shell-mcp-server🔌 Claude 桌面集成
将其添加到您的 Claude Desktop 配置以启用 shell 命令执行:
{
"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"
]
}
}
}🎮 使用示例
基本文件操作
# 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"
)项目管理
# 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"
)系统信息
# 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"
)文件处理
# 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 特定示例
# 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"
)⚙️ 配置
使用命令行参数配置行为:
争论 | 描述 |
| 📁 允许目录列表 |
| 🐚 Shell 规范(名称和路径) |
环境变量:
COMMAND_TIMEOUT:⏱️ 最大执行时间(秒)(默认值:30)
🛡️ 安全功能
🔐目录隔离:命令只能在指定目录中执行
🔒 Shell 控制:仅允许配置的 Shell
⏰超时保护:所有命令都有可配置的超时
🛑路径验证:工作目录验证可防止遍历攻击
👤权限隔离:命令以与服务器进程相同的权限运行
🛠️ 开发
设置您的开发环境:
# 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🤝 贡献
欢迎贡献!请随意:
🐛 报告错误
💡 建议功能
🔧 提交拉取请求
📚 改进文档
📜 许可证
MIT 许可证 - 详情请参阅许可证。
🌟 使用安全 Shell 访问增强你的 AI!🌟
为模型上下文协议构建 | 由 MCP 社区倾情打造
Available Tools
1 toolexecute_commandB
Execute a shell command in a specified directory using a specified shell
Inputs: command (required), shell (required), cwd (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 1 tool
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
Related MCP Connectors
I run shell commands on your private cloud environment (bash, sh, zsh)
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Use your own Windows, Mac or Linux computer from ChatGPT, Claude, Cursor or Gemini CLI: run commands, read, write and search files, run long processes. Your computer only makes an outgoing connection (no open ports or VPN). Read-only mode, allowed folders, blocked commands and an action log keep you in control. Free plan available.
Related MCP Servers
- AlicenseBqualityDmaintenanceA secure server for executing terminal commands within predefined paths, allowing safe interaction by Large Language Models with operating system environments.141 npm18MIT
- 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.-
- AlicenseAqualityDmaintenanceEnables 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
- AlicenseNot gradedqualityCmaintenanceProvides a secure environment for executing shell commands with restricted directory access and timeout enforcement. It includes tools for running commands, managing execution history, and isolating environment variables.24 npmMIT