Bash MCP服务器
   
A. 模型上下文协议 执行bash命令的(MCP)服务器。返回每个命令的stdout、stderr、退出代码和执行持续时间。
安装
安装时使用 篮子:
mpak install @nimblebraininc/bash克劳德代码
claude mcp add bash -- mpak run @nimblebraininc/bash克劳德桌面
添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"bash": {
"command": "mpak",
"args": ["run", "@nimblebraininc/bash"]
}
}
}看 mpak注册表页 获取完整安装选项。
工具
bash-exec
执行bash命令并返回stdout、stderr、退出代码和持续时间。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
command | string | Yes | 要执行的bash命令 |
cwd | string | 否 | 工作目录(默认为服务器的cwd) |
timeout | integer | 否 | 超时时间(秒)(默认值: 30,最大值: 600) |
env | object | 否 | 要设置的其他环境变量 |
示例调用:
{
"name": "bash_exec",
"arguments": {
"command": "ls -la /tmp",
"timeout": 10
}
}示例响应:
{
"stdout": "total 0\ndrwxrwxrwt 12 root wheel 384 Jan 15 12:00 .\ndrwxr-xr-x 6 root wheel 192 Jan 1 00:00 ..\n",
"stderr": "",
"exit_code": 0,
"duration_ms": 12
}安全模型
此服务器执行任意bash命令。安全是 部署安全:服务器本身没有允许列表或沙盒。相反,安全性是由部署环境强制执行的:
- 篮子:用户批准MTF权限(
subprocess: "full")安装时 - 容器:Linux命名空间、cgroups和网络策略限制了命令可以执行的操作
- 克劳德桌面:在用户自己的操作系统权限下运行
MTF许可声明(subprocess: "full", filesystem: "full", network: "full")准确反映了bash命令可以读/写文件和进行网络调用。
快速开始
本地开发
git clone https://github.com/NimbleBrainInc/mcp-bash.git
cd mcp-bash
# Install dependencies
uv sync
# Run the server (stdio mode)
uv run python -m mcp_bash.server
# Or run via FastMCP
uv run fastmcp run src/mcp_bash/server.py服务器支持HTTP传输:
- 健康检查:
GET /health - MCP端点:
POST /mcp
发展
# Install with dev dependencies
uv sync --group dev
# Run unit tests
make test
# Run with coverage
make test-cov
# Run all checks (format, lint, typecheck, unit tests)
make check
# Format
uv run ruff format .
# Lint
uv run ruff check .E2E测试
端到端测试验证了完整的MCPB包生命周期:构建包、将其部署到Docker容器中,以及通过HTTP调用工具。
先决条件: Docker正在运行, mcpb 已安装CLI(npm install -g @anthropic-ai/mcpb)
make test-e2e测试:
- Docker容器Linux架构的供应商依赖关系
- 建立一个
.mcpb捆绑销售mcpb pack - 通过HTTP提供捆绑包
- 开始a
nimbletools/mcpb-python下载并运行捆绑包的容器 - 验证
/health端点、MCP工具列表和通过流式HTTP调用工具
关于
许可证
麻省理工学院
