Code Auditor Mcp

io.github.BenAHammond由 GitHub 帳號 BenAHammond 發布v5.0.2更新於 Oct 24, 2026

Enforces architectural invariants and code quality rules inside your AI agent's edit loop.

已驗證Streamable HTTP可網頁執行知識與記憶開發者工具

概覽

AI 產生的概覽

Code Auditor MCP 提供規則查詢、問題症狀解釋與安裝指令,服務於在 AI 代理編輯流程中執行專案規則的程式碼稽核工具。

可以做什麼
  • 查詢 Code Auditor 規則與分析器,回傳類型、說明、預設嚴重等級、偵測方式與門檻
  • 把自然語言描述的症狀(例如應用程式變慢、硬編碼密碼)對應到相關規則與修正建議
  • 提出新規則請求,並提示先確認沒有重複規則、提供最小正反範例
  • 依指定 AI 代理或全部代理回傳準確的安裝指令
適用情境
當你已使用或打算使用 Code Auditor,希望助理解釋其規則、把描述的程式碼問題對應到具體規則、提出新規則,或產生針對某個代理的安裝指令時適用。
執行需求
可作為遠端端點執行,也可作為本機 npm 套件透過 stdio 執行。README 說明需 Node 18+,Node 23.4+ 可免原生編譯;較舊版本需核准選用的 better-sqlite3 相依套件。MCP 伺服器本身未宣告驗證或環境變數。
安裝前請注意
此伺服器主要回傳參考與安裝資訊,但底層工具會把設定與掛鉤寫入你的 AI 程式開發工具,並可能阻擋編輯。README 描述可選的匿名回饋服務(CODE_AUDITOR_TELEMETRY),會傳送略過理由與結構簽章,預設關閉。套用產生的設定前請先檢查。

安裝

在 SourceWeft 中

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

Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。

交給代理程式安裝

把這段提示詞貼上到 Claude Code、Codex、Cursor 等代理程式,或 SourceWeft 對話中。代理程式會讀取該伺服器的安裝指南,先向你展示發布者、端點和登入方式,經你同意後再把它新增到你的客戶端。金鑰不會寫進任何命令。

閱讀 https://sourceweft.com/mcp/io.github.BenAHammond%2Fcode-auditor-mcp/install.md,並按其中說明把這個 MCP 伺服器接入我的客戶端。修改任何設定之前,先告訴我它的發布者、端點和登入方式,等我確認。不要把 API 金鑰寫進命令或我會提交的檔案;問我金鑰應從哪裡取得。

檢視代理程式所依據的安裝指南

其他 MCP 客戶端

把它新增到你客戶端的 mcpServers 設定中。

{
  "mcpServers": {
    "code-auditor": {
      "type": "http",
      "url": "https://www.codeauditormcp.com/api/mcp"
    }
  }
}

README

Code Auditor

Architectural invariants enforced inside your AI agent's edit loop. When the agent writes code that breaks a project rule, Code Auditor catches it and blocks the edit. The agent sees the rule's message and fixes itself.

Install

bash
npm install -g code-auditor-mcpcode-audit install --agent all

Two commands to install everywhere. code-audit install --agent all copies the skill to every AI coding tool on your machine. Use --agent for specific tools.

What you get per tool: the skill (SKILL.md), MCP server access, and hook wiring where the tool supports it (blocking on Claude Code and Codex, advisory on Cursor).

bash
code-audit install --list   # see the support matrix

Claude Code users can also install via plugin:

bash
claude plugin marketplace add BenAHammond/code-auditor-mcpclaude plugin install code-auditor

The hook auto-installs the auditor on first use via npx.

Requirements

  • Node 18+ to run. Node 23.4+ gets the zero-native-install path: Code Auditor uses the built-in node:sqlite module, so nothing needs to compile or download a prebuilt binary on install.
  • On older Node (18–23.3), Code Auditor falls back to better-sqlite3, an optional dependency whose install script must be approved once on npm 11.2+/12 (they block dependency install scripts by default): npm install-scripts approve better-sqlite3 && npm rebuild better-sqlite3 (with pnpm: pnpm approve-builds, then select better-sqlite3).

