🖥️ Shell MCP Server
镜像源
通过 Shell MCP 服务器为您的 AI 应用程序安全执行 shell 命令!
📥 安装
# 使用 pip
pip install shell-mcp-server
# 或使用 uv (推荐)
uv pip install shell-mcp-server
🔌 Claude 桌面集成
将以下配置添加到 Claude Desktop 配置中:
{
"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"
]
}
}
}
🎮 使用示例
基本操作
# 列出目录内容
result = execute_command(
command="ls -la",
shell="bash",
cwd="/path/to/project"
)
# 查找文件
result = execute_command(
command="find . -name '*.py'",
shell="bash",
cwd="/path/to/project"
)
Git 操作
# 查看状态和差异
result = execute_command(
command="git status && git diff",
shell="bash",
cwd="/path/to/repo"
)
Windows 示例
# PowerShell 中获取进程
result = execute_command(
command="Get-Process | Where-Object {$_.CPU -gt 10}",
shell="powershell",
cwd="C:\path\to\dir"
)
⚙️ 配置参数
参数 | 描述 |
---|---|
directories | 允许执行命令的目录列表 |
--shell name path | shell 规格(名称和路径) |
环境变量:
COMMAND_TIMEOUT
: 最大执行时间(秒,默认:30)
🛡️ 安全特性
- 命令只在指定目录中执行
- 仅允许配置的 shell
- 所有命令都有超时保护
- 工作目录验证防止遍历攻击
📚 更详细的文档请访问 GitHub 项目页面