code context engineのロゴ

code context engine

組織
elara-labs

Save 94% on AI coding tokens. Index your codebase, agents search instead of reading files. Works with Claude Code, Codex, Copilot, Cursor, Gemini CLI. Local MCP server, free, open source.

公開者elara-labs
リポジトリcode-context-engine
言語Python
フォーク
67
スター
423
利用可能なツール
0
通信方式stdio
カテゴリ
ライセンスMIT
リンク
  • ツールをAIワークフローに接続

    code context engineは、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 0個の利用可能なツール

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースの注目度

    リンク先のリポジトリには423件のスターと67件のフォークがあります。


Use cases

Use caseHow CCE helps
💰Reduce Claude Code costs94% fewer input tokens per session
🔒Keep code privateEverything local, no cloud indexing
🔄Multi-editor teamsOne index across Claude Code, Cursor, VS Code, Gemini CLI
🧠Cross-session memoryDecisions and context survive restarts
⚡Faster responsesLess context = faster Claude replies
📊Track actual savingsDollar amounts, not estimates

Quick start

One command. 30 seconds.

bash
uvx --from "code-context-engine[local]" cce init    # install + index + configure, one shot

Or if you prefer a persistent install:

bash
uv tool install "code-context-engine[local]"    # or: pipx install "code-context-engine[local]"
cd /path/to/your/project
cce init

Restart your editor. Done. Every question now hits the index instead of re-reading files.

Agent Plugin support: Run cce init --plugin to generate a portable Agent Plugin directory that works with VS Code, Cursor, Copilot, Codex, ChatGPT, and Kiro. The plugin uses uvx to launch CCE on demand, so users don't need to pre-install the Python package. See Agent Plugin below.

Already have Ollama? Skip [local] and use uv tool install code-context-engine instead. CCE auto-detects Ollama at localhost:11434 and uses nomic-embed-text.

Python 3.11+ and a C compiler (for tree-sitter grammars).

PlatformSetup
macOSxcode-select --install
Ubuntu/Debiansudo apt install build-essential cmake
Fedora/RHELsudo dnf install gcc gcc-c++ cmake
WindowsVisual Studio Build Tools (C++ workload) + CMake

Tested on macOS, Linux, Windows with Python 3.11/3.12/3.13.

cce init auto-detects your editor and writes the right config. To target a specific agent, use --agent claude, --agent codex, --agent copilot, --agent pi, or --agent all.

EditorConfig writtenInstructions
Claude Code.mcp.jsonCLAUDE.md
VS Code / Copilot.vscode/mcp.json.github/copilot-instructions.md
Cursor.cursor/mcp.json.cursorrules
Gemini CLI.gemini/settings.jsonGEMINI.md
OpenAI Codex~/.codex/config.toml (user-global, per-project section)AGENTS.md
OpenCodeopencode.json
Tabnine.tabnine/agent/settings.jsonTABNINE.md
Pi.mcp.jsonAGENTS.md

Multiple editors in the same project? All get configured in one command.

Codex note: Codex CLI reads MCP servers from ~/.codex/config.toml only — it has no per-project config. cce init adds one [mcp_servers.cce-<project>-<hash>] section per project so multiple projects coexist; cce uninstall removes only the section for the current project.

Pi note: Pi does not support MCP natively. To use CCE with Pi, you need a pi MCP adapter extension (e.g. pi-mcp-adapter) that consumes the .mcp.json config and exposes CCE's tools to the Pi agent. cce init sets up both .mcp.json and AGENTS.md (Pi loads the latter automatically for startup instructions).

  my-project · 38 queries · last query 5m ago

  ⛁ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶  88% tokens saved

  Input savings   1.9M  tokens   $27.78
  Output savings  4.8k  tokens   $0.36
  ──────────────────────────────────────────
  Total saved   1.9M  tokens   $28.15

  Breakdown:
    retrieval              84%  ▰▰▰▰▰▰▰▰▰▰    1.8M   $26.76 · 12 calls
    chunk compression       3%  ▰▱▱▱▱▱▱▱▱▱   68.5k    $1.03 · 12 calls
    output compression*    <1%  ▰▱▱▱▱▱▱▱▱▱    4.8k    $0.36 · 12 calls

  Cost estimate based on Opus pricing (input $15.0/1M, output $75.0/1M)

