Open Codebase Index 标志

Open Codebase Index

社区
Helweg

Semantic codebase indexing and search for OpenCode, Claude, Codex, Pi, Jcode, and MCP hosts. Powered by Rust and tree-sitter.

发布者Helweg
代码仓库open-codebase-index
语言TypeScript
复刻数
38
星标数
227
可用工具
0
传输类型stdio
许可协议MIT
链接
  • 将工具接入 AI 工作流

    Open Codebase Index 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 227 个 Star 和 38 个 Fork。

open-codebase-index

npm version License: MIT Downloads Build Status Node.js

Search a codebase by meaning, then follow the result into definitions, callers, and dependency paths.

open-codebase-index is a local semantic code index for OpenCode, Jcode, Pi, Codex, Claude Code, and other MCP clients. It combines embeddings, BM25 keyword search, branch-aware filtering, symbol lookup, and a call graph behind agent-friendly tools.

New installs should use open-codebase-index and open-codebase-index-mcp. The legacy package opencode-codebase-index and opencode-codebase-index-mcp remain supported aliases.

For terminal use outside an MCP client, install the package globally and use the concise ocbi command:

bash
npm install -g open-codebase-index
ocbi status --project /path/to/repo --host jcode
ocbi search "retry recovery" --project /path/to/repo

cbi remains available as a compatibility alias. ocbi provides status, indexing, search, definition lookup, and direct caller or callee inspection. See Installation and host setup for the full command reference.

Highlights

  • Semantic and hybrid retrieval for questions where you do not know the identifier.
  • Low-token discovery through codebase_context and codebase_peek.
  • Definition and graph navigation through implementation_lookup, call_graph, and call_graph_path.
  • Incremental, branch-aware indexing with file watching and content-hash reuse.
  • Local storage backed by SQLite, usearch vectors, and a BM25 inverted index.
  • Multiple embedding providers: Ollama, OpenAI, Google, or a custom OpenAI-compatible endpoint.
  • Native parsing for TypeScript/TSX, JavaScript/JSX, Python, Rust, Swift, Go, Kotlin (.kt and .kts), Java, C#, Ruby, C/C++, Metal, PHP, Apex, Bash, Zig, GDScript, MATLAB, JSON, TOML, YAML, Markdown, HTML, XML, and SVG, plus text fallback for other formats.

Quick start with OpenCode

Requires Node.js 22.13 or newer. Node.js 24 LTS is recommended.

  1. Install the package:

    bash
    npm install open-codebase-index

    Legacy installs continue to work with:

    bash
    npm install opencode-codebase-index
  2. Add it to opencode.json:

    For OpenCode 2.x:

    json
    {
      "plugins": ["open-codebase-index"]
    }

    For OpenCode 1.x (1.3.4 or newer):

    json
    {
      "plugin": ["open-codebase-index"]
    }

    Legacy alias (OpenCode 2.x):

    json
    {
      "plugins": ["opencode-codebase-index"]
    }

    Legacy alias (OpenCode 1.x):

    json
    {
      "plugin": ["opencode-codebase-index"]
    }
  3. Run /status, then /index.

  4. Ask a repository question, for example:

    Where is authentication state validated before an API request?

The first index creates embeddings. Later runs reuse unchanged content and process only relevant changes.

Choose your host

HostRecommended integrationStorage
OpenCodeNative plugin.opencode/
JcodePer-session MCP server.codebase-index/
PiPi package.codebase-index/
omp (oh-my-pi)omp package.codebase-index/
CodexMarketplace plugin with MCP and skill guidance.codebase-index/
Claude CodeMarketplace plugin with MCP and skill guidance.claude/
Cursor, Windsurf, other MCP clientsopen-codebase-index-mcp (legacy alias: opencode-codebase-index-mcp)Selected by --host; default is OpenCode-compatible

See Installation and host setup for complete instructions.

