# Context Crush — Deterministic LLM Context Compactor (v1.0.0)

> Cut WebVTT/SRT transcripts, .eml reply chains, Slack threads, and Jira ADF JSON by 65-90% tokens in <15ms with zero LLM summarization loss.

Zero-hallucination deterministic compaction for WebVTT/SRT meeting transcripts, RFC 5322 .eml & O(N^2) quoted email threads, Slack JSON exports, and Jira v3 Atlassian Document Format (ADF) issues.

## Why Agents Use This API Instead of DIY
Replaces fragile MIME/quoted-printable decoders, rolling live-caption overlap logic, O(N^2) email quote peelers, and recursive Jira ADF AST renderers—saving $0.02-$0.15 in downstream frontier-LLM input tokens for a $0.001-$0.005 edge call.

## Connection & Payment (x402 Default + Optional Bearer API Key)
- **MCP Server (Streamable HTTP):** `https://context-crush.apikeg.com/mcp` (Registry ID: `com.apikeg/context-crush` — `initialize`, `tools/list`, `resources/*`, and `prompts/*` are free)
- **OpenAPI 3.1 Spec:** [openapi.json](https://context-crush.apikeg.com/openapi.json)
- **Full Schema & Examples:** [llms-full.txt](https://context-crush.apikeg.com/llms-full.txt)
- **RFC 9727 API Catalog:** [.well-known/api-catalog](https://context-crush.apikeg.com/.well-known/api-catalog)
- **x402 Bazaar Manifest:** [.well-known/x402.json](https://context-crush.apikeg.com/.well-known/x402.json)
- **MCP Discovery Manifest:** [.well-known/mcp.json](https://context-crush.apikeg.com/.well-known/mcp.json)
- **A2A Agent Card:** [.well-known/agent-card.json](https://context-crush.apikeg.com/.well-known/agent-card.json)
- **Primary Payment (Zero Signup):** Cloudflare Monetization Gateway (`HTTP 402` / `x402` v2 with USDC on Base).
- **Optional Monthly API Key:** Pass `Authorization: Bearer ak_live_...` ($5 / $20 / $50 monthly per-product Stripe plans at [apikeg.com/account](https://apikeg.com/account)).
- **Free Preflight:** Append `?dry_run=true` (or header `X-Dry-Run: true`) to validate any request payload at `$0.00` cost.

## Tools & REST Endpoints
- [`compact_transcript`](https://context-crush.apikeg.com/tools/compact-transcript.md) (`POST https://context-crush.apikeg.com/v1/compact-transcript`) — $0.001 base (up to $0.005 max ($0.001 base + $0.0005 per 50KB of input, capped at $0.005 for payloads up to 2MB), x402 variable settlement): Parses WebVTT (<v Speaker>, NOTE/STYLE blocks, cue UUIDs), SubRip (.srt), or Zoom/Teams/Otter text transcripts; deduplicates rolling live captions, coalesces speaker turns into Markdown, and computes speaker talk-turn stats.
- [`compact_email_thread`](https://context-crush.apikeg.com/tools/compact-email-thread.md) (`POST https://context-crush.apikeg.com/v1/compact-email-thread`) — $0.001 base (up to $0.005 max ($0.001 base + $0.0005 per 50KB of input, capped at $0.005 for payloads up to 2MB), x402 variable settlement): Decodes raw RFC 5322 .eml MIME messages (multipart/alternative, quoted-printable, base64) or pasted reply chains, strips O(N^2) repeated quoted history, mobile signatures, and legal disclaimers, and outputs chronological Markdown.
- [`compact_workspace_export`](https://context-crush.apikeg.com/tools/compact-workspace-export.md) (`POST https://context-crush.apikeg.com/v1/compact-workspace-export`) — $0.001 base (up to $0.005 max ($0.001 base + $0.0005 per 50KB of input, capped at $0.005 for payloads up to 2MB), x402 variable settlement): Compacts Slack channel/thread JSON (resolving <@U...> mentions, dropping join/leave noise, grouping thread_ts replies, formatting reactions, stripping Block Kit) or Jira v3 Issue/ADF JSON (rendering headings, tables, code blocks, lists, mentions, comments while dropping avatarUrls and null customfield_* keys).

## Instant MCP Configuration
```json
{
  "mcpServers": {
    "context-crush": {
      "type": "streamable-http",
      "url": "https://context-crush.apikeg.com/mcp"
    }
  }
}
```

## Common Agent Use Cases
- compress WebVTT SRT meeting transcript for LLM context
- deduplicate quoted email thread RFC 5322 eml parser MCP
- convert Jira v3 ADF Atlassian Document Format JSON to Markdown
- compact Slack channel export JSON threads and mentions for AI agents
- reduce prompt tokens without lossy summarization

---

## Detailed Tool Specifications

### `compact_transcript` — Compact Meeting Transcript (WebVTT / SRT / Text)
- **REST Endpoint:** `POST https://context-crush.apikeg.com/v1/compact-transcript`
- **Tool Doc Page:** https://context-crush.apikeg.com/tools/compact-transcript
- **MCP Tool Name:** `compact_transcript`
- **Pricing:** $0.001 base (up to $0.005 max ($0.001 base + $0.0005 per 50KB of input, capped at $0.005 for payloads up to 2MB), x402 variable settlement)
- **Side Effects:** readOnly=true, idempotent=true, destructive=false
- **Build vs. Buy ROI:** Eliminates 75-90% of caption cue UUID/timestamp/overlap bloat in <10ms with 100% lossless dialogue retention—costing a fraction of the LLM input tokens saved.

#### Input JSON Schema
```json
{
  "type": "object",
  "properties": {
    "transcript": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2000000,
      "description": "Raw meeting transcript in WebVTT (.vtt), SubRip (.srt), or plain-text ([HH:MM:SS] Speaker:) format."
    },
    "format": {
      "type": "string",
      "enum": [
        "auto",
        "vtt",
        "srt",
        "text"
      ],
      "default": "auto",
      "description": "Input transcript format; defaults to automatic detection."
    },
    "timestampFormat": {
      "type": "string",
      "enum": [
        "auto",
        "mm:ss",
        "hh:mm:ss",
        "none"
      ],
      "default": "auto",
      "description": "Rendered Markdown timestamp style ('auto' uses [MM:SS] under 1h and [HH:MM:SS] at >=1h)."
    },
    "timestampIntervalSec": {
      "type": "integer",
      "default": 0,
      "minimum": 0,
      "maximum": 3600,
      "description": "Minimum seconds between emitted speaker-turn timestamps (0 = emit at every speaker switch)."
    },
    "removeFillers": {
      "type": "boolean",
      "default": false,
      "description": "Strip vocal disfluencies ('um', 'uh', 'er', 'ah', 'hmm', parenthetical 'you know') while preserving dialogue."
    }
  },
  "required": [
    "transcript"
  ],
  "additionalProperties": false
}
```

#### Examples
**Compact WebVTT meeting with rolling live captions** — Strips NOTE/STYLE metadata, merges overlapping cues, and coalesces consecutive speaker turns.
```bash
curl -X POST "https://context-crush.apikeg.com/v1/compact-transcript" \
  -H "Content-Type: application/json" \
  -d '{"format":"auto","timestampFormat":"auto","timestampIntervalSec":0,"removeFillers":true,"transcript":"WEBVTT\n\nNOTE exported by Meet\n\ncue-1\n00:01:12.000 --> 00:01:14.200 align:start\n<v Alice Chen>Um, welcome everyone to</v>\n\ncue-2\n00:01:14.200 --> 00:01:17.500 align:start\n<v Alice Chen>welcome everyone to the Q4 launch review.</v>"}'
```
Expected result: Single clean '[01:12] **Alice Chen:** Welcome everyone to the Q4 launch review.' turn + speaker stats + token reduction metrics.

### `compact_email_thread` — De-duplicate Email Thread & RFC 5322 .eml
- **REST Endpoint:** `POST https://context-crush.apikeg.com/v1/compact-email-thread`
- **Tool Doc Page:** https://context-crush.apikeg.com/tools/compact-email-thread
- **MCP Tool Name:** `compact_email_thread`
- **Pricing:** $0.001 base (up to $0.005 max ($0.001 base + $0.0005 per 50KB of input, capped at $0.005 for payloads up to 2MB), x402 variable settlement)
- **Side Effects:** readOnly=true, idempotent=true, destructive=false
- **Build vs. Buy ROI:** Avoids writing RFC 2047/quoted-printable/multipart MIME parsers and multi-client Outlook/Gmail quote splitters; collapses 10-reply O(N^2) threads by >80%.

#### Input JSON Schema
```json
{
  "type": "object",
  "properties": {
    "content": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2000000,
      "description": "Raw RFC 5322 .eml MIME message (multipart/alternative, quoted-printable, base64) or pasted multi-reply email thread."
    },
    "stripSignatures": {
      "type": "boolean",
      "default": true,
      "description": "Strip mobile/client footers ('Sent from my iPhone', 'Get Outlook for iOS') and RFC 3676 '-- ' tails."
    },
    "stripDisclaimers": {
      "type": "boolean",
      "default": true,
      "description": "Strip standard corporate confidentiality and legal disclaimer footer blocks."
    }
  },
  "required": [
    "content"
  ],
  "additionalProperties": false
}
```

#### Examples
**Peel nested Gmail & Outlook reply chain with legal footers**
```bash
curl -X POST "https://context-crush.apikeg.com/v1/compact-email-thread" \
  -H "Content-Type: application/json" \
  -d '{"stripSignatures":true,"stripDisclaimers":true,"content":"Approved — let's lock in the annual tier.\n\nSent from my iPhone\n\nOn Tue, Nov 12, 2026 at 2:15 PM Alice Chen <alice@acme.com> wrote:\n> Can you confirm final pricing?\n>\n> CONFIDENTIALITY NOTICE: This email and any attachments are confidential."}'
```
Expected result: 2 chronological deduplicated messages + participant roster + stripped signature/disclaimer counts.

### `compact_workspace_export` — Compact Slack Export or Jira v3 ADF JSON
- **REST Endpoint:** `POST https://context-crush.apikeg.com/v1/compact-workspace-export`
- **Tool Doc Page:** https://context-crush.apikeg.com/tools/compact-workspace-export
- **MCP Tool Name:** `compact_workspace_export`
- **Pricing:** $0.001 base (up to $0.005 max ($0.001 base + $0.0005 per 50KB of input, capped at $0.005 for payloads up to 2MB), x402 variable settlement)
- **Side Effects:** readOnly=true, idempotent=true, destructive=false
- **Build vs. Buy ROI:** Turns bloated 100KB+ Jira REST v3 ADF issues and Slack API payloads into crisp 3KB Markdown without losing comments, tables, code blocks, or reactions.

#### Input JSON Schema
```json
{
  "type": "object",
  "properties": {
    "content": {
      "type": "string",
      "minLength": 2,
      "maxLength": 2000000,
      "description": "Raw Slack channel/thread JSON export or Jira Issue / Atlassian Document Format (ADF v3) JSON payload."
    },
    "format": {
      "type": "string",
      "enum": [
        "auto",
        "slack_json",
        "jira_json"
      ],
      "default": "auto",
      "description": "Workspace JSON format; defaults to automatic Slack vs. Jira ADF detection."
    },
    "users": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "maxLength": 120
      },
      "description": "Optional Slack user ID to display handle map (e.g. { \"U01ABC\": \"alice\" }) used to resolve <@U...> mentions."
    },
    "includeReactions": {
      "type": "boolean",
      "default": true,
      "description": "Render concise Slack reaction badges such as '[+3 👍]'."
    }
  },
  "required": [
    "content"
  ],
  "additionalProperties": false
}
```

#### Examples
**Compact Slack incident thread with user resolution**
```bash
curl -X POST "https://context-crush.apikeg.com/v1/compact-workspace-export" \
  -H "Content-Type: application/json" \
  -d '{"format":"slack_json","users":{"U01ALICE":"alice","U02BOB":"bob"},"includeReactions":true,"content":"[{\"type\":\"message\",\"subtype\":\"channel_join\",\"user\":\"U01ALICE\",\"ts\":\"1731491900.000100\"},{\"type\":\"message\",\"user\":\"U01ALICE\",\"text\":\"Canary deployed — cc <@U02BOB>\",\"ts\":\"1731492000.000200\",\"reactions\":[{\"name\":\"rocket\",\"count\":3}]}]"}'
```
Expected result: Clean Markdown timeline with @bob resolved, channel_join noise dropped, and [+3 🚀] badge.
