Agent Guards

io.github.mlawsonking由 GitHub 帳號 mlawsonking 發布v0.3.0更新於 Oct 24, 2026

All six agent guard suites in one local MCP server, with optional cloud intelligence.

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

概覽

AI 產生的概覽

一個本機 MCP 伺服器,打包六套確定性防護套件,用來掃描文字、程式碼、差異、URL、郵件與套件的安全風險。

可以做什麼
在本機離線掃描提示詞與文字中的注入、越獄與 Unicode 混淆模式,並偵測密鑰與個人識別資訊並輸出脫敏結果。依正規表達式規則掃描 JS/TS 與 Python 程式碼及統一差異。分析 URL 結構,並透過防 SSRF 的抓取器取得 URL。解析郵件、讀取郵件標頭並套用偽造啟發式判斷。執行需連網的查詢:套件年齡與漏洞、制裁與黑名單、外洩密碼、網域信譽以及 SPF/DMARC/MX 記錄。另附 guard 命令列工具與用於暫存差異掃描的 pre-commit 鉤子。
適用情境
適合助理需要處理不受信任的文字、第三方程式碼、差異或 URL,並希望在採取行動前做一次確定性的本機初篩時使用。也適合希望在不把檔案內容送給模型或第三方的前提下,以 pre-commit 或命令列掃描的團隊。
執行需求
透過 npx agent-guards 以本機 stdio 程序執行,需要 Node 18 或更新版本。不需要 API 金鑰、帳號或設定。部分工具需要網路存取以進行第三方查詢(npm、PyPI、OSV、OFAC 名單、Have I Been Pwned、DNS 記錄);使用 --offline 可限制為僅本機引擎。除非停用,規則更新會連線至規則來源。
安裝前請注意
連網工具會把查詢值傳送給第三方,例如套件倉庫、制裁名單、Have I Been Pwned 與 DNS 解析器;使用 --offline 可讓資料留在本機。伺服器約每天一次連線規則來源,僅傳送呼叫介面名稱與目前規則版本,可用 AGENT_GUARDS_NO_FEED 或 --offline 關閉。偵測以模式比對為基礎,會漏掉新型措辭、未知格式的密鑰與資料流問題,因此「未發現問題」不等於安全。

安裝

在 SourceWeft 中

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

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

其他 MCP 客戶端

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

README

agent-guards core

The detection engines behind Package Guard, Agent Firewall, Payment Guard, Email Guard, Code Guard and Agent Web Tools, in one package, running on your machine.

Everything here is deterministic: regex rules, published lists, and parsers. No model is called in any detection path, so the same input gives the same verdict and every verdict names the rules version that produced it.

Run it

bash
npx agent-guards

That starts an MCP stdio server with every tool from all six products. No configuration, no API key, no account.

bash
npx agent-guards --offline          # local engines onlynpx agent-guards --only code-guard  # one productnpx agent-guards --list             # what you get, and which tools need the networknpx agent-guards --disable check_ip,check_password

The same package installs the guard CLI:

bash
npx --yes --package agent-guards guard scan src/npx --yes --package agent-guards guard diffnpx --yes --package agent-guards guard stats --json

pre-commit

This repository publishes a staged-diff hook for the pre-commit framework. It needs Node 18 or newer. Add this to .pre-commit-config.yaml:

yaml
repos:  - repo: https://github.com/mlawsonking/MCP    rev: main  # pin this to a commit SHA in a shared repository    hooks:      - id: agent-guards-diff

Then run pre-commit install. The hook scans added lines only and uses the rules in that pinned checkout. It does not call a model or send file contents anywhere. A second manual hook, agent-guards-scan, scans the whole working tree when you run pre-commit run agent-guards-scan --hook-stage manual.

Local and cloud, and why the difference matters

Local tools run entirely on your machine. The text you scan never leaves it.

