Makefile MCP

io.github.ai-ronin-systems由 GitHub 帳號 ai-ronin-systems 發布v0.3.0更新於 Oct 25, 2026

Expose trusted GNU Make targets as governed MCP tools without a generic shell.

已驗證STDIO僅桌面開發者工具安全與監控

概覽

AI 產生的概覽

把現有的 GNU Makefile 轉成具型別的 MCP 工具,讓助理只能執行獲准的 make 目標,而不是取得通用 shell。

可以做什麼
  • 列出並檢視倉庫 Makefile 中探索到的 Make 目標
  • 以 MCP 工具執行已暴露的目標,可為每個目標產生獨立工具,或透過通用的列出、描述、執行呼叫
  • 在治理模式下僅允許執行白名單中的情境與目標組合,並驗證具型別的輸入
  • 對標記為危險的工作要求人工核准,並寫入具雜湊鏈的稽核紀錄
  • 以 GNU Make 試跑預覽目標,並用 doctor 指令檢查設定
適用情境
適合希望讓 AI 助理透過 Make 執行倉庫既有的測試、檢查、建置或部署目標,而不給它任意 shell 的情境。特別適合已把自動化放在 Makefile 中,並希望對代理可執行的內容做明確暴露、核准與稽核的團隊。
執行需求
在 Linux 或 macOS 上以本機程序執行(不支援 Windows),需要 Python 3.11+ 與 GNU Make,可透過 uvx 或 pipx 啟動。未宣告任何驗證或環境變數。治理模式需要 .makefile-mcp.yaml 政策檔,修改政策後須重新啟動。
安裝前請注意
Makefile 中的配方屬於受信任程式碼,未做沙箱隔離,因此惡意或有缺陷的 Makefile 不受保護。已暴露的目標仍可能具破壞性,危險工作仰賴 MCP 用戶端真的向人請求核准。稽核紀錄可被同一使用者的其他程序改寫,預覽只是試跑而非沙箱。若代理能修改未固定的 Make 程式碼或腳本,等於取得 shell。

安裝

在 SourceWeft 中

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

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Makefile MCP

[PyPI] [Python] [CI] [License]

Expose trusted GNU Make targets to AI agents — without exposing a generic shell or replacing Make with another workflow system.

Makefile MCP turns an existing Makefile into typed MCP tools. It is zero-config and run-safe by default, and deny-by-default when governed.

text
Makefile  →  Makefile MCP  →  Codex / Claude / LangChain / Cursor / VS Code / MCP client

Threat model

Design for a compromised agent: any text it reads can carry a prompt injection. Makefile MCP keeps the worst case short. A hijacked agent can run only the targets you listed, with values you typed, and a human approves the risky ones. Read the threat model for the threats, controls, tests that prove them, and limits.

ProtectedNot protected
Agents cannot run arbitrary shell commands, only exposed Make targets.A malicious or buggy Makefile: recipes are trusted code, not sandboxed.
Without config, agents can only run test, lint, check, and fmt.A target the operator chose to expose doing something destructive.
Governed mode runs only allow-listed (context, target) pairs with typed, validated inputs.Host or container privileges granted outside Makefile MCP.
dangerous tasks need explicit human approval through the MCP client; no approval, no run.An MCP client that auto-approves elicitation without a human.
Every governed run attempt, refused, approved, or cancelled, can be written to an audit log, with secret inputs masked.Secrets a recipe prints in ways that differ from the input value.
The approval prompt shows the exact arguments; agent-supplied text cannot reshape it.An agent that can edit unpinned Make code or scripts: editing a recipe is a shell.
With pin, any edit to the Makefile, its includes, or listed scripts stops the server until a human restarts it.Prompt injection in output the agent does read; agent_output: tail or none narrows it.
Audit records are hash-chained; doctor reports edits. A CI test replays a hijacked agent.A same-user process rewriting the whole log and its chain.

Details: threat model, SECURITY.md, and security model.

Quick start

bash
pipx install makefile-mcp        # or: uv tool install makefile-mcpmakefile-mcp serve

Given:

make
test: ## Run tests	pytest -q
lint: ## Run lint	ruff check .

Makefile MCP exposes make_test and make_lint as MCP tools. Other targets are listed but not runnable until you govern them.

bash
makefile-mcp listmakefile-mcp doctormakefile-mcp run testmakefile-mcp run test --preview   # GNU Make --dry-run; not a sandbox

One-shot use: uvx makefile-mcp serve.

Why Makefile MCP

Makefile MCP is intentionally narrow: the repository's Makefile remains the executable source of truth, while Makefile MCP supplies a governed agent-facing capability boundary.

PrincipleWhat it means
Make stays authoritativeNo duplicate workflow DSL, plugin command language, scheduler, database, or second execution engine.
No generic shell capabilityAgents invoke discovered or explicitly governed Make targets, not arbitrary host commands.
Trusted Makefile, untrusted invocationRepository automation is trusted; caller-selected tasks and declared values are authorized, validated, and bounded. GNU Make's own variable/function semantics are treated as an interpreter boundary.
One execution pathCLI, direct MCP tools, generic MCP tools, preview, contexts, and capabilities share the same catalog, authorization, validation, and executor.
Conservative discoveryMakefile MCP statically exposes only Make syntax it can classify confidently; ambiguous constructs are omitted rather than guessed.
Bounded Unix runtimeForeground execution has bounded input/output, timeout/cancellation cleanup, stdin isolation, process-group handling, and physical-context locking.

See Design rationale for the full capability/property map and the alternatives deliberately left out.

Architecture

