🖥️ Shell MCP Server
为Claude AI提供安全的shell命令执行MCP服务器。允许在指定目录内进行受控的shell访问。
为Claude AI添加安全的shell命令执行能力,专为Model Context Protocol构建
📥 安装
# 使用pip
pip install shell-mcp-server
# 或使用uv (推荐)
uv pip install shell-mcp-server
🔌 Claude桌面集成
添加以下配置到Claude桌面:
{
"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示例
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控制: 仅允许配置的shell
- 超时保护: 自动终止长时间运行的命令
- 路径验证: 防止目录遍历攻击
🌟 专为Model Context Protocol构建 | MIT许可证