Local, works offlineNeeds the network
prompt-injection and Unicode-obfuscation scanningpackage existence, age and vulnerabilities (npm, PyPI, OSV)
secret and PII detection, with redactionsanctions and scam-list screening (OFAC lists, blocklists)
code and diff scanningbreached-password lookup (Have I Been Pwned)
URL structure analysisdomain age, ASN, blocklist reputation
email parsing, spoof heuristics, header readingSPF/DMARC/MX records, disposable-domain list

Cloud tools say which service they call in their own tool description. With --offline, they report that they could not check. They do not return a verdict.

That distinction is the whole design. A check that did not run is not a pass. This codebase shipped the opposite once: four endpoints answered "not sanctioned", "no known vulnerabilities", "not a honeypot" and "safe" when the lookup behind each had failed or was never attempted. A security tool that says "clear" when it means "I don't know" is worse than no tool.

What it catches, and what it does not

The injection scanner matches known instruction-override, jailbreak, prompt-leak, exfiltration and tool-poisoning phrasings, and the Unicode tricks used to hide them: zero-width characters, bidi overrides, the Unicode tag block, hidden CSS, instructions in HTML comments. It is a deterministic pattern scanner, not a classifier. Novel phrasing gets through. Anyone who reads the rules can write around them. It is one layer, not a wall.

The secret scanner matches 22 credential formats plus generic assignments and 3 PII patterns. A secret in a format it does not know, or split across lines, is not detected. What it does guarantee is that the value it found is gone from the redacted output, not just the label next to it.

The code scanner is 31 regex rules across JS/TS and Python. No parser, no data flow, no taint tracking, so exec(cmd) with a bare variable does not fire while exec("ls " + dir) does. That is a deliberate limit and there is a test pinning it.

Sanctions screening covers the EVM-format OFAC address lists. Honeypot checks only cover the chains honeypot.is actually simulates.

Using it as a library

js
const guards = require('agent-guards');
guards.injection.scan(untrustedText);      // { risk, score, verdict, findings, rules_version }guards.secrets.scan(text);                 // { found, verdict, findings, redacted, rules_version }guards.code.scanDiff(unifiedDiff, 'py');   // findings against new-file line numbersawait guards.safeFetch(url);               // SSRF-guarded: pins the resolved IP, rechecks every hop

safeFetch is the one to reach for whenever you fetch a URL you did not choose. It resolves the hostname once, refuses the request if anything it resolves to is private or loopback, and connects to that exact address, so there is no second lookup for DNS rebinding to poison. It re-checks every redirect hop and never pools sockets, because a pooled connection skips the pin.

Rule updates

The rules go stale. Addresses get sanctioned, packages get pulled from npm for shipping malware, and none of that reaches you if the rules only change when you reinstall. So about once a day the server and the CLI ask the rules feed whether there is a newer ruleset, and apply it if there is.

A pull sends two things: which surface asked (cli, plugin, mcp or facade) and the rules version you already have.

GET /api/rules/latest?surface=mcp&have=2026.07.31

No machine id, no user id, no file names, nothing you scanned. Bundles are signed with Ed25519 and verified against a public key compiled into this package, so it does not matter which mirror served one. A bundle that fails its signature, its schema, or its ReDoS check is discarded and you keep the rules you had. Rules never roll back to an older version on their own.

bash
guard update --status     # what is in use, and when it last checkedguard update              # pull now

Every verdict carries rules_provenance, which is either bundled or feed@<version>, so you can always tell which ruleset produced a result.

To turn updates off: --offline, AGENT_GUARDS_NO_FEED=1, or {"feed": false} in ~/.agent-guards/config.json. AGENT_GUARDS_FEED_URL points it somewhere else. With updates off everything still works on the rules compiled into the package.

The bundle format, the verification steps, and how the malicious-package list is curated are in rules/README.md.

Tests

bash
npm test

Offline suites only. Anything that asserts against a third-party endpoint is run by hand, because a suite that goes red at random teaches everyone to ignore red.

Licence

MIT.

來源:agent-guards/README.md,提交 91f3fa7

工具

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

版本歷史

1
  1. v0.3.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

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

  • 近 30 天內可連通25 分

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

  • 已宣告認證方式10 分

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

  • 已列出工具15 分

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

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