Configuration

Project-level settings live in .codeauditor.json (invariant rules, analyzer settings, and thresholds). Eleven environment variables additionally tune process-scoped behavior — worker pool size, daemon and job-queue timeouts, the index location, the SQLite backend, and the UI port.

VariablePurposeAccepted valuesDefault
CODE_AUDITOR_WORKERSPhase-model worker pool size for per-file fan-out. 1 forces the serial path for byte-identical reports.Positive integermax(1, cpus − 1)
CODE_AUDITOR_RULE_TIMINGPer-rule wall-time accounting (one accumulated timer per rule ID, surfaced in the report).1 enables; unset disablesOff
CODE_AUDITOR_DAEMON_IDLE_MSIdle timeout before the daemon shuts down.Positive finite ms; invalid → default300000 (5 min)
CODE_AUDITOR_DAEMON_LEASE_TTL_MSDaemon heartbeat lease TTL.Finite ms; blank/0 → default60000 (60 s)
CODE_AUDITOR_DATA_DIROverrides the code-index database directory.Directory path (trimmed; blank → default)user-level OS cache
CODE_AUDITOR_EXIT_ON_FATALExit the MCP server on an uncaught exception / unhandled rejection.1 or trueOff
CODE_AUDITOR_JOB_TIMEOUT_MSPer-job timeout for queued audits.Finite ms, clamped to 60s–4h; below the floor → default1800000 (30 min)
CODE_AUDITOR_JOB_LEASE_TTL_MSHeartbeat lease TTL for reclaiming stale running job rows.Strictly positive finite ms; invalid → default30000 (30 s)
CODE_AUDITOR_MAX_RUNNING_JOBSMax concurrently running queued audit jobs.Integer ≥ 1; invalid → default1
CODE_AUDITOR_SQLITE_BACKENDForces a SQLite backend. An invalid value is reported as invalid and rejected — never silently probed past.node-sqlite | better-sqlite3Auto (probe)
MCP_UI_PORTHTTP UI server port (--ui).Port number; invalid → default3001

When CODE_AUDITOR_DATA_DIR is set, the index is scoped per project (<dir>/projects/<sha256(root)[:16]>/index.db) so projects can't leak data into each other. When unset, the index lives in a user-level OS cache (<os_cache>/code-auditor/projects/<hash>/index.db) so it never lands inside the audited repo.

Prompt examples

"Index the codebase and run a full audit, then walk the violations file-by-file with code-audit next-file."

"Create a .codeauditor.json that bans lodash imports and prevents src/languages/ from importing anything in src/analyzers/."

"Run a full audit, fix the highest-priority file, and repeat code-audit next-file until the tree is clean."

"Sync the code index and audit only what changed vs main."

"Add an ast-pattern rule that blocks new Function(...)."

"Add a naming rule requiring hooks in src/hooks/ to start with use."

"Add a call-constraint so chargeCustomer() in src/services/payment.ts can only be called from src/api/."

Rule kinds

Seven kinds. The agent writes them to .codeauditor.json. Bad configs fail the audit, not silently.

KindWhat it blocks
import-banBanned module imports
call-constraintFunction calls from unauthorized files
module-boundaryImports across module boundaries
namingExported symbols not matching a pattern
ast-patternAST nodes matching an ast-grep pattern
style-mechanismUnapproved style mechanisms per file/glob
no-raw-valuesHardcoded values for specific CSS properties

Works with your agent

One skill, one CLI, one MCP server. Every agent gets the same audit engine — the hook contract is the only difference.

AgentSkillHooks / BlockingMCPVerified
Claude CodePlugin or code-audit installYes — blockingYes2026-07-19
Cursorcode-audit install --agent cursor (project-only)AdvisoryYes2026-07-19
Codexcode-audit install --agent codex + pluginYes — blockingYes2026-07-19
Gemini CLIcode-audit install --agent geminiNoYes2026-07-19
VS Code / Copilotcode-audit install --agent agentsNoYes2026-07-19
Other SKILL.md toolscode-audit install --agent agentsNoYes2026-07-19
ZCodecode-audit install --agent zcodeNo (plugin-scoped)Yes2026-09-10

