Precise code context for AI coding agents.
Find related code across files. Follow its connections. Give your agent the evidence it needs.
Quick start · Benchmarks · MCP setup · English | 简体中文
OpenContextEngine is a self-hostable code context engine for AI coding agents. Connect it to your agent through MCP to help it explore an unfamiliar codebase, locate implementations, and find the related code needed for a fix or feature.
It indexes your working directory and follows saved changes. Given a natural-language task, it combines semantic and keyword search, code relationships, and reranking to return relevant source snippets with file paths and line numbers, within a fixed context budget.
- Search beyond exact words. Describe a behavior; retrieve its implementation and connected code across files.
- Understand code structure. Python, TypeScript, JavaScript, and Go adapters, plus text fallback for other languages, configuration, and scripts.
- Stay current as you edit. Saved changes, file deletions, and branch switches sync automatically. Unchanged embeddings are reused; incomplete updates never replace a complete index.
- Work across projects through MCP. Your agent supplies the project path; indexes start on demand and are reused.
search_coderetrieves evidence;index_statusreports synchronization.
94.79% required evidence coverage · 1.73 s median retrieval · 69/80 queries with complete evidence. Seven engines, four repositories, the same 4,000-token output budget. OpenContextEngine retained the most required evidence in this internal development evaluation.
Measured with the optional batch rerank API. 40 source-derived tasks, each asked in Chinese and English. Coverage measures source evidence, not coding-agent success. Timings reflect native retrieval for open tools and SDK client calls for ACE. Full comparison, configurations, and per-query results →
Requires macOS, Linux, or Windows, Node.js 22.14+, Python 3.10+, Git, and configured embedding/reranking services. Go repositories also need Go 1.22+.
Native Windows support is available in version 0.1.3 and later. Run the installation commands in PowerShell.
Install from npm, then expand your client's guide. Model settings are shared across clients on the same machine.
Codex — install, connect, and search
1. Install the CLI
With Codex CLI already installed, run:
npm install -g open-context-engine2. Configure your models
open-context-engine setupEnter your embedding and reranking base URLs, API keys, model names, and embedding dimensions. Setup installs isolated Python dependencies and saves your settings. The default reranker uses the ordinary /rerank API. Endpoint examples →
3. Add the MCP server
codex mcp add open-context-engine -- open-context-engine mcp
codex mcp get open-context-engineThe second command checks the saved configuration. These commands assume open-context-engine is on the client's PATH. For the desktop app or source installations, use the absolute-path configuration. Restart an already-running Codex client after adding the server.
4. Search your project
cd /path/to/your-project
codexAsk:
Use open-context-engine's search_code tool to explain this project's main functionality. Include the entry points and relevant file paths and line numbers.
Codex supplies the project's absolute path as directory_path. The first request starts indexing; if it is still building, ask Codex to check index_status and retry when ready. Later searches reuse the index, and saved changes update automatically.
Claude Code — install, connect, and search
1. Install the CLI
With Claude Code already installed, run:
npm install -g open-context-engine2. Configure your models
open-context-engine setupEnter your embedding and reranking base URLs, API keys, model names, and embedding dimensions. Setup installs isolated Python dependencies and saves your settings. If you already completed setup for Codex, reuse those settings and skip this step. Endpoint examples →
3. Add the MCP server
claude mcp add --transport stdio --scope user open-context-engine -- open-context-engine mcpUser scope makes the server available across your projects. For a shared project configuration, run the command from that project and replace --scope user with --scope project. These commands assume open-context-engine is on the client's PATH; see client setup notes for absolute paths. Restart an already-running Claude Code session after adding the server.
4. Search your project
cd /path/to/your-project
claudeRun /mcp to check the connection, then ask:
Use open-context-engine's search_code tool to explain this project's main functionality. Include the entry points and relevant file paths and line numbers.
Claude supplies the project's absolute path as directory_path. The first request starts indexing; if it is still building, ask Claude to check index_status and retry when ready. Later searches reuse the index, and saved changes update automatically.
Other MCP clients
Install and run setup, then use the configuration printed by open-context-engine mcp-config in your client's supported format. For clients that accept mcpServers JSON and can find the installed command on PATH:
{
"mcpServers": {
"open-context-engine": {
"command": "open-context-engine",
"args": ["mcp"]
}
}
}Your agent supplies the current project's absolute path as directory_path. To pin one project, add "--root", "/absolute/path/to/your-repository" to args.
Model configuration, troubleshooting, and update behavior →
Benchmark report · Raw evaluations · Retrieval engine
MIT © 2026 AnnaSuSu.
Thanks to the LINUX DO community.