
SPARDA
io.github.zakariagharzouli由 GitHub 帳號 zakariagharzouli 發布v0.71.4更新於 Oct 24, 2026
AI writes. SPARDA proves. Deterministic, offline security gate for AI edits.
概覽
SPARDA 以確定性、離線方式證明 AI 撰寫的後端變更是否安全,並可選擇把執行中應用程式的路由暴露為 MCP 工具。
- 可以做什麼
- SPARDA 會把後端(Express、FastAPI、Flask、Next.js、NestJS、Medusa,或透過 OpenAPI 支援任何技術堆疊)編譯成行為圖,再執行確定性的離線檢查:未受守衛保護的寫入、非原子的聚合寫入、未驗證的受限寫入、不可逆副作用,以及兩次編輯之間守衛被移除。指令包括 prove、apocalypse、gate、heal、badge、dossier、ubg、timeless、mirror 與 report。可選地,init 會注入一個可還原的 /mcp 路由,讓助理把應用程式自身的路由當成工具呼叫,寫入預設停用並需兩階段確認。
- 適用情境
- 當助理修改後端程式碼,而你想在變更落地前以確定性、離線方式確認它沒有移除守衛、破壞不變條件或擴大 API 影響範圍時使用。也適合用於 CI 閘門,以及讓助理在寫入安全的前提下操作執行中應用程式的路由。
- 執行需求
- 透過 npx 在本機執行(npm 套件 sparda-mcp,需要 Node.js)。不需要 API 金鑰或雲端帳號。可選的 MCP 執行環境需要在應用程式目錄執行 init、啟動應用程式,再執行 dev;產生的路由會從 SPARDA_LOCAL_KEY 環境變數或 gitignore 的 .sparda/key 檔案解析本機金鑰,兩者都沒有時會失敗關閉。可選環境變數:SPARDA_FLYWHEEL 與 SPARDA_RECORD_SEQUENCES。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 SPARDA,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
SPARDA
🇫🇷 Français — L'IA écrit. SPARDA prouve. Un gate déterministe et hors-ligne qui détecte quand une modif d'IA retire une garde, expose une route ou casse un invariant — sans clé API, directement dans la boucle d'édition de l'agent. Pour tout comprendre en 10 minutes (douleur, architecture, vision) : SPARDA-EXPLIQUE.md.
AI writes. SPARDA proves.
L'IA écrit. SPARDA prouve.
The trust layer for AI-written backends. SPARDA compiles your backend — routes, database queries, state mutations, guards, side-effects — into one deterministic behavior graph, then statically proves what can and can't break before you ship: no unguarded mutation, no broken invariant, no non-atomic aggregate write.
[npm] [CI] [node] [runtime deps] [license]
100% local · deterministic · zero API key · no cloud account. It fails loudly on a real risk, and when it can only see part of your app it says PROVEN (PARTIAL) — never a false green. And when it can prove it was not even looking at your whole app, it says PREMISE NOT VERIFIED and claims nothing at all.
60-second proof
From your Express, FastAPI, Flask, Next.js, NestJS or Medusa app — nothing to configure:
Under the hood it compiles your backend into one language-agnostic graph — the Unified Behavior Graph (UBG), serialized as .sparda/ubg.json under the SBIR specification (SPARDA Behavior IR) — and every command is a pass over that graph.
The wedge — catch an AI edit that removes a guard, in the loop
The one thing a text-diff review and a pattern scanner structurally can't do: prove that this specific edit dropped a protection the previous version had. sparda gate diffs the behavior graph before/after an edit and blocks a regression — deterministic, offline, sub-second, exit 2 (the Claude Code PostToolUse contract that stops the agent's edit loop). See it end-to-end in one command, zero setup:
Wire it into Claude Code in one line — the plugin registers a PostToolUse hook that runs npx -y sparda-mcp gate --hook after every Edit/Write, so a guard-removing edit is caught before it lands.
[!IMPORTANT]
The Route-Compilation Proof — reproduce it yourself. SPARDA compiles real open-source monsters to their behavior graph with zero crashes, each in ≈1–2 seconds: Next.js Dub (579 routes), NestJS Immich (281), MedusaJS (477). It natively resolves deep Dependency Injection, external controllers, and Next.js handlers. One command clones them and re-measures on your machine:Honesty first: compiling a route is a parser result (the number above); proving it safe is a separate per-repo verdict — and most real apps come back NOT_PROVEN, which is the true state, not a failure. (Our full 25-repo corpus stress compiles 3,565 routes at ~150 routes/s; that one needs the corpus checked out.)
What the graph unlocks — 100% local, deterministic, 4 exact-pinned dependencies, zero API key:
The prover is the product. The MCP server is one output of the graph, not the point — SPARDA compiles the whole system's behavior, then proves, replays, heals, and (optionally) serves it.
Nomenclature: SBIR is the specification (the format, like "JSON"); UBG is the compiled graph itself (the artifact, ubg.json). The MCP server is one output of the graph, not the product.
Optional: expose the graph to AI clients (MCP runtime)
Beyond proving, SPARDA can turn your running app into a live MCP server — the graph, executable, with write-safety and an immune layer. This is optional and separate from the prover above.
-
Scan + inject — run once, from your app's directory:
SPARDA parses your routes (AST), generates a marked
/mcprouter, injects it into your app (with a backup), and writessparda.json. Every step is reversible. -
Start your app, then start the bridge:
-
Connect your client.
initprints a ready-to-paste block forclaude_desktop_config.json, pre-filled with your app's name and path:Claude Code connects to the same bridge. That's it — your running app is now a set of MCP tools your AI can call.
Try the Standalone Demo
To see SPARDA in action instantly without modifying your codebase:
This runs the entire MCP lifecycle (detect → parse → generate → inject → remove) on a bundled demo app in a temporary folder, in about 10 seconds. For the compiler itself, run npx sparda-mcp ubg then apocalypse on any Express/FastAPI app.
Black Box Report
SPARDA is designed as a local organism. To see what it remembers and how much compute it has recycled:
This prints a terminal dashboard aggregating your exposed tools, write opt-ins, proof journal decisions, and crystallized composite tools.
To write a self-contained, offline HTML dashboard at .sparda/report.html, append the --html flag:
To output raw JSON for integration:
Deployment Proof: Apocalypse
SPARDA's Behavior Graph is a formal model of your system. Instead of waiting for runtime failures or relying on static analysis vibes, you can statically prove the safety of your backend before any deployment:
This command reads the compiled .sparda/ubg.json (with zero source code parsing at runtime) and discharges five static correctness obligations:
- Unguarded Mutation (Critical): Flags any mutation path that does not cross a security
guard. - Non-Atomic Aggregate Write (High): Flags when an API writes to multiple tables of the same Consistency Domain (Aggregate) outside a single transaction scope.
- Unvalidated Constrained Write (Medium): Flags writes into columns with declared invariants (CHECK, NOT NULL, UNIQUE — parsed from your
.sqlDDL orschema.prisma, Prisma enums included) without prior validation (Zod/Pydantic). - Irreversible Observable Effect (High): Flags out-of-process actions (like Stripe charges) that happen alongside state writes without a structural compensation path (like a catch-refund).
- Aggregate Member Bypass (Info): Flags mutating a member table directly without routing through the aggregate root.
To save your current graph as a safe baseline:
Subsequent runs will diff the candidate graph against this baseline to detect regression vectors:
- Deletion of any security
guard(Critical). - Deletion of a database SQL invariant (High).
- API blast radius expansion (Medium).
If any Critical or High finding is found, apocalypse exits with a non-zero code to block your CI pipeline.
One step in your workflow — findings land in the GitHub Security tab (SARIF):
Time Travel: Timeless
Every production request is deterministic between its effects — the compiler knows exactly where the nondeterminism lives (db, http, clock, random, uuid: the effect nodes of the graph). Timeless records only those points (a few KB per request) and replays the request byte-identically against your current code, with the database, webhooks and clock virtualized from the recording:
Recording is two lines in your app (ESM), with deterministic sampling and GDPR redaction built in:
The closed loop nobody else has: production bug → recorded flight → failing test → AI writes the fix → apocalypse proves the fix breaks no guard, invariant or transaction → deploy. Replay is per-request (concurrent-race capture is out of scope for v1 — stated, not hidden).
Self-Healing, Proven: sparda heal
The loop above, as one gesture — and the machine judges the fix, whoever wrote it:
The brief is built from the graph itself — it hands the fixer the handler's file:line, the capabilities the fix must not grow, and the guards it must not remove. Then the gate — the actual product — proves the fix on three axes at once:
- Behavior — lenient replay of the recorded flight (same deterministic inputs) now produces the expected response, not the recorded bug. The fix may reformulate a query (the tap is relabeled, allowed); it may not change the effect order or kinds.
- Compiler laws —
verifystill passes: the graph is still sound and deterministic. - No regression —
apocalypsediff against the frozen pre-fix graph: zero new critical/high findings, no guard removed, no blast radius grown.
The gate is honest in both directions: an unfixed bug, or a "fix" that silently drops a guard, keeps it closed (exit 1). This is the difference between an AI that writes plausible code and a system that proves the code is correct — the trust layer the agent era is missing.
Any Backend On Earth: OpenAPI Lowering
SPARDA parses Express, FastAPI and Next.js natively — and every other stack through the format the industry already agreed on. Go, Java, Rails, Laravel, .NET: if it has an OpenAPI spec, it compiles.
Security schemes become gating guard nodes, response schemas become typed returns, declared request bodies count as validated input. Pair the spec with your .sql or schema.prisma files and the full state layer — invariants, aggregates, state machines — fills in from declared truth. (JSON specs in v1; we refuse to half-parse YAML with zero dependencies.)
The Mirror VM: delete the framework, the app still answers
The graph is not a diagram — it executes:
No Express. No FastAPI. No source code — just ubg.json answering HTTP: guards actually deny (401), responses render the compiled return schemas, unknown paths 404 with the full route table. Front-end teams develop against backends that aren't deployed yet — or aren't written yet (point mirror at an OpenAPI spec). Every response carries x-sparda-mirror: true; the mirror serves declared behavior, it never invents business values.
To undo everything: npx sparda-mcp remove restores your code byte-for-byte.
The promise — every word is backed by a test in CI
- Three minutes, one command. AST scan, router generation, reversible injection — no config.
- Try it for free, leave for free.
npx sparda-mcp removerestores your code byte-for-byte (tested on JS, TS, Python, even Windows CRLF files). No trace, no lock-in. - The AI cannot write until you say so. Every POST/PUT/DELETE is disabled by default; you enable per tool, and your choice survives every re-run.
- Your app defends itself. A route failing 3 times in a row is quarantined — the AI can't hammer your broken production. Latency anomalies are flagged. Zero LLM needed.
- Nothing leaves your machine. No telemetry to us, no cloud, local key auth, 4 exact-pinned dependencies.
- What it learns is never lost. Diagnoses, descriptions, settings — versioned with your git, surviving every re-init.
What we don't promise: the honest limits in docs/SECURITY.md.
How it works
npx sparda-mcp initparses your codebase (AST), extracts every route, and injects a tiny marked router (/mcp) into your app — fully reversible withnpx sparda-mcp remove.- Tool calls run inside your live app process — warm DB pools, real auth chain, real data. SPARDA adds no infrastructure: compute comes from your host process, intelligence from your AI client's own model (MCP sampling), storage from
sparda.json+ git. - Write tools (POST/PUT/DELETE) are disabled by default. You opt in per tool in
sparda.json— your choices survive re-runs. - Suspicious docstrings are sanitized before they ever reach the AI (prompt-injection defense).
npx sparda-mcp doctor --appaudits your codebase for drift: it detects stale tools (IA seeing ghosts), unsynced routes, schema drift via fingerprints, and zombie configurations. High severity issues trigger a non-zero exit code for your CI pipeline.npx sparda-mcp seed export/importlets you package and share your app's "genome" (semantic memory, workflows, antibodies) securely, transferring immune memory between environments or across similar stacks with zero data leak.npx sparda-mcp twinstarts a safe, simulated mock server of your backend on the original port. It serves GET calls from learned exemplars (observed response shapes & mock data) and returns simulated 202 writes without ever touching your real database or production APIs. Learn exemplars by runningnpx sparda-mcp twin --learn.npx sparda-mcp grammarmaps the graph of valid sequences of tool calls (observed circuits and candidate hypotheses) to prevent LLM hallucination of routes.npx sparda-mcp evolvemutates candidate chains and tests them against the twin in-memory, promoting successful chains to evolved workflow suggestions.
What SPARDA gives your AI
Operate, not just read
Every route becomes a tool that runs against your live process — real auth, real data,
warm connections. One call to sparda_get_context hands the AI the whole living
picture: enabled tools, suggested workflows, runtime telemetry, quarantine state, and
immune memory — so every session resumes where the last one stopped.
Write-safety: the AI can't write until you say so
- Writes (POST/PUT/DELETE) ship disabled. Enable them per tool in
sparda.json; your choice survives every re-init. - An enabled write is never executed on the first call. SPARDA returns an
awaiting_confirmationenvelope — a single-use token plus a preview of the action — and commits only after an explicit confirm step. - When your client supports MCP elicitation, that confirmation prompt appears in the AI's own UI.
- Proof-after-write: every successful write is followed by a read-back of the same resource, so the AI — and you — see the real effect, not a hopeful guess.
Your app defends itself — zero LLM on the hot path
- Quarantine. A tool that returns 3 consecutive 5xx is quarantined: further calls get a
503with a reason and a retry delay instead of hammering your broken route. After a cooldown it half-opens for a single probe. - Latency & anomaly flags. The router learns each route's baseline and flags deviations locally, in a few lines of math.
- Adaptive diagnosis, only on surprise. A genuinely new failure wakes your AI client's own model to diagnose it once; the diagnosis is cached as an "antibody" in
sparda.json, so the same failure later costs zero tokens. Cloning your code doesn't clone its immune memory.
A free intelligence layer, zero API key
On first connection your AI client's own model (via MCP sampling) rewrites raw routes
into business-language tool descriptions and proposes multi-step workflows — cached in
sparda.json and exposed as MCP prompts. Nothing to configure, nothing to pay.
It gets cheaper the more you use it
- Response recycling. When a read keeps returning the same answer, SPARDA serves the next identical call straight from memory — without touching your host app. Reads only; writes always hit the host.
- A recycling gauge.
GET /mcp/statscounts how many calls were answered from SPARDA's own knowledge vs. how many paid the host route. It reads 0% on day one and fills with usage — a measure, never a promise.
Tools nobody wrote — Labs, opt-in, default OFF
Turn it on with "labs": { "recordSequences": true } in sparda.json. SPARDA then
notices when one tool's output feeds the next tool's input and records the circuit —
structure only (tool names, argument names, counts), never your data. A read-only
circuit seen enough times crystallizes into a composite tool, announced
mid-session: one call runs the whole chain, auto-feeding each step from the previous
step's real response. Write routes are never absorbed — their per-call confirmation
always stands.
Living context & telemetry
GET /mcp/stats (per-tool calls/errors, tool "purity", quarantine state) and
GET /mcp/events (errors, latency anomalies, cached diagnoses) expose exactly what
your app is doing — surfaced to the AI as live notifications.
Built for AI clients: the bundled Skill
SPARDA ships with an Agent Skill (SKILL.md) that teaches any compatible
AI client how to drive a SPARDA server to its full potential — call
sparda_get_context first, exploit response recycling, honor quarantine, prefer
crystallized circuits over re-walking a chain, and follow the two-phase write-confirm
protocol. The live, per-project tool list always comes from sparda_get_context at
runtime, so the guidance never goes stale.
Supported frameworks
- Next.js App Router (13/14/15) — file-based injection. SPARDA creates a catch-all route handler. It natively resolves wrapped handlers (
export const POST = withAuth(h)) and deep effect chains. - NestJS — AST-based router injection. Deeply resolves Multi-hop Dependency Injection (Controller → Service → Repository), inherited DI, and
baseUrl/pathsimports. Supports Prisma, TypeORM, and Kysely. - Express 4/5 (JS/TS, ESM/CJS) — AST-based router injection. Deeply resolves external controllers, Mongoose schemas, and barrel re-exports. Uses dynamic tree-scanning to find non-standard entry points (
bootstrap.ts, etc). - MedusaJS — Native AST ingestion of complex e-commerce routing.
- Any Backend On Earth (Go, Java, Rails, Laravel) — Compiles flawlessly from OpenAPI 3.x specs.
- FastAPI (Python >= 3.9) — AST-based router injection.
Security posture (honest)
- 4 runtime dependencies, exact-pinned.
- Dynamic Local Key Resolution. The generated router contains no baked secrets. It resolves authorization keys at runtime from the
SPARDA_LOCAL_KEYenvironment variable or the local gitignored.sparda/keyfile, and fails closed (503) when neither is found. For custom production or staging setups, you can override this behavior by exposingSPARDA_LOCAL_KEYin your environment. - Local key on every router call; self-reference loop protection; 30s timeouts; 8 KB output truncation.
- AST-positioned injection with backup and post-injection re-parse;
npx sparda-mcp removeleaves a clean git diff. - Persistence is value-free: SPARDA records structure (tool names, field names, fingerprints), never your payloads.
Full threat model and known gaps: docs/SECURITY.md.
Documentation
- docs/ARCHITECTURE.md — how
init, the injected router, and the bridge fit together, plus thesparda.jsonschema. - docs/SECURITY.md — threat model, defenses, and honest known gaps.
- docs/TESTING.md — how the promises above are kept honest in CI.
- docs/ERRORS.md — the error knowledge base.
Beyond the open core
SPARDA is free, including in production (see License). Team-scale capabilities — fine-grained per-person access policies and a signed, tamper-evident audit log — are planned for a future paid tier. The open core stands on its own; nothing here is crippled to upsell you.
License
Business Source License 1.1 — free to use, including in production. You may not resell SPARDA or offer it as a competing commercial service. Each version converts to Apache 2.0 four years after its release.
來源:README.md,提交 439617e
工具
0版本歷史
1- v0.71.4最新Sep 16, 2026
評分
已滿足適用檢查項的 40%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
請在儲存庫或註冊中心條目中宣告授權條款。