MCP config generation covers a wider set than skill install. The MCP server's generate tool writes a client config file for any of claude, codex, cursor, gemini, copilot, continue, awsq (AWS Q Developer), codeium (Codeium/Windsurf), vscode, cline, and zcode. Four of those — Continue, AWS Q Developer, Codeium/Windsurf, and Cline — are MCP-only: they have no file-based skill or hook path, so they connect through the generate tool rather than code-audit install.

Hook behavior: Blocking means the diff-scoped changed gate is tripped — an invariant rule that declares gating: true (a binary, per-rule flag, independent of severity) blocks the edit from landing (the agent sees the violation and fixes inline). Advisory means violations are reported through the strongest available feedback channel but the edit has already occurred. Cursor's afterFileEdit hook is fire-and-forget with no output consumption. MCP is available everywhere for shell-less use.

Findings: Deterministic vs Advisory

Code Auditor's built-in rules fall into two categories:

CategoryMeaningExamples
DeterministicStructural fact — an engineer would act on every findingsingle-responsibility (300-line functions), solid/method-complexity (cyclomatic complexity > 20), solid/class-size (40+ method classes), dependency-inversion (concrete imports where an interface exists)
AdvisoryHeuristic signal — may be wrong depending on domainsql-injection-risk (AST-level string-pattern matching without type info), missing-org-filter (domain-specific — assumes SaaS tenant isolation), unknown-table (requires user-provided schema), dry/duplicate (token-identical blocks)

Deterministic rules ship at critical or severe. Advisory rules ship at severe or high. Rules proven near-zero precision on a real corpus are disabled by default (off) — users opt in when the rule matches their domain.

Recalibration

Built-in severity defaults are recalibrated from real-corpus triage. The current defaults reflect measurement on three corpora: this tool's own codebase, Gin, and Excalidraw. Six data-access rules that produced near-zero precision across all three corpora are disabled by default.

Every disabled rule documents what corpus it would be useful on. Users can restore any rule via severityOverrides in .codeauditor.json:

json
{  "severityOverrides": {    "sql-injection-risk": "critical",    "missing-org-filter": "severe",    "loop-query": "severe"  }}

Severity overrides apply globally (before per-directory path profile caps). Setting a rule to "off" removes it from the output entirely.

SQL Injection Detection

