
Bash Command Mcp
io.github.mrorigo由 GitHub 账号 mrorigo 发布v1.0.0更新于 Oct 27, 2026
Sophisticated bash command MCP server that runs and manages shell execution.
概览
本地 MCP 服务器,让助手在你的机器上执行 shell 命令,并支持带日志的后台任务、等待与终止。
- 可以做什么
- 在前台运行 shell 命令,可指定超时、工作目录和环境变量
- 以后台进程方式启动命令,并将标准输出和错误写入日志文件
- 列出已跟踪的后台进程并查看其日志末尾内容
- 等待后台进程结束,或按进程 ID 终止它
- 为工具调用、超时和后台生命周期输出 OpenTelemetry 追踪与指标
- 适用场景
- 适合需要助手在本机执行构建、测试、脚本或系统命令,并管理长时间运行进程的场景,而不只是读写文件。
- 运行要求
- 作为本地进程运行,通常通过 npx 使用已发布的 npm 包,或用 Bun 从源码启动;需要 Node.js 或 Bun。可选环境变量用于配置日志目录(BASH_COMMAND_MCP_LOG_DIR)和 OpenTelemetry(OTEL_ENABLED、OTEL_EXPORTER_OTLP_ENDPOINT、OTEL_SERVICE_NAME、OTEL_SERVICE_VERSION、OTEL_METRIC_EXPORT_INTERVAL_MS)。HTTP 模式使用 BASH_COMMAND_MCP_TRANSPORT、BASH_COMMAND_MCP_HOST、BASH_COMMAND_MCP_PORT 和 BASH_COMMAND_MCP_ALLOWED_HOSTS。
安装
在 SourceWeft 中
- 打开 控制台中的 Bash Command Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
bash-command-mcp
A highly sophisticated Bash MCP server for safe, structured command execution with first-class background job orchestration.
Important Security Warning
This server executes shell commands on the machine where it is running.
If you run bun run index.ts directly on your host, commands run on your host with your user permissions.
Use Docker to isolate execution unless you fully trust the MCP client and prompts.
To install dependencies:
To run over stdio:
To run over Streamable HTTP:
To run via npm/npx (published package):
Why This Server
- High-fidelity shell execution with clear exit-code semantics.
- Advanced background process lifecycle controls (
run_background,wait_background,kill_background). - Built-in observability via per-process stdout/stderr log files.
- OpenTelemetry traces and metrics for production visibility.
- Agent-friendly ergonomics with
cwdandenvoverrides for precise execution context.
Tool Behavior
Tools:
run: run command in foreground. Args:commandorcmd,timeoutSeconds(default60, min1; values above86400are capped with a hint), optionalcwd, optionalenv.run_background: start command in background with stdout/stderr written to log files. Args:commandorcmd, optionalcwd, optionalenv.list_background: list tracked background processes, including log file paths.kill_background: stop tracked background process bypid.tail_background: show last N lines from background process logs. Args:pid, optionallines(default200, max5000).wait_background: wait for background process completion and return final status/output. Args:pid, optionaltimeoutSeconds(default60, min1; values above86400are capped with a hint).
OpenTelemetry
This server includes built-in OpenTelemetry instrumentation for traces and metrics.
- OpenTelemetry packages are installed with the server package.
- Telemetry initializes unless
OTEL_ENABLED=false. - If
OTEL_EXPORTER_OTLP_ENDPOINTis set, traces/metrics are exported via OTLP HTTP. - If no OTLP endpoint is configured, console exporters are used.
Instrumented operations:
- Tool call spans for
run,run_background,list_background,tail_background,wait_background, andkill_background. - Background lifecycle spans/counters (
started,ended). - Metrics for tool calls, failures, timeouts, and duration histograms.
Common env vars:
OTEL_ENABLED=true|falseOTEL_SERVICE_NAME=bash-command-mcpOTEL_SERVICE_VERSION=1.0.0OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318OTEL_METRIC_EXPORT_INTERVAL_MS=10000BASH_COMMAND_MCP_LOG_DIR=/path/to/log-dir
Example (OTLP Collector on localhost):
Transports
This server supports two transports:
stdiofor local, process-spawned integrations.httpfor remote or network-accessible MCP clients using Streamable HTTP.
Default behavior remains stdio so existing desktop and CLI setups keep working.
Environment variables for HTTP mode:
BASH_COMMAND_MCP_TRANSPORT=http|stdioBASH_COMMAND_MCP_HOST=127.0.0.1BASH_COMMAND_MCP_PORT=3000BASH_COMMAND_MCP_ALLOWED_HOSTS=localhost,127.0.0.1,[::1]
HTTP mode uses host-header validation by default when bound to a loopback address. If you bind to 0.0.0.0 or ::, provide an explicit allow-list in BASH_COMMAND_MCP_ALLOWED_HOSTS.
Docker
Build the image:
Run with a local folder mounted at /workspace:
Run over Streamable HTTP:
/workspace mapping explained:
- Left side (
$(pwd)) is a folder on your host machine. - Right side (
/workspace) is the path inside the container. - Commands run by this MCP server should target files under
/workspace; those changes are written back to the mapped host folder.
For HTTP mode in Docker, bind to 0.0.0.0 and publish the port with -p. If you expose the container beyond localhost, set BASH_COMMAND_MCP_ALLOWED_HOSTS to the hostnames you want to permit.
Example:
- If your host has
./project/file.txtand you run the container from./project, the same file is available in the container at/workspace/file.txt.
来源:README.md,提交 1770662
工具
0版本历史
1- v1.0.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分