text
                         Makefile                            |                    conservative catalog                            |              +-------------+-------------+              |                           |            auto                       governed         no config                   .makefile-mcp.yaml              |                           |              +-------------+-------------+                            |                       Application                  +---------+---------+                  |                   |              MCP direct         MCP generic                  +---------+---------+                            |                         Executor                            |                      exact `make -f`

One catalog. One execution path. Thin CLI and MCP adapters.

See Architecture.

Governed mode

Without .makefile-mcp.yaml, Makefile MCP runs in auto mode: every conservatively discovered root target is listed, but only test, lint, check, and fmt can run, with no caller-controlled Make variables. --legacy-auto-run restores the old run-everything behavior (deprecated).

Add .makefile-mcp.yaml to switch to explicit governance:

yaml
schema_version: 1
contexts:  backend:    directory: backend
tasks:  test:    contexts: [root, backend]    risk: safe
  deploy:    risk: dangerous    variables:      ENV:        type: enum        values: [staging, production]        required: true
capabilities:  verify: test
audit:  path: .makefile-mcp/audit.jsonl
pin:  paths: [scripts]       # freeze Make code and scripts the agent must not change

Only enabled (context, target) pairs are callable. dangerous tasks additionally need human approval (defaults.require_approval), and audit writes one JSON line per call. See Governed mode, Configuration, and Contexts and capabilities.

MCP presentations

Makefile MCP supports three MCP presentations over the same callable catalog. Choose the presentation that best fits your requirements.

bash
makefile-mcp serve --tools direct    # default: one typed tool per callable targetmakefile-mcp serve --tools generic   # list_tasks / describe_task / run_taskmakefile-mcp serve --tools both      # both views, same execution core

See MCP presentations and client setup.

Security

Makefile MCP assumes the repository, Makefiles, included Make code, wrapper scripts, and provisioned tools are trusted operator-controlled code. The security boundary is the invocation: an MCP/CLI caller chooses an exposed task/context and, in governed mode, supplies declared values. Makefile MCP authorizes and validates that request; it does not sandbox hostile Makefiles.

Runtime bounds, cancellation/process-group cleanup, stdin isolation, and locking are primarily execution-correctness properties. They limit failure modes around trusted automation rather than turning Make into a sandbox. The built-in MCP server is stdio-only: no HTTP listener, remote-auth layer, TLS, tenancy, or network-service lifecycle is hidden inside the product.

See SECURITY.md for the security policy, reporting process, trust boundary, and limitations. Detailed implementation notes are in docs/security.md.

Intentional scope limits

  • GNU Make on Linux/macOS; Windows is not currently supported.
  • Trusted repository assumption: Makefiles, includes, scripts, and provisioned tools are operator-controlled code.
  • Static discovery is deliberately conservative, not a complete GNU Make parser.
  • Preview is GNU Make dry-run, not sandboxing; Make evaluation can still have side effects.
  • Direct tool inventory is registered at startup; generic catalog calls can observe supported Makefile changes.
  • .makefile-mcp.yaml is startup policy; changes require restart and fail closed until then.
  • Foreground/bounded tasks only; deliberately detached daemons are outside Makefile MCP's process-group containment model.
  • No HTTP server, auth stack, scheduler, job queue, workflow persistence, plugin execution framework, or arbitrary shell tool.
  • Reload behavior:
    • .makefile-mcp.yaml is startup policy. Restart Makefile MCP after adding, removing, or editing it.
    • Makefile discovery refreshes when the conventional Makefile or tracked literal includes change.
    • Generic calls see the refreshed catalog immediately.
    • Direct tool inventory is a startup snapshot: adding or removing direct tools requires a restart. Existing direct tools still re-check the live catalog when invoked.

Requirements

Python 3.11+ · GNU Make · Linux or macOS

Documentation

  1. Threat model — why agents should not get a shell, threats and controls, the policy and audit log, guarantees and limits. Start here.
  2. Architecture — runtime flow, responsibilities, lifecycle, invariants, and dependency rules.
  3. Design rationale — key tradeoffs, full product-property map, and deliberately rejected alternatives.
  4. CLI reference — commands, options, result model, root detection, and exit codes.
  5. Configuration — authoritative .makefile-mcp.yaml fields, defaults, approval, audit log, and precedence.
  6. Static Make discovery — supported syntax, fail-closed behavior, includes, limitations, and cache semantics.
  7. Governed mode — explicit exposure, typed inputs, risk metadata, human approval, and operating model.
  8. MCP presentations — direct, generic, both, schemas, result/error semantics, naming, and lifecycle.
  9. Contexts and capabilities — monorepo scoping, (context, target) authorization, and semantic mappings.
  10. MCP client setup — Codex, Claude Code, LangChain/LangGraph, Cursor, VS Code, and uvx examples.
  11. Security — trust boundary, Make input safety, arbitrary strings, discovery, environment/path controls, and execution bounds.
  12. Development — contributor workflows, code ownership, regression expectations, and Definition of Done.
  13. Deployment — Docker/stdio deployment, production checklist, and provisioning custom tools plus Makefiles.
  14. Releasing — version/tag contract, clean-package smoke test, PyPI Trusted Publishing, provenance, GitHub Releases, and MCP Registry metadata.

Security reporting: SECURITY.md. Contributing: CONTRIBUTING.md.

來源:README.md,提交 f08160c

工具

0
SourceWeft 曾在隔離沙箱中以無憑證方式啟動該軟體包一次,以列出其工具,但未能完成:伺服器未能啟動。

版本歷史

2
  1. v0.3.0最新Oct 25, 2026
  2. v0.2.2Oct 15, 2026

評分

已滿足適用檢查項的 50%

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

  • 近 30 天內可連通25 分

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

  • 已宣告認證方式10 分

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

  • 已列出工具15 分

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

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