Skip to main content
Glama

ContextForge MCP — Deterministic Token Compressor & Context-Window Compiler

Live Remote MCP Endpoint (Streamable HTTP · Zero Auth · Zero LLM Calls): https://context-forge-mcp.yashwant938.workers.dev/mcp
Live Interactive Edge Playground: https://context-forge-mcp.yashwant938.workers.dev
Official MCP Registry ID: io.github.yashwant938/context-forge-mcp

ContextForge MCP is a zero-dependency Model Context Protocol (2025-03-26) server, standalone CLI, and installable Agent Plugin that cuts 60–90% of context-window bloat deterministically—with zero external LLM API keys, zero runtime dependencies, and exact line-number traceability.

Most agent failures in production aren't model-intelligence failures—they're context-harness failures:

  1. Codebase Overload — Dumping 25 raw files burns 40,000+ tokens and triggers Lost-in-the-Middle recall decay.

  2. Noisy Terminal Logs & Giant JSON Dumps — Repetitive timestamps, UUIDs, healthcheck lines, and 500-row API arrays drown out the 3 lines that actually explain the crash.

  3. Silent RAG Encoder Truncation — Chunks exceeding 256 tokens (all-minilm-l6-v2) or 512 tokens (bge-small-en) are silently chopped off during embedding, while redundant chunks waste generation context.

  4. Blind Token Economics — Connecting 30+ eager MCP tools quietly burns 6,000–12,000 tokens every single turn before the user even writes a sentence.

ContextForge replaces ad-hoc truncation with deterministic multi-language code skeletonization, Drain-style log clustering, JSON/OpenAPI schema folding, token-bounded RAG re-chunking + U-shaped attention packing, and BM25 multi-fidelity budget compilation.


Quick Connect (Claude Code, Cursor, Antigravity, Windsurf, Codex)

Option A — Hosted Remote MCP (5 Seconds · Zero Install · Zero Auth)

{
  "mcpServers": {
    "context-forge": {
      "url": "https://context-forge-mcp.yashwant938.workers.dev/mcp"
    }
  }
}

Option B — Local Stdio MCP (Unlocks Direct Disk compile_repo_context)

{
  "mcpServers": {
    "context-forge-local": {
      "command": "node",
      "args": ["/absolute/path/to/context-forge-mcp/bin/context-forge-mcp.mjs"]
    }
  }
}

Option C — Standalone CLI (Zero Dependencies · Node >= 20)

# BM25-rank & pack a repository into a strict 6,000-token XML bundle
node bin/cli.mjs pack . "authentication jwt refresh" 6000

# Skeletonize any JS/TS/Python/C++/Go/Rust/Java file with Lstart-Lend ranges
node bin/cli.mjs skeleton src/engines/codeSkeletonizer.mjs signatures

# Cluster a noisy CI/Docker/server log into prioritized error templates + unique stack traces
node bin/cli.mjs logs build.log

# Compact a huge JSON payload or OpenAPI 3.x spec into an inferred schema + stats
node bin/cli.mjs json openapi.json

# Simulate multi-turn token growth, compaction cliff & monthly USD savings
node bin/cli.mjs budget claude-sonnet-4 35 25

Related MCP server: cap-shield-mcp

MCP Primitives Implemented (7 Tools · 4 Resources · 3 Prompts)

7 Deterministic MCP Tools

Tool

Transport

What It Computes

compile_repo_context

Local stdio

Walks a repo on disk (ignoring .git, node_modules, lockfiles, .env, binaries) → ranks files against taskQuery via BM25 → compiles a strict token-budgeted XML context pack mixing full code + line-indexed skeletons

compile_context_pack

Remote & Local

Multi-artifact BM25 + multi-fidelity context compiler over source files, logs, and JSON passed over HTTP, with a dropped-file manifest for on-demand expansion

skeletonize_code

Remote & Local

Multi-language skeletonizer (JS/TS, Python, C/C++, Go, Rust, Java) with 3 modes: signatures (65–88% savings), outline, and symbol-focus (keeps full bodies only for target symbols)

compress_logs_and_traces

Remote & Local

Drain-style template normalizer (timestamps, UUIDs, IPs, hex, numbers) + severity-prioritized clustering + unique stack-trace extraction (70–95% savings)

compact_json_and_api

Remote & Local

Collapses giant JSON arrays into inferred typed schemas (min..max, enum, optionality, 1 trimmed sample) and compacts OpenAPI 3.x / Swagger specs into route & component tables (75–92% savings)

audit_and_pack_rag_context

Remote & Local

Audits encoder truncation (MiniLM 256, BGE/E5 512, Nomic 2048, OpenAI 8191, Voyage 32k), re-chunks to 0% overflow, deduplicates via Jaccard similarity, and applies Lost-in-the-Middle U-shaped ordering

simulate_context_budget

Remote & Local

Turn-by-turn token trajectory across 8 frontier models (Claude Sonnet/Opus 4, GPT-5, GPT-4.1, Gemini 2.5 Pro/Flash, DeepSeek V3, Qwen3 Coder), calculating MCP schema tax, compaction cliff turn, prompt caching, and monthly USD savings

4 MCP Resources (resources/list, resources/read)

  • context-forge://guide/compression-playbooks — Deterministic strategy matrix by artifact type

  • context-forge://guide/model-pricing-windows — Frontier context windows, attention sweet spots & cached pricing

  • context-forge://guide/lost-in-the-middle — Encoder truncation limits & U-shaped attention packing

  • context-forge://guide/mcp-token-hygiene — Avoiding eager MCP tool-schema bloat