Supports Anthropic, OpenAI, and Google model pricing. Configure via pricing.model in ~/.cce/config.yaml.


Why this matters

Input tokens are 85-95% of your Claude Code bill. CCE cuts them by 94% (benchmarked on FastAPI).

Without CCE:    Claude reads payments.py + shipping.py   = 45,000 tokens
With CCE:       context_search "payment flow"            =    800 tokens
Without CCEWith CCE
Session startupRe-reads files every timeQueries the index
Finding a functionRead entire 800-line fileGet the 40-line function
Cross-session memoryNoneDecisions + code areas persisted
Token cost (Sonnet, medium project)~$0.14/session~$0.04/session

Benchmark: FastAPI (reproducible)

We benchmarked CCE against FastAPI (53 source files, 180K tokens) with 20 real coding questions. No cherry-picking, no synthetic queries.

Methodology: For each query, "without CCE" means reading the full content of every file the query touches. "With CCE" means the relevant chunks after compression.

Important baseline note: The 94% number is measured against full-file reads, not against what Claude Code actually does. In practice, Claude Code already uses grep, partial file reads, and targeted tools, so the real-world savings compared to normal Claude Code behavior will be lower than 94%. We use full-file as the baseline because it's reproducible and deterministic (no agent behavior variability). The benchmark measures CCE's retrieval efficiency, not a head-to-head comparison with Claude Code's built-in exploration.

MetricResult
Retrieval savings94% (83,681 → 4,927 tokens/query)
Compression (additional, on retrieved chunks)89% (4,927 → 523 tokens/query)
Recall@10 (found the right files)0.90
Latency p500.4ms
Queries tested20

Per-Layer Savings (each measured independently)

LayerWhat it doesSavingsMethod
RetrievalFull files → relevant code chunks94%measured
Chunk CompressionRaw chunks → signatures + docstrings89%measured
GrammarDrops articles/fillers from memory text13%measured

