
agycraft-mcp
io.github.YuchengWang/agycraft-mcp
Privacy-first local MCP server & CLI doctor for Antigravity and Gemini CLI.
Documentation
agycraft-mcp
Privacy-first local MCP server & offline CLI doctor for Antigravity (AGY) and Gemini CLI — part of the ModelCraft open-source ecosystem. Available on npm and GitHub.
Independent community project. Not affiliated with or endorsed by Google.
Note on Gemini CLI Support: Google sunset personal/consumer-tier access for Gemini CLI on June 18, 2026.
agycraft-mcpcontinues to maintain full Gemini CLI support (settings.jsondiagnostics,--scope projectregistration, andOTeltelemetry) for Gemini Code Assist Standard/Enterprise and paid Gemini API key workflows. Individual developers are recommended to use Antigravity (agy).
Why agycraft-mcp?
- Preflight & Hygiene (
doctor,preflight): Catch brokenmcp_config.json/settings.json,urlvshttpUrlmismatches, stripped*TOKEN*/*KEY*/*SECRET*env vars, corporate proxy SSL errors (NODE_EXTRA_CA_CERTS), missing.geminiignore, and bloated global rules before your session stalls — plus a live cloud status gate (preflight). - Multi-Granularity Token, Rollup & KV Cache Audit (
analyze_token_usage): Inspect5h/24h/7d/30d/allconsumption acrosssummary,hourly,daily,weekly, andmonthlyrollups (v2schema withwatermarks.jsonsalt_fingerprint),scope: "global" | "project"isolation (project_hash),auth_modefiltering, Thinking output cost share,<4,096implicit KV cache misses, and unified model catalog shadow cost estimation (estimated_total_usd,estimated_cache_savings_usd). - Quota-Saving Prescriptions & Executive Summaries (
get_saving_recommendations): Detect long-session snowballs (with gentle phase-milestone compaction guidance when KV cache hit rate>= 85%), heavy model mismatches, Thinking downgrade opportunities, autonomous agent failure loops, and missing.geminiignore(with Python/data-science exclusions) — returningbehavior_summaryandexecutive_summaryin a single call. - Actionable Error Attribution (
diagnose_error): Diagnose all 5 fault domains (Quota/429 desync, Auth/403 mismatch, Capacity/503-504, MCP transport, Network/SSL), Structured Output & Function Calling protocol errors, and 4 granular GCP / Vertex AI rules (gcp-vertex-api-disabled,gcp-adc-expired,gcp-vertex-iam-or-location,gcp-vpc-sc-blocked) with BigQuery/GCS false-positive protection, copyable fix commands, verification steps, don't-dos, andmodelcraft.devdeep links. - Model Selection & Mixed-Auth Ecosystem Status (
lookup_model_guide,get_ecosystem_status): Pick the right model or Orchestrator pairing (e.g. Neon + Hydrogen), check deprecation warnings, inspect readonlyauth_contextmixed-auth isolation (Google OAuth / GCP ADC / API Key), view live upstream status, and compute local PT midnight & rolling 5h/7d reset countdowns.
Privacy & Compliance Architecture (100% Auditable)
- Zero User Data Upload: All token analysis, incremental rollup aggregation, structural transcript counting, and doctor checks run 100% locally.
- Strict Numeric/Metadata Whitelist:
~/.config/agycraft/usage.jsonlonly recordsv,ts,provider,product,session_hash(salted SHA-256),model,input_tokens,cache_read_tokens,output_tokens,thinking_tokens,context_used_pct,tool_calls,turn_index,error_code,project_hash(salted SHA-256 ofworkspace_dir/cwd), andauth_mode. Prompts, responses, source code, raw file paths, project names, and emails are never written or logged. - Zero Credential Inspection: Credential files (
oauth_creds.json,application_default_credentials.json) are checked viaexistsSynconly — never read, parsed, or logged. Never reads secret env values or calls undocumented Google/AGY internal endpoints. - One-Way Read-Only Snapshots: The only network request is a parameterless
GETto public static JSON snapshots (jsDelivr -> GitHub Pages -> GitHub Rawmulti-source fallback, configurable viaAGYCRAFT_DATA_URL/MODELCRAFT_DATA_URL) with ETag caching and bundled offline fallback snapshots insnapshots/. - Zero Native Dependencies: Pure TypeScript/JavaScript for Node 20+ (Node 22+ LTS recommended) — no
better-sqlite3or C++ build steps.
Quick Start (30 Seconds)
1. Run Offline Preflight Doctor & Live Status Guard
# Run directly with npx (no global install required)
npx -y agycraft-mcp@latest doctor
npx -y agycraft-mcp@latest preflight
# Or install globally
npm install -g agycraft-mcp
agycraft-mcp doctor
agycraft-mcp preflight
2. Add to Antigravity CLI (agy), Gemini CLI (gemini), or JSON Config (mcp_config.json / settings.json)
Antigravity CLI (agy) & Gemini CLI (gemini) one-liners:
# Antigravity CLI
agy mcp add agycraft npx -y agycraft-mcp@latest
# Gemini CLI (project-scoped)
gemini mcp add --scope project agycraft npx -y agycraft-mcp@latest
(For local dev testing against a local ModelCraft server: agy mcp add --env AGYCRAFT_DATA_URL=http://127.0.0.1:4321/data/v1 agycraft npx -y agycraft-mcp@latest)
Or JSON config (~/.gemini/antigravity/mcp_config.json / ~/.gemini/settings.json):
{
"mcpServers": {
"agycraft": {
"command": "npx",
"args": ["-y", "agycraft-mcp@latest"]
}
}
}
3. Optional: View Non-Destructive Telemetry Setup Snippets
npx -y agycraft-mcp@latest setup
4. Clear All Local Data Anytime
npx -y agycraft-mcp@latest clear-local-data
5. Project-Scoped Sandbox Isolation (AGYCRAFT_CONFIG_DIR & AGYCRAFT_BRAIN_DIR)
To evaluate agycraft-mcp in an isolated repo/sandbox with zero writes to ~/.config/agycraft and zero scans of global ~/.gemini/antigravity-cli/brain, set AGYCRAFT_CONFIG_DIR (which automatically skips global brain scanning unless AGYCRAFT_BRAIN_DIR is explicitly provided, or set AGYCRAFT_BRAIN_DIR=none to disable explicitly):
CLI one-liners:
# Gemini CLI (supports --scope project)
gemini mcp add --scope project --env AGYCRAFT_CONFIG_DIR=./sandbox_repo/.agycraft agycraft npx -y agycraft-mcp@latest
# Antigravity CLI
agy mcp add --env AGYCRAFT_CONFIG_DIR=./sandbox_repo/.agycraft agycraft npx -y agycraft-mcp@latest
# Shell sandbox isolation for CLI commands
AGYCRAFT_CONFIG_DIR=./sandbox_repo/.agycraft AGYCRAFT_BRAIN_DIR=none npx -y agycraft-mcp@latest doctor
Or JSON config (~/.gemini/settings.json / .gemini/settings.json):
{
"mcpServers": {
"agycraft": {
"command": "npx",
"args": ["-y", "agycraft-mcp@latest"],
"env": {
"AGYCRAFT_CONFIG_DIR": "./sandbox_repo/.agycraft"
}
}
},
"toolPermission": "proceed-in-sandbox"
}
Note:
"toolPermission": "proceed-in-sandbox"is an Antigravity top-levelsettings.jsonpermission field (sibling to"mcpServers", not nested insidemcpServers.agycraft).agy mcp addandgemini mcp adddo not write this field automatically—add it manually at the top level of your config file if needed.
CLI Subcommands
| Command | Description |
|---|---|
agycraft-mcp | Start Stdio MCP Server (default) |
agycraft-mcp doctor [--auth-mode <channel>] [--json] | Run offline preflight, channel isolation, & context hygiene checks |
agycraft-mcp doctor --cost [--window 5h|24h|7d|30d|all] [--json] | Inspect readonly cost breakdown by Canonical Model × Auth Mode (Shadow Cost vs Estimated GCP / API Spend) |
agycraft-mcp preflight [--json] | Live cloud status guard against status.json (MODELCRAFT_STATUS_URL / MODELCRAFT_DATA_URL); exits 1 on degraded, active incidents, 429/503 sources, or timeout |
agycraft-mcp setup | Print opt-in AGY Hook, Gemini CLI OTel (logPrompts: false), & sandbox snippets |
agycraft-mcp record | Append whitelisted numeric hook payload from stdin (hashes workspace_dir/cwd into project_hash) |
agycraft-mcp clear-local-data | Delete ~/.config/agycraft/usage.jsonl, .salt, cache/, and rollups/ |
Registered MCP Tools
analyze_token_usage- Parameters:
window("5h" | "24h" | "7d" | "30d" | "all", default"5h"),granularity("summary" | "hourly" | "daily" | "weekly" | "monthly", default"summary"),timezone,max_buckets(1..90, default31),product("agy" | "gemini-cli" | "all"),scope("global" | "project"),workspace_dir(salted locally intoproject_hash, never returned),auth_mode("all" | "google_oauth" | "gcp_adc" | "api_key" | "unknown"). - Uses incremental
rollups/(v2schema,hourly/daily/weekly/monthly+watermarks.jsonsalt_fingerprint) and unified model catalog shadow cost estimation (estimated_total_usd,estimated_cache_savings_usd).
- Parameters:
get_saving_recommendations- Parameters:
window("24h" | "7d", default"24h"),scope("global" | "project"),transcript_path,loopThreshold(default4),workspace_dir,timezone. - Returns
behavior_summary(avg_input_tokens_per_request,cache_hit_rate_pct,estimated_cache_savings_usd,light_model_request_share_pct,heavy_model_request_share_pct,top_models,peak_hours,project_share_of_global_pct,auth_context) andexecutive_summaryin a single call, with gentle compaction guidance when KV cache hit rate>= 85%and Python/data.geminiignoreexclusions.
- Parameters:
diagnose_error- Parameters:
error_text(required),product("agy" | "cli" | "api" | "web"),auth_mode(optional explicit channel ID/alias),doctor_summary. - Driven by
ChannelRegistry(channels.json), covering 4-channel429 RESOURCE_EXHAUSTEDisolation (google_oauth,gcp_vertex_adc,gemini_api_key,vertex_express_key), 5 fault domains, Structured Output/Function Calling, and 4 granular GCP/Vertex AI rules (gcp-vertex-api-disabled,gcp-adc-expired,gcp-vertex-iam-or-location,gcp-vpc-sc-blocked) with BigQuery/GCS 400/403 anti-false-positive protection.
- Parameters:
lookup_model_guide- Parameters:
task,model_id,provider("google" | "antigravity" | "anthropic" | "all"),include_history(boolean).
- Parameters:
get_ecosystem_status- Parameters:
plan("free" | "pro" | "ultra"),product("agy" | "cli" | "api" | "web"),timezone,scope("global" | "project"),workspace_dir,auth_mode. - Includes readonly
auth_contextmixed-auth isolation (google_oauth,gcp_adc,api_key) alongside live upstream status and PT midnight / rolling 5h/7d reset countdowns.
- Parameters:
Development
git clone https://github.com/YuchengWang/agycraft-mcp.git && cd agycraft-mcp && pnpm install && pnpm build && node dist/index.js doctor
Run tests and typechecking:
pnpm typecheck
pnpm test
pnpm build
Benchmarks & Community Acknowledgements
Special thanks to Dr. Jessica Rudd — Google Developer Expert (GDE) in GenAI and author of the Data Bytes newsletter (who also shared this evaluation in the GDE GenAI Circle) — for her independent sandbox testing, benchmarks, and actionable feedback in The Snowball Sensor: Catching Runaway AI Agent Loops Before They Burn Your Quota:
| Metric | Unguarded Runaway Loop | With agycraft-mcp (loopThreshold=4) | Impact |
|---|---|---|---|
| Loop Termination | Turn 22 | Turn 4 | Halted 18 turns early |
| Cumulative Input Tokens | 361,372 | 18,040 | 95.0% reduction |
Detection Latency (get_saving_recommendations) | — | 2.86 ms | Sub-3 ms overhead |
Release History / Changelog
v0.2.4 (2026-12-04)
- Consecutive & Sliding-Window
polling_loopDetection: UpgradedcollectTranscriptMetaandantipatternsto detect consecutive and sliding-window polling sequences, eliminating miss-detections in long sessions where polling accounts for< 15%of total tool calls. - Context-Depth Weighted Waste Quantification &
>= 100KHigh Alerts: Quantifiedpolling_wasted_tokensandestimated_wasted_usdweighted by per-turn context depth, escalating tohighseverity when polling occurs at>= 100Kcontext tokens. - Structured Prescriptions & Cross-Client
transcript.jsonlDiscovery: Added structuredpolling_loopremediation prescriptions inget_saving_recommendationsand automatictranscript.jsonlprobing across bothantigravityandantigravity-cli.
v0.2.2 (2026-12-02)
- Bilingual Adaptive Output (
lang: "en" | "zh" | "auto") &src/i18n.ts: Added bilingual localization across MCP tool responses and CLI diagnostics withsrc/i18n.ts, synchronized bilingualsnapshots/*.json, and 99/99 unit tests passing.
v0.2.1 (2026-12-02)
doctor --costChannel-Isolated Cost Audit & Deprecation Alerts: Addedagycraft-mcp doctor --cost [--window 5h|24h|7d|30d|all] [--json]anddoctor --jsoncost_summary/deprecated_model_in_usechecks, strictly separatingShadow Cost (Shared Quota Pressure)(google_oauth),Estimated GCP / API Spend(gcp_adc), andUnattributed Est.(unknown) by Canonical Model × Auth Mode with zerosession_hash,project_hash, or local path exposure.- Canonical Model Registry &
unknownAttribution: Unified model IDs to canonical catalog entries (gemini-4-hydrogen,gemini-3.8-flash,gemini-3.5-flash-lite,claude-sonnet-5-5, etc.) and eliminatedunknowngaps for AGYCHECKPOINTevents andMODEL_TIER_FLASH_LITECLI background logs (0unknownin liveanalyze_token_usage). - Anthropic Provider & Deprecation Guidance: Added
provider: "anthropic"support (claude-sonnet-5-5,claude-sonnet-4-5,claude-opus-4-6,claude-haiku-4-5) tolookup_model_guide, filtered deprecatedgemini-3.8-flashfromtask: "planning", and resolved legacygemini-3-8-flashaliases with migration warnings (-> gemini-4-hydrogen). - Dynamic
ChannelRegistry(channels.json) & 4-Channel Isolation: Added data-drivenChannelRegistry(supporting bothchannelsandauth_channelsschemas inchannels.json),doctor --auth-mode <channel>isolation checks, per-channelchannel_reportsinget_saving_recommendations, and 4-channeldiagnose_errorrouting (google_oauth,gcp_vertex_adc,gemini_api_key,vertex_express_key). - Verification & Release Verdict: Verified on Node
v20.20.2and Nodev22.21.1with 94/94 unit tests passing across 8 test files, plus real-project (AGYCRAFT_READONLY=1, livemodelcraft-web/public/data/v1/), zero-code dynamic channel extension (mock_enterprise_oidc), and isolated sandbox E2E verification — Go for release.
v0.2.0 (2026-12-02)
- Built-in
preflightCloud Guard & Node 20+ Compatibility: Addedagycraft-mcp preflight [--json]to checkstatus.json(MODELCRAFT_STATUS_URL/MODELCRAFT_DATA_URL) and exit1on degraded status, active incidents, upstream429/503signals, or HTTP/network failures. Relaxedengines.nodeto>=20.0.0(Node 22+ LTS recommended) with cleandoctorNode 20.x support. - Project-Scoped Filtering & Mixed-Auth Isolation: Added
scope: "global" | "project", one-way saltedproject_hashfromworkspace_dir/cwd(never persisting raw paths),unattributed_sessions_excludedreporting, and readonlyauth_context/auth_modeisolation across Google OAuth (google_oauth), GCP ADC (gcp_adc), and API Key (api_key) usingexistsSync-only credential checks. - Incremental
rollups/(v2) & Shadow Cost Estimation: Added atomic, file-locked incremental rollups (hourly/daily/weekly/monthly+watermarks.jsonwithsalt_fingerprintinvalidation) and unified model catalog shadow cost estimation (estimated_total_usd,estimated_cache_savings_usd) acrossanalyze_token_usage(5h/24h/7d/30d/all). - Single-Call
behavior_summary&executive_summary: Upgradedget_saving_recommendationsto emitbehavior_summary(top models, peak hours, cache hit rate, project share, auth context) andexecutive_summary, plus gentle phase-milestone compaction advice when KV cache hit rate>= 85%and Python/data.geminiignoreexclusions (.venv/,__pycache__/,data/,logs/,tmp/,*.parquet,*.lock). - 4 Granular GCP / Vertex AI
diagnose_errorRules & Anti-False-Positive: Addedgcp-vertex-api-disabled,gcp-adc-expired,gcp-vertex-iam-or-location, andgcp-vpc-sc-blocked, while preventing BigQuery/GCS400/403data-plane errors from being misclassified as model schema or model auth errors. AGYCRAFT_BRAIN_DIR&AGYCRAFT_CONFIG_DIRSandbox Isolation: AddedAGYCRAFT_BRAIN_DIR(none/off/falseor custom path), automatic skipping of global brain scans whenAGYCRAFT_CONFIG_DIRis set, and sandboxedsetupsnippets with top-level"toolPermission": "proceed-in-sandbox".- Acknowledgements: Driven by real-world sandbox testing (
AGYCRAFT_CONFIG_DIR=./sandbox_repo/.agycraft,"toolPermission": "proceed-in-sandbox", Node.jsv20.19.0) and benchmarks from Dr. Jessica Rudd (GDE in GenAI & Data Bytes author — The Snowball Sensor: Catching Runaway AI Agent Loops Before They Burn Your Quota, demonstrating 95.0% token reduction from 361,372 to 18,040 tokens and 2.86 ms detection latency). - Verification & Release Verdict: Verified on Node
v20.20.2and Nodev22.21.1with 65/65 unit tests passing across 7 test files, plus full MCP protocol interference & CLI sandbox E2E verification — Go for release.
v0.1.0 (2026-11-26)
- Initial release with 5 Stdio MCP tools (
analyze_token_usage,get_saving_recommendations,diagnose_error,lookup_model_guide,get_ecosystem_status), offline CLI (doctor,setup,record,clear-local-data), strict 12-field numeric/metadata whitelist, and bundled offline fallback snapshots.
License
MIT
agycraft-mcpnpm install agycraft-mcp