Antigravity Truth Guard
Integrates with Google Cloud Firestore and Gemini/Vertex AI to store and retrieve indexed project knowledge, generate embeddings, and run independent plan verification, with paid fallback and circuit-breaker protection.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Antigravity Truth Guard Verify the invoice schema facts, then audit my plan before I code."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π‘οΈ Antigravity Truth Guard v2.0
Global Multi-Project Anti-Hallucination MCP Guard for Autonomous AI Coding Agents with Zero-Runaway-Cost Protection
English | Π£ΠΊΡΠ°ΡΠ½ΡΡΠΊΠ° Π²Π΅ΡΡΡΡ (README.uk.md)
Antigravity Truth Guard is an open-source autonomous architectural governance system (MCP server) that guarantees AI coding agents (Google Antigravity, Claude Code, OpenAI Codex, Cursor, etc.) write code strictly grounded in verified facts and architecture contracts. It eliminates database schema hallucinations, prevents architectural layer contamination, and protects project owners from runaway API costs caused by infinite loops.
π Table of Contents
Related MCP server: guardian-mcp
π§© The Problem: Why Do AI Coding Agents Hallucinate?
Autonomous AI coding agents operate with superhuman speed, but in commercial repositories, they exhibit three critical failure modes:
Schema & Contract Hallucinations: When an agent lacks grounded context for a database table or business rule (e.g. βmonetary values must be stored strictly as integer cents, never floating-point numbersβ), it guesses or extrapolates. This causes production outages, silent financial drift, and corrupted database states.
Architectural Cross-Segment Contamination: An agent often tries in a single prompt to modify calculation formulas in the domain core, add a button to the UI, and alter database schemas simultaneously. The result is tangled spaghetti code that breaks Clean Architecture.
The "Financial Abyss" (Runaway Agent Loops): If an agent encounters an unexpected error while operating autonomously (especially overnight), it can trap itself in infinite self-correction loops. It burns tens of thousands of LLM API calls, resulting in unexpected, massive billing charges.
ποΈ How Truth Guard Works (Plain English for Non-Programmers)
Imagine you are constructing a high-rise building, and the AI agent is an ultra-fast construction crew.
[ User Request: "Build new inventory feature" ]
β
βΌ
βββββββββββββββββββββββββββββ
β AI Coding Agent β
β (Claude, Codex, etc.) β
βββββββββββββββ¬ββββββββββββββ
β 1. Drafts technical plan
βΌ
βββββββββββββββββββββββββββββββββββββ
β π‘οΈ ANTIGRAVITY TRUTH GUARD β
β (Chief Compliance Notary) β
βββββββββββββββ¬ββββββββββββββββββββββ
β 2. Audits against Ground Truth Laws
ββββββββββββββββ΄βββββββββββββββ
βΌ βΌ
[ Plan INVENTED Facts ] [ Plan 100% GROUNDED ]
β β
βΌ βΌ
β STAMP: REJECTED β
STAMP: APPROVED
Job site remains locked! Receipt generated:
Agent must fix errors. .truth-receipt.json
β
βΌ
Construction/Code edit
permitted to execute!The "Notary & Blueprint" Principle:
The Blueprint (Ground Truth): Your project specifications, schema contracts, and domain rules stored in
.mdspecification files (safe from self-poisoning). Truth Guard indexes them into a high-speed knowledge base.Mandatory Fact-Check (
truth_search): The AI agent is strictly forbidden from writing code blind. It must first ask Truth Guard: βWhat are the exact, verified rules for this subsystem?β.The Independent Verification Gate (
truth_verify_plan): Before modifying any code, the agent submits its implementation plan along with the intendedtarget_files. An independent AI auditor cross-references every single table, column, enum, and arithmetic operation against the Ground Truth facts. If the agent invented anything, the plan is instantly rejected.Cryptographic Verification Receipt (
.truth-receipt.json): Only when the plan is 100% faithful does Truth Guard issue a time-stamped, cryptographically signed receipt bound totarget_files(15-minute TTL, single-use per git commit). The repository verification harness (npm run verifyand Git pre-commit hooks) rejects any commit or test run if code changes exist without an authentic, fresh receipt!
π³ Financial Safety Architecture: Zero-Runaway-Cost Protection
Truth Guard features an automated Emergency Safety Circuit Breakerβjust like an electrical circuit breaker in your house:
[ Daily API Call Stream ]
β
ββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββ
βΌ βΌ βΌ
[ Calls 0 - 1,400 ] [ Calls 1,400 - 5,000 ] [ Calls > 5,000 (LOOP) ]
β β β
βΌ βΌ βΌ
β TIER 1: FREE TIER β‘ TIER 2: PAY-AS-YOU-GO π¨ TIER 3: CIRCUIT BREAKER
Google AI Studio Secondary Paid Fallback EMERGENCY SHUTDOWN!
1,500 free calls/day. (costs a few cents, All paid APIs blocked.
Cost: $0.00 / day. prevents work stops). Forces LOCAL_FALLBACK.
Cost: ~$0.05. Cost: $0.00 (100% Safe).Tier 1 (Free Tier, 0 β 1,400 calls/day): Utilizes the Google AI Studio / Gemini API Free Tier (1,500 free requests per day). Operating comfortably within 1,400 calls/day, your daily operational cost is $0.00.
Tier 2 (Paid Backup / Pay-as-you-go, 1,400 β 5,000 calls/day): If the daily free quota is exhausted or temporary
429 Rate Limitsoccur, the server does not crash. It automatically escalates to a linked Google Cloud Pay-as-you-go backend (Gemini / Vertex AI). Verification continues seamlessly at a cost of only a few cents per month.Tier 3 (Emergency Safety Circuit Breaker, > 5,000 calls/day): If an agent goes rogue or is trapped in an infinite script loop, the circuit breaker trips:
All paid external cloud API calls are immediately hard-blocked.
The server switches to
LOCAL_FALLBACK_MODE(in-memory keyword BM25 search + deterministic TypeScript schema & rule auditing).Your funds and credit card are 100% protected against runaway charges.
βοΈ Technical Architecture & In-Memory RAM Mirroring
1. In-Memory RAM Cache Mirror (local-mirror.json) β $0 Database Read Costs
At server boot, all knowledge chunks for the active project and
globalspace are loaded into process memory (ramMirror) and cached locally inlocal-mirror.json.All
truth_searchrequests execute entirely in RAM using hybrid scoring:Vector Cosine Similarity over 768-dimensional embeddings (
gemini-embedding-001).BM25 Keyword Matching over section titles and body content.
Zero Firestore read charges during developer/agent conversations! (Comfortably inside Firestore's 50,000 free daily reads).
2. Multi-Project Isolation with Priority Boosting
Truth Guard automatically detects the active project from the git repository name or
package.json.Search runs concurrently across two namespaces:
project_id == currentProjectIdandproject_id == "global".Project-specific facts receive a
[HIGH (PROJECT OVERRIDE)]priority tag and rank boost over global defaults ([BASE (GLOBAL)]).
3. Background Smart Watcher (Zero Quota Waste)
Powered by
chokidar, Truth Guard continuously monitors**/*.md,**/*.schema.ts, and**/*.types.ts.Sections are tracked via SHA-256 hashes in
.truth-hashes.json.Embeddings are generated only for sections whose text has genuinely changed.
π The 5 Universal Engineering Laws
Defined in global-rules.md and seeded automatically into project_id: "global":
Grounded Context (
global-no-guessing): Agents are forbidden from guessing codebase architecture, database schemas, or API contracts. Every task starts withtruth_search.Cross-Segment Isolation (
global-surgical-scope): Strict Clean Architecture boundaries. Never blend changes across Domain, Application, Infrastructure, and UI in a single monolithic edit.Verification Honesty (
global-verification-honesty): Never bypass compiler diagnostics (@ts-ignore) or mock test passes. Every plan must cite authenticcited_fact_ids.Ledger-First Accounting (
global-defensive-code): All currency values must use integer cents (integer cents). Balances must never be directly overwritten; every inventory change must be an immutable ledger delta (+ / -).Hierarchy of Truth (
global-project-priority): Project-specific rules always take absolute precedence over global defaults when conflicting.
π οΈ MCP Tools Reference
The server exposes 4 standard Model Context Protocol (MCP) tools:
Tool | Purpose | Key Arguments |
| In-memory semantic & BM25 search (0 database reads) |
|
| Multi-tier LLM verification gate & receipt generator |
|
| Create or update a spec rule (Human-in-the-Loop protected) |
|
| Comprehensive status report: active tier, RAM chunks, circuit breaker |
|
π Quickstart & Deployment Guide
1. Clone & Install Dependencies
git clone https://github.com/bushold-dev/antigravity-truth-guard.git
cd antigravity-truth-guard
npm install2. Configure Environment Variables
Copy .env.example to .env:
cp .env.example .envFill in your configuration:
# Free Gemini API Key (Get free key at https://aistudio.google.com/app/apikey)
GEMINI_API_KEY="your-gemini-api-key-here"
# Google Cloud Project ID with Firestore Native database
GCP_PROJECT="your-google-cloud-project-id"
FIRESTORE_DATABASE="(default)"3. Create Firestore Composite Vector Index (Run Once)
gcloud firestore indexes composite create \
--collection-group=truth_chunks \
--query-scope=COLLECTION \
--field-config=field-path=project_id,order=ASCENDING \
--field-config=field-path=embedding,vector-config='{"dimension":"768","flat":{}}'4. Run Verification Self-Test
npm testVerifies RAM mirror preloading, semantic search, plan verification, and the circuit breaker safety system.
π Connecting to Antigravity, Claude, Codex, and Cursor
For Google Antigravity
Add to ~/.gemini/config/mcp_config.json or ~/.gemini/antigravity/mcp_config.json:
{
"mcpServers": {
"antigravity-truth-guard": {
"command": "node",
"args": ["/absolute/path/to/antigravity-truth-guard/server.mjs"]
}
}
}For Claude Code (claude.json)
{
"mcpServers": {
"truth-guard": {
"command": "node",
"args": ["/absolute/path/to/antigravity-truth-guard/server.mjs"]
}
}
}For OpenAI Codex (~/.codex/config.toml)
[mcp_servers.truth_guard]
command = "node"
args = ["/absolute/path/to/antigravity-truth-guard/server.mjs"]Enforce in Your Project's CI/CD or Build Script (package.json)
{
"scripts": {
"verify": "node /path/to/antigravity-truth-guard/check-receipt.mjs && npm run lint && npm test"
}
}If an AI agent modifies code in src/ without obtaining an authentic .truth-receipt.json from truth_verify_plan, this script immediately halts the build!
π€ AI Agent Prompts Library
We provide ready-to-use copy-paste prompts in PROMPTS.md (Π£ΠΊΡΠ°ΡΠ½ΡΡΠΊΠ° Π²Π΅ΡΡΡΡ):
Autonomous Setup Prompt: Directs any AI agent to prepare Google Cloud, install Truth Guard, and connect it to your IDE.
Repository Enforcement Prompt: Directs any AI agent to enforce mandatory verification receipts and the 3 Laws of Truth inside an existing project.
π License
Released under the open-source MIT License. Contributions, issues, and forks are welcome!
Available Tools
4 toolstruth_searchB
RAM mirror semantic search for ground-truth rules, architecture specs, and schema contracts (0 Firestore reads)
Inputs: query (required), include_global, target_project.
truth_statusA
Get operational status of antigravity-truth-guard: tier, RAM mirror count, circuit breaker, and quota usage
Inputs: target_project.
truth_upsert_ruleB
Create or update a ground-truth rule or spec both locally on disk, in RAM mirror, and in Firestore (requires human confirmation)
Inputs: content (required), file_path (required), section_title (required), scope, +2 more.
truth_verify_planB
Anti-hallucination verification gate: checks proposed plan against ground truth facts using multi-tier LLM engine
Inputs: target_files (required), proposed_plan (required), cited_fact_ids (required), project_dir.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 4 tools
Each tool targets a clearly distinct operation: semantic search, plan verification, rule upsert, and status reporting. There is no meaningful overlap between them, and an agent can easily select the right tool.
All tools share a consistent truth_ prefix and snake_case style. Three use verb-based names (search, verify_plan, upsert_rule) while truth_status is noun-based, a minor deviation.
Four tools is a well-scoped set for a truth-guard service: search, verify, upsert, and status each earn their place without redundancy.
The surface covers reading, verifying, creating/updating, and monitoring rules. However, there is no explicit delete/remove operation for rules and no dedicated list-all tool, leaving minor lifecycle gaps.
Maintenance
Related MCP Connectors
Pre-execution governance for AI agents. Deterministic PASS/FAIL/REVIEW verdicts, replayable proof.
See, price, and control every tool call your AI agents make: policy checks, cost, and audit tools.
Cuts coding agent token burn up to 72% continuously via contradiction-free memory & verification.
Enforces architectural invariants and code quality rules inside your AI agent's edit loop.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceProvides AI coding agents with an embedded knowledge graph and architecture governance tools, enabling blast radius analysis, compliance checks, and smart context extraction from codebases.Apache 2.0
- AlicenseAqualityCmaintenanceEnables AI coding agents to avoid irreversible mistakes by intercepting risky deletions, overwrites, and commands before execution, applying path, pattern, and blast-radius safeguards with quarantine backups.313 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables autonomous agents to enforce financial guardrails by tracking real-time token burn and cost velocity, automatically throttling or freezing execution when budgets are exceeded. It also blocks destructive shell commands, prompt injections, and runaway planning loops while sanitizing outputs before they are returned.7MIT

Tently MCPofficial
AlicenseNot gradedqualityBmaintenanceEnables coding agents such as Claude Code and Cursor to check a team's learned decisions from pull requests, reviews, and docs before writing code, showing whether breaking them is blocking or advisory. It also provides locally computed symbol impact/blast-radius analysis so source code never leaves the machine.67 npm2MIT