3 MCP Prompts (prompts/list, prompts/get)

  • compress-debug-session — Cluster raw crash logs + pack suspect source files before diagnosing a bug

  • pack-repo-for-feature — BM25 repo packing workflow before multi-file implementation

  • optimize-rag-pipeline — Encoder overflow audit + near-duplicate pruning + U-shaped reordering


Development, Testing & Deployment

# Run full unit + local stdio MCP + Cloudflare Worker Streamable HTTP tests
npm test

# Dogfood BM25 repo packer on ContextForge's own codebase
npm run pack:self

# Build zero-dependency Cloudflare Worker bundle (dist/worker.mjs)
npm run build:worker

# Deploy to Cloudflare Workers Edge
npx wrangler deploy

Related project: ArchGuard MCP (Architecture Drift, SQL DDL & Distributed Systems Verifier)

Available Tools

7 tools
audit_and_pack_rag_contextA

Audit retrieved RAG passages against embedding encoder hard limits (MiniLM 256, BGE/E5 512, Nomic 2048, OpenAI 8191, Voyage 32k), eliminate silent truncation via sentence-bounded re-chunking, remove Jaccard near-duplicates, and apply Lost-in-the-Middle U-shaped attention ordering inside a strict token budget.

Inputs: chunks (required), encoderModel, overlapTokens, dedupThreshold, +3 more.

compact_json_and_apiA

Deterministically compact huge JSON payloads, DB query dumps, or OpenAPI 3.x/Swagger specs into an inferred typed schema with field cardinality, numeric min/max ranges, enum distributions, and a trimmed sample item (75-92% token reduction).

Inputs: payload (required), maxDepth.

compile_context_packB

BM25-ranked, token-budgeted multi-artifact context compiler. Ranks source files, logs, JSON dumps, and docs against a taskQuery, keeping top files verbatim, skeletonizing supporting dependencies, clustering logs, and outputting a strict XML context pack + dropped-file manifest.

Inputs: files (required), taskQuery (required), fullTopK, tokenBudget.

compile_repo_contextA

Walk a local repository on disk (skipping node_modules, .git, lockfiles, binaries, and .env secrets), rank files against taskQuery via BM25, and compile a strict token-budgeted context pack mixing verbatim target code and line-indexed skeletons.

Inputs: rootPath (required), taskQuery (required), fullTopK, maxFiles, +1 more.

compress_logs_and_tracesA

Drain-style deterministic log template clusterer and stack-trace deduplicator. Normalizes timestamps, UUIDs, IPs, hex pointers, and numbers to collapse 1,000+ noisy CI/server/test lines into frequency-ranked ERROR/WARN clusters + unique stack traces (70-95% token reduction).

Inputs: logs (required), maxClusters, preserveStackTraces.

simulate_context_budgetB

Deterministic multi-turn agent context-window and cost economics simulator. Computes exact MCP schema tax, turn-by-turn token growth, Lost-in-the-Middle degradation cliff turn, 85% compaction wall turn, prompt-cache economics, and monthly USD savings across 8 frontier models.

Inputs: model, turns, mcpToolCount, sessionsPerDay, +6 more.

skeletonize_codeA

Deterministically compress JS/TS, Python, C/C++, Go, Rust, or Java source code into a line-indexed signature skeleton (or symbol-focus view that expands only matching functions), cutting 65-88% tokens while preserving imports, types, signatures, and exact Lstart-Lend ranges.

Inputs: code (required), mode, path, language, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 7 tools

    Disambiguation4/5

    Each tool targets a distinct artifact type (JSON/OpenAPI, source code, logs/traces, RAG passages) or task (repo walk, budget simulation), so purposes are mostly clear. The three 'pack/compile' tools (compile_context_pack, compile_repo_context, audit_and_pack_rag_context) overlap somewhat since all produce budgeted context, but input-source differences in the descriptions help disambiguate.

    Naming Consistency4/5

    Names follow a consistent snake_case, verb-led convention (compact_, compile_, skeletonize_, compress_, audit_and_pack_, simulate_). Minor deviations: audit_and_pack_rag_context uses two verbs, and compress vs compact are near-synonyms, but overall pattern is predictable.

    Tool Count5/5

    Seven tools is well-scoped for a context/token-optimization toolkit, with each tool covering a distinct compression or analysis concern. No redundant or filler tools.

    Completeness4/5

    The surface broadly covers artifact compaction (JSON, code, logs), context packing (multi-artifact, repo, RAG), and budget simulation, forming a coherent lifecycle. Minor gaps: no standalone token-count/validation tool and no inverse (expand/restore) operations, though simulate_context_budget partially covers estimation.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A task-aware context compression layer for Agent workflows, RAG pipelines, and AI Coding assistants, reducing noisy logs, retrieval chunks, and code context into high-signal LLM inputs via CLI, Python SDK, and MCP.
      22 PyPI
      324
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to compress and selectively retrieve context, with measured recall rather than claimed performance. It provides tools to assess potential traffic and token savings, list compression dictionaries, and assemble relevant memory entries within a token budget.
      MIT
    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables MCP-compatible clients and autonomous agents to dynamically compress long-horizon context by pruning verbose tool outputs, HTML boilerplate, and semantic redundancy by 40-70%. It reduces token burn and latency through deterministic, zero-dependency processing.
      -
    • A
      license
      A
      quality
      B
      maintenance
      Deterministic, local-first context optimization for AI coding agents. Automatically compresses raw development session data (messages, tool logs, error stack traces, and git diffs) into a compact, task-specific context window. Operates 100% locally with zero external LLM dependencies, ensuring your source code never leaves your machine.
      6
      33 npm
      MIT