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.

概覽

AI 產生的概覽

本機 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。
安裝前請注意
指令會以你的使用者權限在主機上執行,因此可讀取、修改或刪除你有權限存取的任何內容;README 建議除非完全信任 MCP 用戶端與提示詞,否則以 Docker 隔離。可啟動與終止背景程序。HTTP 模式若綁定到回送位址以外,需明確設定主機允許清單。遙測預設開啟,會匯出到設定的 OTLP 端點或主控台。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Bash Command Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

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:

bash
bun install

To run over stdio:

bash
bun run index.ts

To run over Streamable HTTP:

bash
BASH_COMMAND_MCP_TRANSPORT=http \BASH_COMMAND_MCP_HOST=127.0.0.1 \BASH_COMMAND_MCP_PORT=3000 \bun run index.ts

To run via npm/npx (published package):

bash
npx -y bash-command-mcp

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 cwd and env overrides for precise execution context.

Tool Behavior

Tools:

  • run: run command in foreground. Args: command or cmd, timeoutSeconds (default 60, min 1; values above 86400 are capped with a hint), optional cwd, optional env.
  • run_background: start command in background with stdout/stderr written to log files. Args: command or cmd, optional cwd, optional env.
  • list_background: list tracked background processes, including log file paths.
  • kill_background: stop tracked background process by pid.
  • tail_background: show last N lines from background process logs. Args: pid, optional lines (default 200, max 5000).
  • wait_background: wait for background process completion and return final status/output. Args: pid, optional timeoutSeconds (default 60, min 1; values above 86400 are 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_ENDPOINT is 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, and kill_background.
  • Background lifecycle spans/counters (started, ended).
  • Metrics for tool calls, failures, timeouts, and duration histograms.

Common env vars:

  • OTEL_ENABLED=true|false
  • OTEL_SERVICE_NAME=bash-command-mcp
  • OTEL_SERVICE_VERSION=1.0.0
  • OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
  • OTEL_METRIC_EXPORT_INTERVAL_MS=10000
  • BASH_COMMAND_MCP_LOG_DIR=/path/to/log-dir

Example (OTLP Collector on localhost):

bash
OTEL_ENABLED=true \OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 \OTEL_SERVICE_NAME=bash-command-mcp \npx -y bash-command-mcp

Transports

This server supports two transports:

  • stdio for local, process-spawned integrations.
  • http for 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|stdio
  • BASH_COMMAND_MCP_HOST=127.0.0.1
  • BASH_COMMAND_MCP_PORT=3000
  • BASH_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:

bash
docker build -t bash-command-mcp .

Run with a local folder mounted at /workspace:

bash
docker run --rm -i -v "$(pwd):/workspace" bash-command-mcp

Run over Streamable HTTP:

bash
docker run --rm -p 3000:3000 \  -e BASH_COMMAND_MCP_TRANSPORT=http \  -e BASH_COMMAND_MCP_HOST=0.0.0.0 \  -e BASH_COMMAND_MCP_PORT=3000 \  bash-command-mcp

/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.txt and you run the container from ./project, the same file is available in the container at /workspace/file.txt.

來源:README.md,提交 1770662

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.0.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分