The sql-injection-risk rule is disabled by default (off) after recalibration. On the self-audit corpus, it produced 0% precision — the rule misinterpreted TypeScript pattern-matching code (string constants like 'SELECT', 'FROM', 'WHERE' used for the tool's own SQL detection) as database queries. On the Gin and Excalidraw corpora, precision was also near zero.

When to re-enable it: your project's SQL is constructed via string concatenation or template literals in functions whose sole purpose is query assembly. The rule detects those patterns. For codebases using ORMs or parameterized queries exclusively, the rule produces noise.

To re-enable and block on SQL injection:

json
{  "severityOverrides": {    "sql-injection-risk": "critical"  }}

With sql-injection-risk: critical (and the rule marked gating), your agent's hook will block edits that introduce AST-level SQL injection patterns.

Dismissals

Every finding is a measurement, not a verdict — but measurements are occasionally wrong. When the agent hits a false positive (the rule is right in general, wrong for this specific code), it can dismiss that one instance rather than work around it:

bash
code-audit dismiss <fingerprint> --reason "generated code, not hand-written"

The <fingerprint> comes from the JSON report (every violation carries a fingerprint field). A written --reason is required, and the dismissal clears exactly one finding — rule + file + symbol — so the same rule still fires everywhere else. Dismissals live in a committed .codeauditor.dismissals.json, reviewable in a diff.

Anonymous dismissal feedback (opt-in)

The reason an agent gives for dismissing a finding is the most useful signal for improving the rules. Code Auditor can send dismissed findings to an anonymous feedback service that collects them.

It is off by default and turned on only by an explicit opt-in, via any of three methods (in precedence order):

  1. per-invocation — code-audit dismiss --telemetry … sends just that one dismissal; --no-telemetry suppresses one.
  2. environment — CODE_AUDITOR_TELEMETRY=1 (or 0) as a machine-level default for headless/CI runs.
  3. persisted — code-audit telemetry status|enable|disable (or the telemetry MCP tool), which records the choice in your user config dir.

telemetry enable needs no arguments: it opts in against the built-in service endpoint (overridable for self-hosting). Opting in generates an anonymous install ID: a random value generated locally, never derived from your machine, user, or project, used only to group submissions by source.

What is sent — the tool version, the rule ID, the urgency level, the dismissal reason exactly as typed, a structural AST signature (grammar kinds only, never their contents), a coarse language hint, a timestamp, and the anonymous install ID. What is never sent — source code, identifiers, literals, file paths, or anything derived from your code or environment. Sending is best-effort: offline or an unreachable endpoint is silent and never blocks an edit or fails a gate.

Style Intelligence

Code Auditor indexes every style declaration in your project — CSS, SCSS, Tailwind, inline styles, and CSS-in-JS. The styles rules read global distributions and flag fragmentation that no single-file linter can see.

7 detectors, 10 rule IDs:

DetectorWhat it finds
Value driftNear-duplicate color values (delta-E < 2.0) and exact-value outliers where one value dominates
Off-scaleMargin/padding/gap/font-size values not on the inferred project scale
Undefined classclassName values with no matching CSS selector or Tailwind utility
Token bypassHardcoded values that match a design token but don't reference it
Mechanism fragmentationSame (property, value) delivered via ≥ 3 mechanisms (CSS, inline, Tailwind)
Declaration-set similarityTwo CSS rule blocks with > 90% identical declarations
Z-index sprawlProject-wide z-index inventory — too many distinct values or orphan singletons

The styles rules read from a project-wide SQLite index, so scoped runs (changed files only) still compare against the full project baseline. A fresh #273828 drift color in a scoped run is caught against the full corpus of #1e2328 values.

Style invariant rules:

json
{  "rules": [    {      "kind": "style-mechanism",      "message": "Only Tailwind in src/components/",      "allow": ["tailwind"],      "path": "src/components/**"    },    {      "kind": "no-raw-values",      "message": "No raw colors in src/pages/ — use design tokens",      "properties": ["color", "background-color"],      "path": "src/pages/**"    }  ]}

Style search operators — search by property, value, mechanism, or token:

bash
code-audit search "css:margin-top value:16px"          # specific valuecode-audit search "mechanism:inline css:color"          # inline color declarationscode-audit search "token:--color-primary"                # bypassing a design token

The React rules also gain raw-element detection: if your project has a Button wrapper, raw <button> usages outside Button's definition become severe findings.

License

MIT

來源:README.md,提交 b792894

工具

4

get_install_commands

Get Install Commands

Return the exact install commands for Code Auditor for a given AI agent. Call this when a user asks how to install Code Auditor, or asks for the command for a specific agent (claude, cursor, codex, gemini, agents, zcode, or all).

輸入參數agent必填

lookup_rule

Look Up Rule

Return the rule kind, description, default severity, detection method, and threshold for a given Code Auditor rule or analyzer. Call this when a user asks what a specific rule does (e.g. import-ban, sql-injection, n+1).

輸入參數rule_id必填

explain_symptom

Explain Symptom

Map a natural-language symptom (e.g. 'my app is slow', 'hardcoded password', 'infinite react loop') to the relevant Code Auditor rule(s) and their fixes. Call this when a user describes a problem rather than naming a rule.

輸入參數symptom必填

request_rule

Request Rule

Request a new Code Auditor rule. Call lookup_rule or explain_symptom first to confirm no existing rule covers it. Provide a minimal example that should be flagged and a corrected example that should not. Reduce both to the smallest code that shows the difference, and remove secrets and proprietary identifiers. Returns a receipt id.

輸入參數title必填signal必填symptom必填languages必填toolVersioncleanExample必填firingExample必填

版本歷史

3
  1. v5.0.2最新Oct 10, 2026
  2. v5.0.1Oct 9, 2026
  3. v2.0.2Sep 16, 2026

評分

已滿足適用檢查項的 100%

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

  • 近 30 天內可連通必需25 分
  • 已宣告認證方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分