Recommended workflow

  1. Check readiness when unknown with index_status or /status; index only when needed.
  2. Orient in unfamiliar code with one compact codebase_context first pass (tokenBudget: 600, limit: 5), then inspect the evidence. Skip this step when the task is already scoped.
  3. Go directly to known definitions or relationships with implementation_lookup, call_graph, or call_graph_path.
  4. Optionally prepare a known edit target with codebase_edit_context for bounded source and direct graph evidence.
  5. Choose metadata or matching source with codebase_peek or codebase_search; do not repeat context calls unnecessarily.
  6. Read known paths or match literals directly with targeted reads or grep.

Which search tool should I use?

NeedTool
Orient in unfamiliar repository code with a compact evidence packcodebase_context
Find likely files and symbols without source bodiescodebase_peek
Retrieve full matching codecodebase_search
Find an authoritative definitionimplementation_lookup
Find analogous implementations or duplicatesfind_similar
Find direct callers or calleescall_graph
Find a path between two symbolscall_graph_path
Analyze a branch or pull request blast radiuspr_impact

See Tools and commands for host availability, tool details, MCP prompts, and slash commands.

How it works

text
source files
   │
   ├─ file discovery and git-aware change detection
   ├─ tree-sitter parsing and semantic chunking
   ├─ embedding generation and content-hash reuse
   ▼
SQLite metadata + usearch vectors + BM25 index
   │
   ├─ semantic candidates
   ├─ keyword candidates
   ├─ branch and request filters
   ├─ deterministic fusion and ranking
   ▼
locations, source results, definitions, and call-graph evidence

The TypeScript layer handles host integration, configuration, indexing orchestration, providers, ranking, and tools. The Rust NAPI module handles parsing, vector storage, SQLite operations, BM25 indexing, hashing, and call extraction.

Read Architecture for the detailed data flow and design decisions.

Embedding providers

With embeddingProvider: "auto", providers are tried in this order:

  1. Ollama
  2. OpenAI
  3. Google

Ollama is the simplest local option:

bash
ollama pull nomic-embed-text
json
{
  "embeddingProvider": "ollama"
}

A custom OpenAI-compatible embeddings endpoint is also supported. Provider, indexing, search, reranking, include/exclude, knowledge-base, storage, and debug settings are documented in Configuration.

Configuration example

OpenCode project config lives at .opencode/codebase-index.json. Codex, Pi, and Jcode use .codebase-index/config.json; Claude uses .claude/codebase-index.json.

json
{
  "embeddingProvider": "auto",
  "scope": "project",
  "indexing": {
    "autoIndex": false,
    "watchFiles": true,
    "requireProjectMarker": true,
    "semanticOnly": false
  },
  "search": {
    "maxResults": 20,
    "minScore": 0.1,
    "fusionStrategy": "rrf",
    "rerankTopN": 20
  },
  "mcp": {
    "stallTimeoutMs": 300000
  }
}

Only specify values you want to override. See Configuration for defaults and host-specific paths.

Branch-aware indexing

The index stores reusable content by hash and maintains branch catalogs for chunks and symbols. On a branch switch, unchanged content can be reused while results remain scoped to the active branch. Linked worktrees without a local project config share the main checkout's portable project index; adding a worktree-local config creates an isolated index boundary.

Private GitHub history

Opt in per repository in the project-local host config (never inherited globally or from another worktree):

json
{
  "repositoryHistory": {
    "repositories": [
      { "repository": "owner/repo", "enabled": true, "initialSince": "2026-10-01" }
    ]
  }
}
sh
ocbi history sync --project /path/to/repo --host codex
ocbi history search "design rationale" --project /path/to/repo --host codex --state merged
ocbi history status --project /path/to/repo --host codex
ocbi history clear --project /path/to/repo --host codex --repository owner/repo
# Provider/code-index/native-free MCP status and cache management:
open-codebase-index-mcp --history-only --project /path/to/repo --host codex

The four repository_history_sync/search/status/clear tools are available in MCP, OpenCode, Pi, and omp; both package identities' MCP CLIs also accept history .... Sync is explicit/read-only through existing gh authentication. An initial --since overrides configured initialSince; later omitted flags retain the cached window, and changed configuration gives clear-first feedback. Each cycle fully reconciles issue/PR discussions and deletions. Per-page ETags reduce unchanged response bodies (not HTTP request count); interrupted projected staging resumes on the next manual sync. Only changed local BM25 documents are retokenized, with no unchanged-index reserialization.