Output compression (reducing Claude's reply length) provides additional savings (~65% estimated) but is not included in the headline number above.

Multi-language benchmarks

RepoLanguageFilesRetrieval savingsRecall@10
FastAPIPython5394%0.90
DjangoPython (large)2,34793%0.95
ExpressJavaScript694%1.00
chiGo9476%0.67
fiberGo (monorepo)39693%0.07

Django (2,347 files, 5.4M tokens) shows CCE scales to large codebases with 0.95 recall. Go's shorter files reduce the retrieval headroom (smaller baseline). Monorepos dilute recall at top-10 (fiber). Middleware queries with one-feature-per-file hit R=1.00 consistently.

Reproduce it yourself:

bash
pip install code-context-engine
python benchmarks/run_benchmark.py --repo https://github.com/fastapi/fastapi.git --source-dir fastapi
python benchmarks/run_benchmark.py --repo https://github.com/go-chi/chi.git --source-dir .

Full results in benchmarks/results/. Queries and methodology in benchmarks/.


What you get

11 MCP tools that Claude uses automatically:

ToolWhat it does
context_searchHybrid vector + BM25 search with graph expansion
expand_chunkFull source for a compressed result
related_contextFind code via graph edges (calls, imports)
session_recallRecall decisions from past sessions
session_timelineWalk turn summaries for a session (drill into recall hits)
session_eventInspect raw tool input/output for a specific event
record_decisionSave a decision for future sessions
record_code_areaRecord which files were worked in
index_statusCheck index freshness
reindexRe-index a file or the full project
set_output_compressionAdjust response verbosity (off / lite / standard / max)

Live dashboard with donut charts, file health, and session history:

bash
cce dashboard

CCE Dashboard

Dollar estimates with multi-provider pricing (Anthropic, OpenAI, Google):

bash
cce savings --all    # see savings across all projects

How it works

  1. Index: Tree-sitter parses your code into semantic chunks (functions, classes, modules). Stored as vector embeddings locally.
  2. Search: Claude calls context_search. Hybrid vector + BM25 retrieval finds the right chunks. Code graph adds related files automatically.
  3. Compress: Chunks are truncated to signatures + docstrings (or LLM-summarized if Ollama is running).
  4. Remember: Decisions and code areas persist across sessions via session_recall.
  5. Track: Every query is logged. cce savings shows exactly how much you saved.

Re-indexing after edits takes under 1 second (96% embedding cache hit rate). Git hooks keep the index current automatically.


What makes CCE different

It saves where the money is

Output compression tools (like Caveman) save 20-75% on output tokens. Output is 5-15% of your bill. Net savings: ~11%.

CCE saves on input tokens (94% retrieval savings on FastAPI, reproducibly benchmarked). Input is 85-95% of your bill.

It actually understands your code

Not a text search. Tree-sitter AST parsing creates semantic chunks. Hybrid retrieval merges vector similarity with BM25 keyword matching via Reciprocal Rank Fusion. A confidence scorer blends similarity (50%), keyword match (30%), and recency (20%). Graph expansion walks CALLS/IMPORTS edges to pull in related code.

It remembers

record_decision("use JWT for auth", reason="session tokens flagged by legal") is stored in SQLite and surfaces via session_recall in the next session. No re-explaining your architecture.

It tracks real savings

Not estimates. Actual tokens served vs full-file baseline, broken down by buckets (retrieval, compression, output, memory, grammar). Dollar costs fetched from Anthropic's pricing page. Savings summary shown at every session start.

It is secure by default

Secret files (.env, *.pem, credentials.json) are never indexed. Content is scanned for AWS keys, GitHub tokens, Slack tokens, Stripe keys, JWTs, and generic credentials. PII (emails, IPs, SSNs, credit cards) is scrubbed from memory writes. All MCP file paths are validated against path traversal.


Under the hood

SHA-256 fingerprint per chunk, salted with model name. Re-index skips unchanged code. Binary float32 storage (10x smaller than JSON). Typical re-index: 96% cache hit, under 1 second.

Replaced LanceDB with sqlite-vec. Same cosine-distance quality, 99% smaller install. WAL mode + PRAGMA NORMAL for 80% write speedup. Vectors, FTS5, code graph, and compression cache all in three SQLite files.

Memory entries compressed without LLM calls. Drops articles, fillers, pronouns. Three levels (lite/full/ultra, 20-60% savings). Code, paths, URLs preserved byte-for-byte. Same input always yields same output.

5 Claude Code lifecycle hooks capture session context. Every hook runs curl ... || true, so a crashed server never blocks the user. SessionStart injects bootstrap context; others capture silently.

Dollar estimates in cce savings support 15+ models across Anthropic, OpenAI, and Google. Static pricing ships with CCE, live Anthropic pricing is fetched and cached 7 days. Configure pricing.model (e.g. gpt-4o, gemini-2.5-pro, sonnet) or override with pricing.input / pricing.output for custom rates.

Running dozens of cce serve processes (one per project per AI session) can exhaust system memory. The resource governor caps ONNX Runtime threads per process, uses advisory file locks so only one process indexes a given project at a time, backs off under Linux memory pressure (PSI), and auto-shuts down idle servers after 30 minutes. Configure via serve.idle_timeout_minutes and serve.max_ort_threads.

CCE's cross-session memory depends on the agent calling record_decision and record_code_area. Memory nudges make recording ambient: after N searches without a recording, context_search results include a short reminder. At session end, the Stop hook summarizes unrecorded activity. Nudges re-arm after the first recording so they stay useful without being noisy.

cce serve --http exposes a POST /search endpoint for custom agent integrations that speak HTTP instead of MCP stdio. Same hybrid retrieval pipeline, structured JSON response with confidence scores. Input validation clamps top_k (1..100) and confidence_threshold (0.0..1.0).

7 buckets track every token saved: retrieval, chunk compression, output compression, memory recall, grammar, turn summarization, progressive disclosure. Survives restarts. Powers CLI and dashboard analytics.


Agent Plugin

Agent Plugins is an open standard (v1.0.0) backed by Amazon, Cursor, Microsoft, OpenAI, and Vercel for packaging AI skills and MCP servers into portable, zero-install bundles. CCE can generate a plugin directory that compatible editors can discover and load automatically.

bash
cce init --plugin                          # Generate at .cce/plugin/
cce init --plugin --plugin-dir ~/plugins/cce  # Custom location
cce init --agent claude --plugin           # Both: agent config + plugin

What gets generated

.cce/plugin/
├── plugin.json                       # Agent Plugins v1.0.0 manifest
├── mcp.json                          # MCP server config (uvx + stdio)
├── skills/
│   └── code-context/
│       ├── SKILL.md                  # Agent instructions (frontmatter + body)
│       └── references/
│           └── tools.md              # Per-tool parameter docs (loaded on demand)
└── LICENSE

Compatible editors

VS Code, GitHub Copilot, ChatGPT, Codex, Cursor, and Kiro. The plugin uses uvx to launch CCE on demand, so users do not need to pre-install the Python package. The MCP server auto-discovers the project root by walking up from its working directory, looking for .context-engine.yaml or .git/.

When to use --plugin vs --agent

--agent (default)--plugin
Install methodWrites editor-specific config filesGenerates a portable plugin directory
Zero-installNo, CCE must be on PATHYes, uvx fetches CCE on demand
Instruction updatesStale until cce init re-runStale until cce init --plugin re-run
Best forYour own machineSharing with a team or distributing

Both can be used together. --agent handles per-editor MCP config, --plugin provides a portable alternative.


CLI at a glance

bash
cce init                    # Index + install hooks + register MCP
cce init --plugin           # Generate Agent Plugin for VS Code, Cursor, etc.
cce                         # Status banner
cce savings                 # Token savings with dollar estimates
cce savings --all           # All projects
cce dashboard               # Web dashboard with live charts
cce search "auth flow"      # Test a query
cce status                  # Index health + config
cce services                # Ollama + dashboard + MCP status
cce commands add-rule '...' # Project rules for Claude
cce uninstall               # Clean removal of all CCE artifacts

Run cce list for the full command reference.


Configuration

Zero-config by default. Override what you need in ~/.cce/config.yaml or .context-engine.yaml:

yaml
compression:
  level: standard          # minimal | standard | full
  output: standard         # off | lite | standard | max
  ollama_url: http://localhost:11434   # point at a remote Ollama if desired

retrieval:
  top_k: 20
  confidence_threshold: 0.5

pricing:
  model: opus              # opus | sonnet | haiku | gpt-4o | gemini-2.5-pro | ...
  # input: 15.0            # override $/1M input tokens
  # output: 75.0           # override $/1M output tokens

Remote Ollama: If you run Ollama on another machine in your network, set compression.ollama_url (e.g. http://nas.local:11434) or export CCE_OLLAMA_URL (the env var wins). CCE probes the endpoint and falls back to truncation-only compression when it's unreachable, so a flaky link won't break indexing.


Output Compression

CCE also compresses Claude's responses (same concept as Caveman):

LevelStyleSavings
offFull output0%
liteNo filler or hedging~30%
standardFragments, drop articles~65%
maxTelegraphic~75%

Tell Claude: "switch to max compression" or "turn off compression". Code blocks and commands are never compressed.


Disk Footprint

ComponentSize
Core install (Ollama backend)~17 MB
With [local] extra (fastembed + ONNX)~189 MB
Embedding model (one-time download)~60 MB (fastembed) or managed by Ollama
Index per project (small/medium/large)5-60 MB

No GPU required. With Ollama, embeddings are handled by the Ollama server. With the [local] extra, the embedding model runs on CPU via ONNX Runtime.


Supported Languages

AST-aware chunking (tree-sitter parsed, 11 extensions):

LanguageExtensions
Python.py
JavaScript.js, .jsx
TypeScript.ts, .tsx
PHP.php
Go.go
Rust.rs
Java.java
C#.cs

Language-aware fallback chunking (40+ extensions):

CategoryLanguages
WebHTML, CSS, SCSS, LESS, Vue, Svelte
SystemsC, C++, Zig, Nim
MobileSwift, Kotlin, Dart
FunctionalHaskell, Scala, Clojure, Elixir, Erlang, F#
ScriptingRuby, Perl, Lua, R, Bash/Zsh
Data/ConfigJSON, YAML, TOML, XML, SQL, GraphQL, Protobuf
DevOpsTerraform, HCL, Dockerfile
DocsMarkdown

All other text files are chunked by line range. Binary files are skipped.


Documentation

PageContent
How Much Are You Spending on AI Coding Tokens?The math on input vs output tokens
What is CCE? (Complete Guide)Setup, tools, how it works, FAQ
How to Save Claude Code TokensCost breakdown and savings guide
Benchmark Deep DiveFull FastAPI benchmark methodology
Comparison with AlternativesCCE vs Cursor, Aider, Continue, Greptile
ExamplesReal conversations with Claude
How It WorksFull 9-stage pipeline
CLI ReferenceEvery command with output
ConfigurationAll config options

FAQ

Does CCE affect response quality?

No. Quality stays the same or slightly improves.

CCE replaces "dump the entire file" with "search for the relevant function." The model still gets the code it needs (0.90 Recall@10 in benchmarks). Less irrelevant context means less noise competing for attention, which can improve the model's focus on your actual question.

How does output token savings work?

CCE writes output compression rules directly into your agent's instruction files (CLAUDE.md, AGENTS.md, .cursorrules, etc.) during cce init. These rules apply to the entire session, not just CCE tool responses, so every reply from the agent follows them.

Set the level in ~/.cce/config.yaml or .context-engine.yaml:

yaml
compression:
  output: max       # off | lite | standard | max

Then re-run cce init to update instruction files. Or change at runtime:

set_output_level output_level=max
LevelSavingsWhat it does
off0%No compression
lite~25%Removes filler/hedging/pleasantries + diff-only for code changes
standard~70%Drops articles, fragments, short synonyms + diff-only for code
max~80%Telegraphic style + diff-only for code

Default is standard. All levels include code output rules that tell the model to show only changed lines (not full file rewrites), which is where most output tokens go in coding sessions. The max level produces very terse prose (similar to "caveman mode"). Code blocks, paths, and commands are never compressed regardless of level.

Where do the savings come from?

Most savings are input tokens (what goes into the model):

LayerTypeTypical savings
RetrievalInput94% (full files → relevant chunks)
Chunk compressionInput89% (chunks → signatures)
Grammar compressionInput13% (article/filler removal)
Turn summarizationInputvaries (session history)
Progressive disclosureInputvaries (tool payloads)
Output compressionOutput25-80% (depends on level)

Output tokens cost 5x more per token (e.g. Opus: $15/1M input vs $75/1M output), so even a small output reduction has outsized cost impact.


Roadmap

  • Multi-repo benchmarks (FastAPI, chi, fiber)
  • More benchmarks (Django, Express)
  • Tree-sitter support for C, C++, Ruby, Swift, Kotlin
  • Docker support for remote mode
  • Port to mcp 2.x API

See CHANGELOG.md for shipped features.


Contributing

Contributions welcome. See https://github.com/elara-labs/code-context-engine/blob/main/CONTRIBUTING.md for setup.


License

MIT. See LICENSE.

Authors

Acknowledgments

Claude Code · MCP · sqlite-vec · Tree-sitter · fastembed · Ollama


code context engineのMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度code context engineに接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」、「詳細設定」、「MCP」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「MCP」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

code context engineをサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. code context engineのMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタが引き続き使用可能か確認するには、更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "code-context-engine": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いてcode context engineのMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. code context engineのMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
code context engineを使ってこのタスクを手伝ってもらえますか?
code context engine
はい、読みました。
code context engineで調べた結果をお伝えします。

よくある質問

code context engine MCPサーバーは何に使いますか?

code context engineは、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindでcode context engine MCPを複数のAIモデルと併用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルでcode context engineを利用できます。

TypingMindでcode context engine MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けの優れたフロントエンドです。code context engineを接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

code context engine MCPをTypingMindに接続するにはどうすればよいですか?

code context engineはTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindでcode context engine MCPのどのようなツールを利用できますか?

code context engineはMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

code context engine MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。code context engineで認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