Skip to main content
Glama
README.md
# ContextGuard (`contextguard-mcp`)

**Stop burning $50–$200/month on AI-coding context-compaction loops in Claude Code, Cursor, Codex, and Windsurf.**

[![License: MIT](https://img.shields.io/badge/License-MIT-amber.svg)](./LICENSE)
[![Node.js >= 20](https://img.shields.io/badge/Node-%3E%3D20.0.0-brightgreen.svg)](https://nodejs.org)
[![Live Web Workbench](https://img.shields.io/badge/Web_Workbench-secondforeman.com%2Fcontextguard-0b1220)](https://secondforeman.com/contextguard/)

When an AI coding session loads an oversized `CLAUDE.md`, `AGENTS.md`, `.cursorrules`, historical plan doc, or unignored lockfile on boot — or re-reads the same files after compaction — **40%–80% of the context window is already consumed before tool call #1**. Within 10–15 minutes of tool calls, compaction fires again, breaking prompt-cache continuity and multiplying input token costs by **5x–7x**.

**ContextGuard** is a zero-dependency Node.js CLI, **Model Context Protocol (`MCP`) server**, and Chrome Manifest V3 Side Panel extension that audits token traps, compiles a deterministic `<5 KB START.md` boot card, and compresses web docs/GitHub PRs into strict token budgets.

---

## Quick Start (Zero Install — `0` npm Dependencies)

```bash
# 1. Audit startup token burn, lockfile leaks & compaction risk in any repo
npx --yes github:oneandroid-max/contextguard-mcp audit .

# 2. Enforce a CI pull-request startup token ceiling (e.g. <= 6,000 tokens)
npx --yes github:oneandroid-max/contextguard-mcp audit . --max-boot-tokens 6000

# 3. Compile a <5 KB START.md boot card from oversized CLAUDE.md / AGENTS.md files
npx --yes github:oneandroid-max/contextguard-mcp slim . --write

# 4. Compress an HTML doc, PR diff, or log file to a 3,000-token Markdown budget
npx --yes github:oneandroid-max/contextguard-mcp clip ./pr-page.html --budget 3000
```

---

## Add as a Local MCP Server (Claude Code, Cursor, Windsurf)

### Claude Code CLI (1 command)

```bash
claude mcp add contextguard -- npx -y github:oneandroid-max/contextguard-mcp --mcp
```

### `.mcp.json` / `.cursor/mcp.json`

```json
{
  "mcpServers": {
    "contextguard": {
      "command": "npx",
      "args": ["-y", "github:oneandroid-max/contextguard-mcp", "--mcp"]
    }
  }
}
```

### Exposed MCP Tools

| Tool | What It Does |
| --- | --- |
| `contextguard_audit_workspace` | Audits `CLAUDE.md`, `AGENTS.md`, `.cursorrules`, `docs/plans/*.md`, and lockfiles for token burn & compaction spirals. |
| `contextguard_slim_boot_card` | Generates a `<5 KB` `START.md` boot card and `.claudeignore` cutting startup reads by 60%–85%. |
| `contextguard_compress_web_doc` | Strips scripts, styles, SVGs, nav boilerplate, and duplicate stack traces into a budgeted Markdown prompt. |
| `bidradar_search_public_bids` | Searches live written/async public-sector RFPs, sub-threshold P-Card quotes, and ADA Title II PDF/web opportunities via [BidRadar](https://secondforeman.com/bidradar/). |

---

## Browser Workbench, Chrome MV3 Side Panel & Pro Suite

- **Interactive Browser Workbench & Chrome Extension Download:** [https://secondforeman.com/contextguard/](https://secondforeman.com/contextguard/)
- **BidRadar — Self-Serve B2B Public-Bid, RFQ & ADA Compliance Lead Alerts:** [https://secondforeman.com/bidradar/](https://secondforeman.com/bidradar/)
- **SignalClip — B2B Directory, Table, Bulk PDF & Buyer-Signal Extractor (Chrome MV3):** [https://secondforeman.com/signalclip/](https://secondforeman.com/signalclip/)
- **ADA Title II & ISO 14289-1 (`PDF/UA-1`) GitHub Action:** [oneandroid-max/pdf-ua-audit-action](https://github.com/oneandroid-max/pdf-ua-audit-action)

Set `SECOND_FOREMAN_PRO_KEY="SC1...."` in your shell or `.mcp.json` `env` block to unlock unlimited multi-file JSONL transcript forensics, Pro `.mcp.json`/CI workflow generation, and unredacted [BidRadar](https://secondforeman.com/bidradar/) direct buyer emails (`$29/mo` or `$149/yr` instant Stripe checkout at [secondforeman.com/contextguard/#pricing](https://secondforeman.com/contextguard/#pricing)).

---

## Privacy & Publisher Disclosure

- **100% Local Processing:** `contextguard` audits files and compresses HTML locally on your machine with zero telemetry and zero code/prompt uploads.
- **Publisher:** **Second Foreman LLC** · 801 NW 10th Street #470, Oklahoma City, OK 73106-6931 · [hello@secondforeman.com](mailto:hello@secondforeman.com) · Veteran-Owned Small Business.
- Built and operated by an AI agent (Google Gemini) with Paul Edward Lewis Jr. human sign-off, guaranteed by Second Foreman LLC.