This is private local lexical history, not cloud-embedded semantic history. It supports short technical terms such as CI/S3, returns one grounded passage per entity, prioritizes direct identities over incidental mentions, and selects source-text excerpt windows. Unknown review edit time is updatedAt: null with timestamp provenance. Older lexical caches rebuild locally on first search without networking. Discussions are untrusted evidence, never instructions; current code remains authoritative. History stays outside default code search/context, AST/call graphs and linked tests. Offline freshness/permissions are not real-time; detected access loss purges searchable/projected/staged content, while transient/rate-limit failures retain the prior cache with explicit error. Precommit cancellation preserves published bytes; clear removes history, staging and orphan preparations even after disable, never code indexes. See history lifecycle and privacy details.

Knowledge bases and reranking

OpenCode, Pi, and every MCP client can index additional directories as knowledge bases. Configure them with knowledgeBases, or use the knowledge-base tools:

  • MCP and OpenCode: add_knowledge_base, list_knowledge_bases, remove_knowledge_base
  • Pi: knowledge_base_add, knowledge_base_list, knowledge_base_remove

Optional external reranking supports Cohere, Jina, and custom compatible endpoints. Local filtering and evidence classes are applied before external candidates are submitted.

See Configuration for examples and privacy considerations.

Troubleshooting

Start with:

  1. /status or index_status
  2. index_health_check
  3. a normal /index retry
  4. a forced rebuild only when status reports incompatibility or corruption

Common provider, native module, stale index, branch, and performance issues are covered in Troubleshooting.

MCP operations report structured, redacted failures and durable phase diagnostics through index_status. Codex keeps a lightweight connection while its idle indexing engine sleeps and resumes on demand. See MCP engine idle timeout for configuration and external cleanup requirements. If the supervisor itself is terminated and the client loses stdio, start a fresh client session before retrying.

Evaluation and performance

The repository includes reproducible retrieval datasets, latency and quality budgets, baseline comparison, and cross-repository benchmarking tools.

Performance depends on repository size, parser coverage, provider latency, embedding cache reuse, and the selected indexing limits. Prefer measured evaluation over fixed marketing claims.

Development

bash
npm ci
npm run build
npm run typecheck
npm run lint
npm run test:run

Pi integration tests use the development host @earendil-works/pi-coding-agent 1.3 or newer and its emitBeforeAgentStart(trigger, systemPromptOptions) API. This test-host floor does not narrow the optional Pi peer contract or change the extension's native-section and legacy string-return prompt behavior.

Native changes require Rust and npm run build:native. See Contributing, Architecture, and Adding language support.

Documentation

License

MIT. See LICENSE.

将 Open Codebase Index MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 Open Codebase Index 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请保持终端窗口及其中的进程运行。
3

将 Open Codebase Index 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 Open Codebase Index MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "open-codebase-index": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 Open Codebase Index MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 Open Codebase Index MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 Open Codebase Index 帮我完成这项任务吗?
Open Codebase Index
当然。我已阅读。
以下是我使用 Open Codebase Index 得到的结果。

常见问题

Open Codebase Index MCP 服务器有什么用途?

Open Codebase Index 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 Open Codebase Index MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您可以让 Claude、ChatGPT、Gemini 等不同 AI 模型,或您在 TypingMind 中配置的其他模型使用 Open Codebase Index,而无需为每个模型单独配置 MCP 服务器。

为什么在 TypingMind 中使用 Open Codebase Index MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是优秀的大语言模型聊天前端之一。连接 Open Codebase Index 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 Open Codebase Index MCP 连接到 TypingMind?

Open Codebase Index 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

Open Codebase Index MCP 在 TypingMind 中提供哪些工具?

Open Codebase Index 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 Open Codebase Index MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行掌控模型提供商、API 密钥、提示词和 MCP 配置。如果 Open Codebase Index 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