ContextForge
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ContextForgeTrace inbound calls to processPayment"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ContextForge
MCP orchestrator that combines codebase-memory-mcp + headroom into a single pipeline.
Your AI agent gets a code knowledge graph and automatic context compression — in one MCP server.
Agent (Claude Code / Codex / Cursor)
│
▼
ContextForge ←─── single MCP server
│
├─→ codebase-memory-mcp (graph query: 99% fewer retrieval tokens)
│ │
│ ▼
└─→ headroom (compression: 60–95% fewer prompt tokens)
│
▼
LLM ProviderWhy
Problem | Without ContextForge | With ContextForge |
"What calls | Agent greps 30 files → ~80K tokens | Graph query → ~500 tokens |
Tool output bloat | Raw JSON/logs fill context | headroom compresses 60–95% |
Managing two MCP servers | Two configs, two binaries | One |
Session visibility | No insight |
|
Real numbers from the upstream projects:
codebase-memory-mcp: 5 structural queries used ~3,400 tokens vs ~412,000 via file-by-file grep (99.2% reduction, arXiv:2603.27277)headroom: 47–92% token reduction on real workloads (GSM8K, TruthfulQA, SQuAD v2 accuracy preserved)
Related MCP server: knowing
Install
Prerequisites
Dependency | Install |
Python 3.10+ | |
Node.js + npm | |
codebase-memory-mcp |
|
headroom-ai |
|
Quick install (Linux / macOS)
curl -fsSL https://raw.githubusercontent.com/yourusername/contextforge/main/scripts/install.sh | bashQuick install (Windows PowerShell)
iwr -useb https://raw.githubusercontent.com/yourusername/contextforge/main/scripts/install.ps1 | iexManual install
pip install contextforge
# or with uv (recommended):
uv tool install contextforgeSetup
1. Health check
contextforge doctorExpected output:
✅ Python 3.12
✅ mcp (Model Context Protocol SDK)
✅ headroom-ai
✅ codebase-memory-mcp → /usr/local/bin/codebase-memory-mcp
✅ Everything looks good!2. Configure your agent
Claude Code (writes .mcp.json in current directory):
contextforge install --target claudeManual — add to your .mcp.json:
{
"mcpServers": {
"contextforge": {
"command": "contextforge",
"args": ["run"]
}
}
}3. Add to CLAUDE.md (recommended)
Paste this into ~/.claude/CLAUDE.md or your project's CLAUDE.md:
## ContextForge (code intelligence + compression)
When ContextForge MCP tools are available, **always prefer cbm_* tools over
grep/Glob/Read for structural code questions** — they use 99% fewer tokens.
| Instead of... | Use... |
|----------------------------|-----------------------------------------|
| Grep for a function name | `cbm_search_graph(name_pattern="...")` |
| Reading files for call chains | `cbm_trace_path(function_name="...")` |
| Exploring the architecture | `cbm_get_architecture()` |
| Text search across files | `cbm_search_code(query="...")` |
Index first: `cbm_index_repository(repo_path=".")`. After that, all results
pass through headroom compression automatically. Use `cf_stats` to see savings.Usage
Index your project (first time)
cbm_index_repository(repo_path="/path/to/your/project")This takes seconds to minutes depending on repo size. The Linux kernel (28M LOC) indexes in ~3 minutes.
Structural queries (all auto-compressed)
# Find all functions matching a pattern
cbm_search_graph(name_pattern=".*Handler.*", label="Function")
# Who calls processPayment?
cbm_trace_path(function_name="processPayment", direction="inbound")
# What would break if I change this?
cbm_get_impact(node_id="<node_id_from_search>")
# High-level architecture view
cbm_get_architecture()
# Full-text search ranked by graph importance
cbm_search_code(query="database connection pool")
# Find unused code
cbm_find_dead_code(confidence="high")Compression utilities
# Compress arbitrary text before including in context
cf_compress(text="<large log output>", hint="logs")
# Session stats
cf_stats()
# → { "tokens_saved": 42183, "overall_compression_ratio": "78%", ... }
# Reset counters for a new session
cf_reset_stats()Available tools
CBM tools (14) — routed to codebase-memory-mcp + compressed
Tool | Description |
| Index a repo into the knowledge graph |
| Search by name pattern (regex) |
| Full-text + graph-ranked code search |
| Trace call paths (inbound/outbound) |
| Full call chain analysis |
| High-level module/service overview |
| Detailed info on a graph node |
| Detect unreachable code |
| Find code clones |
| Impact radius of a change |
| Raw Cypher-like graph query |
| Architecture Decision Records |
| HTTP/gRPC/GraphQL cross-service edges |
| Indexing progress |
ContextForge meta tools (3)
Tool | Description |
| Session compression statistics |
| Compress arbitrary text with headroom |
| Reset session counters |
Environment variables
Variable | Default | Description |
| auto-detect | Path to |
|
| Model hint for headroom token counting |
|
|
|
Architecture
contextforge/
├── src/contextforge/
│ ├── __init__.py
│ ├── server.py # FastMCP server — tool definitions + orchestration
│ ├── cbm_client.py # stdio JSON-RPC client for the CBM binary
│ ├── compressor.py # headroom-ai wrapper with per-tool profiles + stats
│ └── cli.py # typer CLI (run / install / doctor / info)
├── config/
│ └── default.toml # Default configuration
├── scripts/
│ ├── install.sh # Linux/macOS quick install
│ └── install.ps1 # Windows PowerShell quick install
├── pyproject.toml
└── README.mdRequest lifecycle:
Agent calls a
cbm_*tool via MCPserver.pyforwards the call tocbm_client.pycbm_client.pysends a JSON-RPC request to thecodebase-memory-mcpsubprocess over stdioThe result comes back as structured JSON
compressor.pyruns it throughheadroom-ai[compress()]with a tool-specific profileCompressed result (+ token savings header) is returned to the agent
Why a subprocess and not a native library?
codebase-memory-mcp is a static C binary — no Python bindings exist. The stdio JSON-RPC protocol is its native interface. This is actually an advantage: zero Python dependency conflicts, and the binary is self-contained.
Contributing
PRs welcome. Key areas:
Additional tool profiles in
compressor.py— better headroom hints per CBM toolIncremental reindex — watch file changes and trigger
index_repositoryautomaticallyStats persistence — save session stats to disk for long-running workflows
Docker image — bundle both binaries in one container
Credits
Built on top of:
codebase-memory-mcp by DeusData — MIT License
headroom by headroomlabs-ai — Apache 2.0
ContextForge itself is MIT licensed.
License
MIT — see LICENSE
This server cannot be deployed
Maintenance
Related MCP Connectors
- WauldoOAuthcom.wauldo
Stateless agentic tools over MCP: concept extraction, long-context, knowledge graph, planning.
LLM Orchestration MCP Agent
MCP-Native LLM Orchestration Agent
Multiple MCP tools, persistent graph memory, token-saving data pointers, and more.
Related MCP Servers
- AlicenseAqualityCmaintenanceUnified MCP orchestration layer that consolidates multiple MCPs into a single interface with semantic tool discovery, code-mode execution, scheduling, and intelligent caching to reduce token usage by 97% and eliminate choice paralysis.299 npm98Elastic 2.0

knowingofficial
AlicenseNot gradedqualityAmaintenanceContent-addressed code graph that produces ranked context for AI agents in one call. 22 MCP tools across indexing, blast radius, test scope, semantic diff, runtime traffic, and feedback-aware context packing. Incremental updates via Merkle DAG (no re-indexing). GCF wire format saves 84% tokens vs JSON18MIT- AlicenseNot gradedqualityCmaintenanceToken-efficient MCP reimplementation with progressive tool discovery, result handling, and compact wire encoding, reducing token usage by up to 89% on tool definitions.1MIT
- AlicenseCqualityAmaintenanceAn MCP server that filters and compresses context by 80-90% before sending to an LLM, using code knowledge graphs and compression.202MIT