{"slug": "show-hn-ctxwise-stop-8mb-mcp-crashes-schema-bloat-and-cache-misses", "title": "Show HN: CtxWise – Stop 8MB MCP crashes, schema bloat, and cache misses", "summary": "FramY2 released CtxWise v1.0, a local-first CLI that profiles and compresses the context loaded by coding agents Claude Code, OpenAI Codex CLI, and Cursor, claiming a 73.3% reduction in model-visible prompt size and a 29.1% cut in per-turn tokens across a 20/20 pass run. The tool runs via npx with no API keys or model calls, and its mcp-xray command measures token weight per MCP tool schema, flagging tools at 250 tokens or more or with 12 or more input properties as bloated; in the project's example, 3 MCP servers and 18 tool schemas consumed roughly 6,420 schema tokens. CtxWise also ships a shield command that scans context files for leaked API keys such as sk-ant-*, sk-proj-*, and ghp_*, plus prompt injection and zero-width Unicode, failing CI with exit code 2 in under 20ms.", "body_md": "**Stop burning 30,000+ startup tokens on bloated MCP tool schemas, diverging `CLAUDE.md` / `AGENTS.md` files, and hidden prompt leaks.**\n\n  The local-first AI Context Firewall, MCP Schema Tree-Shaker, and Token Profiler for **Claude Code**, **OpenAI Codex**, and **Cursor**.\n\n[**⚡ 30s Quickstart**](#30-second-quickstart) ·\n  [**📊 Before vs. After**](#before-vs-after-ctxwise) ·\n  [**🌳 MCP Tree-Shaker**](#mcp-schema-tree-shaking) ·\n  [**🛡️ Security Shield**](#context-security-shield) ·\n  [**🤖 GitHub Action**](#github-action-ci-guard) ·\n  **🤝 5-Min PRs**\n\n**💡 Using Claude Code, OpenAI Codex, or Cursor?** Drop a **⭐ Star** on GitHub so you can find CtxWise whenever your MCP servers or `CLAUDE.md` / `AGENTS.md` files start bloating your context window!\n\nZero config, zero API keys, zero model calls. Run directly with `npx` in any repository:\n\n```\n# 1. Profile MCP servers & find bloated tool schemas silently eating your context window\nnpx @framy2/ctxwise mcp-xray --probe-stdio\n\n# 2. Audit startup tokens & parity across Claude Code (CLAUDE.md), Codex (AGENTS.md), and Cursor\nnpx @framy2/ctxwise agents\n\n# 3. Scan context files & skills for leaked API keys, prompt injection, and hidden Trojan Unicode\nnpx @framy2/ctxwise shield --fail-on-risk\n\n# 4. Sync CLAUDE.md <-> AGENTS.md <-> Cursor rules and apply lossless Token Diet compression\nnpx @framy2/ctxwise sync --compress --cursor\n```\n\nModern coding agents (**Claude Code**, **OpenAI Codex CLI**, **Cursor**) load `CLAUDE.md`, `AGENTS.md`, `.cursor/rules`, skill catalogs, and **every connected MCP server's JSON schema** on every turn:\n\n| Problem Surface | ❌ Without CtxWise | ✅ With CtxWise v1.0 | \n|---|---|---|\n| **Idle MCP Tool Schemas** | 4–5 MCP servers silently burn **15,000–35,000 tokens/turn** | `ctxwise mcp-xray` ranks every tool schema & flags`[BLOATED]` tools | \n| **Multi-Agent Rule Drift** | `CLAUDE.md` ,`AGENTS.md` , and`.cursor/rules` diverge fast | `ctxwise sync --compress` keeps all 3 synced + strips 25–40% boilerplate | \n| **Leaked API Keys in Context** | `sk-ant-*` ,`sk-proj-*` ,`ghp_*` inside`.mcp.json` or skills | `ctxwise shield` blocks secrets before they enter git or model prompts | \n| **Prompt Injection & Trojan Source** | Hidden `<!-- curl ... -->` comments or zero-width Unicode | `ctxwise shield --fail-on-risk` fails CI (`exit 2` ) in`<20ms` | \n| **Measured Prompt Overhead** | Unbounded context growth across PRs | **-73.3% model-visible prompt** &**-29.1% turn tokens** (20/20 pass) | \n\n```\nflowchart LR\n    subgraph Sources[\"Active Agent Context Surface\"]\n        C[\"Claude Code\\nCLAUDE.md · .mcp.json · .claude/skills\"]\n        O[\"OpenAI Codex\\nAGENTS.md · config.toml · .codex/skills\"]\n        U[\"Cursor\\n.cursorrules · .cursor/rules/*.mdc\"]\n    end\n\n    subgraph Engine[\"CtxWise Local Engine (0 API Calls · <50ms)\"]\n        A[\"ctxwise agents & sync\\nCross-Agent Parity + Token Diet\"]\n        M[\"ctxwise mcp-xray\\nMCP Tool Schema Tree-Shaker\"]\n        S[\"ctxwise shield\\nSecret & Prompt-Injection Firewall\"]\n        B[\"ctxwise budget & drift\\nDeterministic Lock & CI Gate\"]\n    end\n\n    Sources --> Engine\n    Engine --> Out1[\"Lean, Synced Context\\n(-29% to -73% Token Overhead)\"]\n    Engine --> Out2[\"GitHub Action CI Gate\\nuses: FramY2/ctxwise@v1\"]\n```\n\nDiscover all MCP servers declared across `.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json` (VS Code's top-level `\"servers\"` key), `~/.claude.json`, and `~/.codex/config.toml`. Measure exact token weights per tool schema (from a saved `tools/list` JSON file or by probing local stdio servers live) and spot `[BLOATED]` tools (`>= 250` tokens or `>= 12` input properties):\n\n```\nnpx @framy2/ctxwise mcp-xray --probe-stdio\nCtxWise mcp-xray · 3 MCP servers declared · 18 tool schemas analyzed · ~6,420 schema tokens (estimated)\n\nHeaviest MCP tool schemas:\n- ~890 tokens · github/create_or_update_pull_request (16 params, 3,560 chars) [BLOATED]\n- ~640 tokens · postgres/execute_migration_plan (14 params, 2,560 chars) [BLOATED]\n\nTree-shaking potential: ~1,530 tokens/turn savable by pruning bloated tools.\n```\n\nKeep **Claude Code** (`CLAUDE.md`, `.claude/rules/`, `.claude/skills`, `.claude/commands`, `.mcp.json`), **OpenAI Codex** (` AGENTS.md`, `.codex/skills`), and **Cursor** (`.cursor/rules/*.mdc`) 100% aligned while stripping markdown bloat (HTML comments, duplicate bullet rules, blank padding) without touching fenced code blocks. In CI, `ctxwise agents --fail-on-divergence` exits `1` when `CLAUDE.md` and `AGENTS.md` drift apart:\n\n```\nnpx @framy2/ctxwise agents\nnpx @framy2/ctxwise agents --fail-on-divergence\nnpx @framy2/ctxwise sync --compress --cursor\n```\n\nProtect your repository before an agent reads your workspace or before a PR merges:\n\n- **Secret Exposure Detection:** Catches hardcoded Anthropic (`sk-ant-...` ), OpenAI (`sk-proj-...` ), GitHub (`ghp_...` ), AWS (`AKIA...` ), and private key blocks inside`CLAUDE.md` ,`AGENTS.md` ,`.mcp.json` , and skills.\n- **Prompt Injection & Trojan Unicode Guard:** Detects override directives (`ignore all previous instructions` ), covert HTML comment payloads (`<!-- curl ... -->` ), and hidden bidirectional/zero-width Unicode characters.\n- **Claude Settings Hygiene & SARIF 2.1.0 Output:** Flags misplaced`\"mcpServers\"` blocks inside`.claude/settings.json` (`anthropics/claude-code#105885` ) and emits SARIF 2.1.0 (`--sarif ctxwise.sarif` ) for GitHub Code Scanning.\n- **Unpinned MCP Launchers (`unpinned-mcp-exec`):** Flags MCP servers that run an unpinned or`@latest` package through`npx` /`uvx` style launchers, so a compromised upstream release cannot silently enter your agent's tool surface.\n\n```\nnpx @framy2/ctxwise shield --fail-on-risk --sarif ctxwise.sarif\n```\n\nBootstrap a reviewable token budget (`ctxwise.budget.yaml`) and lean starter `AGENTS.md` + `CLAUDE.md` files tailored to your stack in one command:\n\n```\nnpx @framy2/ctxwise preset\nnpx @framy2/ctxwise preset nextjs-typescript --with-guidance\nnpx @framy2/ctxwise budget --fail-on-exceed   # auto-loads ./ctxwise.budget.yaml\n```\n\n`ctxwise budget` covers Claude Code, Codex, and Cursor startup files. By default (`--agent all`) the limit applies to the heaviest single agent session, so a synced `CLAUDE.md` + `AGENTS.md` pair is never double-counted; use `--agent codex|claude|cursor` to budget one agent.\n\nBuilt-in presets include:\n\n- `nextjs-typescript` (Next.js + TypeScript + Tailwind)\n- `sveltekit` /`sveltekit-typescript` (SvelteKit 2 + Svelte 5 Runes + TypeScript)\n- `python-fastapi` (Python 3.12 + FastAPI + Pydantic v2)\n- `rust-cargo` (Rust + Cargo Workspace)\n- `go-microservice` (Go 1.23+ Service)\n- `mcp-server-dev` (Model Context Protocol Server)\n- `monorepo-turbo` (Turborepo / pnpm Monorepo)\n\nAdd **CtxWise** to `.github/workflows/ci.yml` in 5 lines to automatically block secret leaks, prompt injection, and context token bloat on every Pull Request:\n\n```\n- name: AI Context Firewall & Token Budget Guard\n  uses: FramY2/ctxwise@v1\n  with:\n    max-known-tokens: \"4000\"\n    fail-on-secrets: \"true\"\n    check-agent-parity: \"true\"\n    sarif-file: \"ctxwise-shield.sarif\"\n```\n\nWhen `./ctxwise.budget.yaml` exists (or `budget-policy` points at a policy file), the Action uses it instead of `max-known-tokens`. `check-agent-parity: \"true\"` runs `ctxwise agents --fail-on-divergence`, and every run appends a Markdown report (shield status, per-agent token breakdown, budget status) to the job summary.\n\nCtxWise ships a native Claude Code plugin manifest (`.claude-plugin/plugin.json` + `.claude-plugin/marketplace.json`) that installs the `ctxwise` skill:\n\n```\n/plugin marketplace add FramY2/ctxwise\n/plugin install ctxwise@ctxwise\n```\n\n- **[`FramY2/mcp-diet`](https://github.com/FramY2/mcp-diet) (`@framy2/mcp-diet`)** : Zero-dependency stdio MCP proxy & runtime firewall — deterministic`tools/list` tree-shaking (`--allow` ,`--deny` ,`--read-only` ,`--max-desc` ), oversized`tools/call` crash guard (`--max-result-kb` for`anthropics/claude-code#105703` ), and live credential redaction (`--redact-secrets` ).\n- **[`FramY2/agent-wire-tap`](https://github.com/FramY2/agent-wire-tap) (`@framy2/agent-wire-tap`)** : Zero-cost local loopback HTTP interceptor & CI contract tester for coding agents (`codex` ,`claude` ) — captures exact outbound wire payloads and verifies system prompt, tool count, and byte budget contracts with**$0.00 API cost** .\n- **[Interactive Context & MCP Token Tax Calculator](https://framy2.github.io/ctxwise/)** : 100% client-side web app to measure per-turn MCP schema tax, 50-turn session cost across Claude Opus 4.7 / Opus 5.5 / Sonnet 5.5 / GPT-6.1-Sol / GPT-6-Luna (2026-11-11 list prices), Codex`32 KiB` truncation status, and leaked secrets. Accepts`.mcp.json` and`.vscode/mcp.json` .\n- **[`ctxwise-vscode` (`editors/vscode`)](https://github.com/FramY2/ctxwise/blob/main/editors/vscode)** : Lightweight VS Code & Cursor status-bar extension displaying live workspace token tax, Context Grade (`A` –`F` ), Codex`32 KiB` cap percentage, and secret alerts.\n\nThe public microbenchmark ran 10 paired tasks across requested GPT-5.6 Luna, Terra, and Sol profiles: **20/20 answers passed the same exact validator**. Removing irrelevant discovered context reduced the estimated model-visible prompt by **73.3%** and exact aggregate turn tokens by **29.1%** (with a second maintainer repeat measuring **28.5%** across nine comparable pairs).\n\nRead the [method and limitations](https://github.com/FramY2/ctxwise/blob/main/benchmarks/results/2026-08-09-v1/report.md) or inspect the [machine-readable summary](https://github.com/FramY2/ctxwise/blob/main/benchmarks/results/2026-08-09-v1/summary.json).\n\n| Command | What it does | Network / Model Call | \n|---|---|---|\n| `ctxwise agents` | Audits startup tokens and parity across **Claude Code** ,**OpenAI Codex** , and**Cursor** | None | \n| `ctxwise sync` | Synchronizes `AGENTS.md` ↔`CLAUDE.md` ↔`.cursor/rules` with optional`--compress` Token Diet | None | \n| `ctxwise codex-doctor` | Audits `AGENTS.override.md` /`AGENTS.md` hierarchy against Codex's`32 KiB` truncation limit | None | \n| `ctxwise mcp-xray` | Profiles MCP server tool-schema token weights and flags bloated tools for tree-shaking | None (or local stdio probe) | \n| `ctxwise mcp-prune` | Disables bloated or unused MCP servers in `.mcp.json` /`.codex/config.toml` with`.bak` save | None (or local stdio probe) | \n| `ctxwise shield` | Scans agent context files & skills for leaked API keys, prompt injection, and hidden Unicode | None | \n| `ctxwise preset` | Lists or applies curated stack budgets and `AGENTS.md` /`CLAUDE.md` templates | None | \n| `ctxwise snapshot` | Ranks known Codex context contributors, coverage gaps, and safe next actions | None | \n| `ctxwise budget` | Checks Claude Code / Codex / Cursor startup context against CLI or YAML limits (auto-loads `ctxwise.budget.yaml` ); exits`2` in CI | None | \n| `ctxwise audit` | Inventories config plus active root-to-CWD guidance, skills, plugins, agents, and MCPs | None | \n| `ctxwise map` | Renders a bounded Mermaid map of context sources and discovery overhead | None | \n| `ctxwise xray` | Summarizes model-visible prompt JSON without echoing its text | None | \n| `ctxwise profile` | Compiles YAML into native `~/.codex/<name>.config.toml` , with dry-run and backups | None | \n| `ctxwise lock` | Hashes a redacted capability surface ( `ctxwise.lock.json` ) for reproducibility | None | \n| `ctxwise drift` | Compares a capability lock with a file or live setup; can fail CI on drift | None | \n| `ctxwise quota` | Reads the current plan and quota window through local Codex app-server | Codex account read only | \n| `ctxwise receipt` | Calculates an honest receipt from saved `codex exec --json` usage | None | \n| `ctxwise run` | Runs Codex and appends exact usage plus an optional pre-turn prompt X-Ray | Requested Codex turn | \n\nNew to profiles? Follow the [lean-profile walkthrough](https://github.com/FramY2/ctxwise/blob/main/docs/tutorials/lean-profile.md): it turns a real `audit` finding into a reviewable lean profile, end to end.\n\nWant to make your first open-source contribution to an AI developer tool? Adding a new stack preset in [`presets/`](https://github.com/FramY2/ctxwise/blob/main/presets) takes **less than 5 minutes** (just 1 YAML file, validated automatically by `npm test`):\n\n- 🟢 [**Issue #23**](https://github.com/FramY2/ctxwise/issues/23) — Add`sveltekit-typescript` preset (SvelteKit 2 + Svelte 5 Runes)\n- 🟢 [**Issue #24**](https://github.com/FramY2/ctxwise/issues/24) — Add`astro-content` preset (Astro 5 + Content Layer)\n- 🟢 [**Issue #25**](https://github.com/FramY2/ctxwise/issues/25) — Add`django-ninja` preset (Python + Django 5 + Django Ninja)\n- 🟢 [**Issue #26**](https://github.com/FramY2/ctxwise/issues/26) — Add`laravel-inertia` preset (Laravel 11 + Inertia.js + PHP 8.3)\n- 🟢 [**Issue #27**](https://github.com/FramY2/ctxwise/issues/27) — Add`kotlin-spring-boot` preset (Kotlin + Spring Boot 3)\n- 🟢 [**Issue #28**](https://github.com/FramY2/ctxwise/issues/28) — Add`cloudflare-workers-hono` preset (Cloudflare Workers + Hono)\n\nSee [`CONTRIBUTING.md`](https://github.com/FramY2/ctxwise/blob/main/CONTRIBUTING.md) for the 3-step guide!\n\n| Authentication | Default display | Dollar meaning | \n|---|---|---|\n| OpenAI API key | Exact runtime tokens + dated API estimate | Estimated billable API charge | \n| ChatGPT Plus/Pro/Business | Tokens + credit equivalent + quota snapshot | No dollar amount | \n| Subscription with `--api-equivalent` | Same data + API comparison | Comparison only; **not charged** | \n\nSee [Architecture](https://github.com/FramY2/ctxwise/blob/main/docs/architecture.md), [Cost semantics](https://github.com/FramY2/ctxwise/blob/main/docs/cost-semantics.md), and [Privacy and security](https://github.com/FramY2/ctxwise/blob/main/docs/privacy-security.md).\n\nApache-2.0. See [LICENSE](https://github.com/FramY2/ctxwise/blob/main/LICENSE) and [NOTICE](https://github.com/FramY2/ctxwise/blob/main/NOTICE).\n\n**If CtxWise saved you tokens or caught a bloated MCP schema, please give the repo a ⭐ Star on GitHub!**\n\n[⭐ Star FramY2/ctxwise on GitHub](https://github.com/FramY2/ctxwise/stargazers)", "url": "https://wpnews.pro/news/show-hn-ctxwise-stop-8mb-mcp-crashes-schema-bloat-and-cache-misses", "canonical_source": "https://github.com/FramY2/ctxwise", "published_at": "2026-11-13 18:12:50+00:00", "updated_at": "2026-11-13 18:20:11.679147+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "developer-tools", "ai-tools", "ai-safety"], "entities": ["FramY2", "CtxWise", "Claude Code", "OpenAI Codex CLI", "Cursor", "GitHub"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/show-hn-ctxwise-stop-8mb-mcp-crashes-schema-bloat-and-cache-misses", "markdown": "https://wpnews.pro/news/show-hn-ctxwise-stop-8mb-mcp-crashes-schema-bloat-and-cache-misses.md", "text": "https://wpnews.pro/news/show-hn-ctxwise-stop-8mb-mcp-crashes-schema-bloat-and-cache-misses.txt", "jsonld": "https://wpnews.pro/news/show-hn-ctxwise-stop-8mb-mcp-crashes-schema-bloat-and-cache-misses.jsonld"}}