OpenGrok MCP Server
概览
作者提供的说明(英文原文)
MCP server bridging OpenGrok search engine with AI for instant context across massive codebases.
PopNx MCP 的三大支柱
这三项永远不会合并成一个分数:意见、测量和人气是不同的东西。
- 用户评价i暂无评价评价功能将在后续阶段与账户功能一起开放
- 我们的基础检查i1 项中通过 1 项依据公开信息检查;尚未扫描代码
- 使用情况i非常新↓ 132/周 · ★ –
它能帮你做什么
我们还没有为它写通俗的介绍。下面是我们从注册中心读取到的事实。
- 连接方式: 在你的电脑上运行
- 传输方式: stdio
- 分类: 搜索与 AI 记忆
- 你需要填写:OPENGROK_BASE_URL, OPENGROK_PASSWORD
安装
选择你使用的 AI 应用,然后复制设置。
安装之前
- 基础检查:1 项中通过 1 项
- 在你的电脑上运行,拥有你的用户账户的权限(文件、网络、应用)。
- 需要你自己填写:
OPENGROK_BASE_URL,OPENGROK_USERNAME,OPENGROK_PASSWORD,OPENGROK_VERIFY_SSL,OPENGROK_CODE_MODE,OPENGROK_ENABLE_MEMORY_TOOLS,OPENGROK_DEFAULT_PROJECT,OPENGROK_CONTEXT_BUDGET,OPENGROK_API_VERSION,HTTP_PROXY,OPENGROK_RESPONSE_FORMAT_OVERRIDE,OPENGROK_MEMORY_BANK_DIR,OPENGROK_LOCAL_COMPILE_DB_PATHS,OPENGROK_ENABLE_ELICITATION,OPENGROK_ENABLE_SAMPLING,OPENGROK_SAMPLING_MODEL,OPENGROK_ENABLE_FILES_API,OPENGROK_ENABLE_OBSERVATION_MASKER,OPENGROK_OBSERVATION_MASKER_TURNS,OPENGROK_SAMPLING_MAX_TOKENS,OPENGROK_AUDIT_LOG_FILE,OPENGROK_RATELIMIT_RPM,OPENGROK_PER_TOOL_RATELIMIT,OPENGROK_TIMEOUT,OPENGROK_DEFAULT_MAX_RESULTS,OPENGROK_PASSWORD_FILE,OPENGROK_MAX_RESPONSE_BYTES,OPENGROK_SEARCH_AND_READ_CAP,OPENGROK_STRICT_SSRF,OPENGROK_JWT_ISSUER,OPENGROK_GRAMMAR_DIR
标为机密的值是你账户的钥匙。千万不要分享给别人,也不要粘贴到聊天里。
你需要
- npm已安装 Node.js(用于 npx 命令)
你用的是哪个应用?
在上方选择你的应用。我们会记住它,下次按钮会显示“安装到 …”。
打开 Claude Desktop → Settings → Developer → Edit Config,把下面的内容粘贴到 claude_desktop_config.json
{
"mcpServers": {
"opengrok": {
"command": "npx",
"args": [
"-y",
"opengrok-mcp-server"
],
"env": {
"OPENGROK_BASE_URL": "your-value",
"OPENGROK_USERNAME": "your-value",
"OPENGROK_PASSWORD": "your-value",
"OPENGROK_VERIFY_SSL": "your-value",
"OPENGROK_CODE_MODE": "your-value",
"OPENGROK_ENABLE_MEMORY_TOOLS": "your-value",
"OPENGROK_DEFAULT_PROJECT": "your-value",
"OPENGROK_CONTEXT_BUDGET": "your-value",
"OPENGROK_API_VERSION": "your-value",
"HTTP_PROXY": "your-value",
"OPENGROK_RESPONSE_FORMAT_OVERRIDE": "your-value",
"OPENGROK_MEMORY_BANK_DIR": "your-value",
"OPENGROK_LOCAL_COMPILE_DB_PATHS": "your-value",
"OPENGROK_ENABLE_ELICITATION": "your-value",
"OPENGROK_ENABLE_SAMPLING": "your-value",
"OPENGROK_SAMPLING_MODEL": "your-value",
"OPENGROK_ENABLE_FILES_API": "your-value",
"OPENGROK_ENABLE_OBSERVATION_MASKER": "your-value",
"OPENGROK_OBSERVATION_MASKER_TURNS": "your-value",
"OPENGROK_SAMPLING_MAX_TOKENS": "your-value",
"OPENGROK_AUDIT_LOG_FILE": "your-value",
"OPENGROK_RATELIMIT_RPM": "your-value",
"OPENGROK_PER_TOOL_RATELIMIT": "your-value",
"OPENGROK_TIMEOUT": "your-value",
"OPENGROK_DEFAULT_MAX_RESULTS": "your-value",
"OPENGROK_PASSWORD_FILE": "your-value",
"OPENGROK_MAX_RESPONSE_BYTES": "your-value",
"OPENGROK_SEARCH_AND_READ_CAP": "your-value",
"OPENGROK_STRICT_SSRF": "your-value",
"OPENGROK_JWT_ISSUER": "your-value",
"OPENGROK_GRAMMAR_DIR": "your-value"
}
}
}
}在终端中运行这条命令
claude mcp add opengrok --env OPENGROK_BASE_URL=your-value --env OPENGROK_USERNAME=your-value --env OPENGROK_PASSWORD=your-value --env OPENGROK_VERIFY_SSL=your-value --env OPENGROK_CODE_MODE=your-value --env OPENGROK_ENABLE_MEMORY_TOOLS=your-value --env OPENGROK_DEFAULT_PROJECT=your-value --env OPENGROK_CONTEXT_BUDGET=your-value --env OPENGROK_API_VERSION=your-value --env HTTP_PROXY=your-value --env OPENGROK_RESPONSE_FORMAT_OVERRIDE=your-value --env OPENGROK_MEMORY_BANK_DIR=your-value --env OPENGROK_LOCAL_COMPILE_DB_PATHS=your-value --env OPENGROK_ENABLE_ELICITATION=your-value --env OPENGROK_ENABLE_SAMPLING=your-value --env OPENGROK_SAMPLING_MODEL=your-value --env OPENGROK_ENABLE_FILES_API=your-value --env OPENGROK_ENABLE_OBSERVATION_MASKER=your-value --env OPENGROK_OBSERVATION_MASKER_TURNS=your-value --env OPENGROK_SAMPLING_MAX_TOKENS=your-value --env OPENGROK_AUDIT_LOG_FILE=your-value --env OPENGROK_RATELIMIT_RPM=your-value --env OPENGROK_PER_TOOL_RATELIMIT=your-value --env OPENGROK_TIMEOUT=your-value --env OPENGROK_DEFAULT_MAX_RESULTS=your-value --env OPENGROK_PASSWORD_FILE=your-value --env OPENGROK_MAX_RESPONSE_BYTES=your-value --env OPENGROK_SEARCH_AND_READ_CAP=your-value --env OPENGROK_STRICT_SSRF=your-value --env OPENGROK_JWT_ISSUER=your-value --env OPENGROK_GRAMMAR_DIR=your-value -- npx -y opengrok-mcp-server运行前请先填写空着的值。
或者自己复制设置
粘贴到项目中的 .cursor/mcp.json,或 ~/.cursor/mcp.json
{
"mcpServers": {
"opengrok": {
"command": "npx",
"args": [
"-y",
"opengrok-mcp-server"
],
"env": {
"OPENGROK_BASE_URL": "your-value",
"OPENGROK_USERNAME": "your-value",
"OPENGROK_PASSWORD": "your-value",
"OPENGROK_VERIFY_SSL": "your-value",
"OPENGROK_CODE_MODE": "your-value",
"OPENGROK_ENABLE_MEMORY_TOOLS": "your-value",
"OPENGROK_DEFAULT_PROJECT": "your-value",
"OPENGROK_CONTEXT_BUDGET": "your-value",
"OPENGROK_API_VERSION": "your-value",
"HTTP_PROXY": "your-value",
"OPENGROK_RESPONSE_FORMAT_OVERRIDE": "your-value",
"OPENGROK_MEMORY_BANK_DIR": "your-value",
"OPENGROK_LOCAL_COMPILE_DB_PATHS": "your-value",
"OPENGROK_ENABLE_ELICITATION": "your-value",
"OPENGROK_ENABLE_SAMPLING": "your-value",
"OPENGROK_SAMPLING_MODEL": "your-value",
"OPENGROK_ENABLE_FILES_API": "your-value",
"OPENGROK_ENABLE_OBSERVATION_MASKER": "your-value",
"OPENGROK_OBSERVATION_MASKER_TURNS": "your-value",
"OPENGROK_SAMPLING_MAX_TOKENS": "your-value",
"OPENGROK_AUDIT_LOG_FILE": "your-value",
"OPENGROK_RATELIMIT_RPM": "your-value",
"OPENGROK_PER_TOOL_RATELIMIT": "your-value",
"OPENGROK_TIMEOUT": "your-value",
"OPENGROK_DEFAULT_MAX_RESULTS": "your-value",
"OPENGROK_PASSWORD_FILE": "your-value",
"OPENGROK_MAX_RESPONSE_BYTES": "your-value",
"OPENGROK_SEARCH_AND_READ_CAP": "your-value",
"OPENGROK_STRICT_SSRF": "your-value",
"OPENGROK_JWT_ISSUER": "your-value",
"OPENGROK_GRAMMAR_DIR": "your-value"
}
}
}
}浏览器会先询问是否打开应用,然后应用会显示设置并请你确认。密钥的值会留空,由你自己填写。
或者自己复制设置
粘贴到项目中的 .vscode/mcp.json
{
"servers": {
"opengrok": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"opengrok-mcp-server"
],
"env": {
"OPENGROK_BASE_URL": "your-value",
"OPENGROK_USERNAME": "your-value",
"OPENGROK_PASSWORD": "your-value",
"OPENGROK_VERIFY_SSL": "your-value",
"OPENGROK_CODE_MODE": "your-value",
"OPENGROK_ENABLE_MEMORY_TOOLS": "your-value",
"OPENGROK_DEFAULT_PROJECT": "your-value",
"OPENGROK_CONTEXT_BUDGET": "your-value",
"OPENGROK_API_VERSION": "your-value",
"HTTP_PROXY": "your-value",
"OPENGROK_RESPONSE_FORMAT_OVERRIDE": "your-value",
"OPENGROK_MEMORY_BANK_DIR": "your-value",
"OPENGROK_LOCAL_COMPILE_DB_PATHS": "your-value",
"OPENGROK_ENABLE_ELICITATION": "your-value",
"OPENGROK_ENABLE_SAMPLING": "your-value",
"OPENGROK_SAMPLING_MODEL": "your-value",
"OPENGROK_ENABLE_FILES_API": "your-value",
"OPENGROK_ENABLE_OBSERVATION_MASKER": "your-value",
"OPENGROK_OBSERVATION_MASKER_TURNS": "your-value",
"OPENGROK_SAMPLING_MAX_TOKENS": "your-value",
"OPENGROK_AUDIT_LOG_FILE": "your-value",
"OPENGROK_RATELIMIT_RPM": "your-value",
"OPENGROK_PER_TOOL_RATELIMIT": "your-value",
"OPENGROK_TIMEOUT": "your-value",
"OPENGROK_DEFAULT_MAX_RESULTS": "your-value",
"OPENGROK_PASSWORD_FILE": "your-value",
"OPENGROK_MAX_RESPONSE_BYTES": "your-value",
"OPENGROK_SEARCH_AND_READ_CAP": "your-value",
"OPENGROK_STRICT_SSRF": "your-value",
"OPENGROK_JWT_ISSUER": "your-value",
"OPENGROK_GRAMMAR_DIR": "your-value"
}
}
}
}浏览器会先询问是否打开应用,然后应用会显示设置并请你确认。密钥的值会留空,由你自己填写。
这个服务器在你的电脑上运行,而 ChatGPT 只能连接互联网上的服务器。请选择其他应用。
你的选择通过 Cookie 保存在这台设备上,无需账户。
需要你填写的值
- OpenGrok server base URL (e.g. https://opengrok.example.com/source/)
OPENGROK_USERNAMEenvOpenGrok authentication username. Leave unset for anonymous access.- OpenGrok authentication password. Prefer storing via OS keychain using 'npx opengrok-mcp-server setup'.
OPENGROK_VERIFY_SSLenvVerify TLS certificates. Set to false for self-signed or internal CA certs.OPENGROK_CODE_MODEenvEnable Code Mode: 2-tool sandbox interface with env.opengrok.* JavaScript API. Reduces AI token usage by ~90%.OPENGROK_ENABLE_MEMORY_TOOLSenvRegister the 3 memory tools in Code Mode (memory status, read, update). Off = api + execute only.OPENGROK_DEFAULT_PROJECTenvDefault project to scope all searches. Can be overridden per call.OPENGROK_CONTEXT_BUDGETenvResponse size tier controlling token usage.OPENGROK_API_VERSIONenvOpenGrok REST API version. Use v2 for call graph features (requires OpenGrok 1.12+).HTTP_PROXYenvHTTP/HTTPS proxy URL for all OpenGrok API requests (e.g. http://proxy.company.com:8080). Also set as HTTPS_PROXY.OPENGROK_RESPONSE_FORMAT_OVERRIDEenvForce a specific response format for all tools. Leave unset for per-tool auto-selection (recommended).OPENGROK_MEMORY_BANK_DIRenvDirectory where the AI stores investigation notes (active-task.md, investigation-log.md). Defaults to ~/.config/opengrok-mcp/memory-bank/ or workspace-relative when set by the VS Code extension.OPENGROK_LOCAL_COMPILE_DB_PATHSenvComma-separated paths to compile_commands.json for C/C++ compiler flag and include-path extraction. Leave unset for automatic workspace discovery.OPENGROK_ENABLE_ELICITATIONenvInteractive AI Prompts — the AI pauses to ask questions during investigations (project selection, file disambiguation). Requires Claude Code v2.1.76+ or a client that supports MCP Elicitation.OPENGROK_ENABLE_SAMPLINGenvAI Sampling — allow the server to request LLM completions for error explanations and summaries. Off by default to avoid consuming premium requests (e.g. GitHub Copilot).OPENGROK_SAMPLING_MODELenvModel preference for MCP Sampling (used for error explanation and query reformulation).OPENGROK_ENABLE_FILES_APIenvFiles API Cache — avoids re-uploading unchanged investigation notes. Requires Files API support in the MCP client.OPENGROK_ENABLE_OBSERVATION_MASKERenvObservation Masker — prepend compact history summaries to opengrok_execute results after N turns. Disabled by default; has no benefit for clients that retain full context (Claude Code, Cursor).OPENGROK_OBSERVATION_MASKER_TURNSenvNumber of most-recent opengrok_execute results to keep as full text before masking older ones. Default: 10.OPENGROK_SAMPLING_MAX_TOKENSenvMaximum tokens for AI sampling responses (error explanation, query reformulation). Range: 64–4096.OPENGROK_AUDIT_LOG_FILEenvPath to write structured audit events (CSV/JSON). Appends tool invocations, elicitation events, and errors. Leave unset to disable.OPENGROK_RATELIMIT_RPMenvMaximum requests per minute to the OpenGrok server. Default: 60.OPENGROK_PER_TOOL_RATELIMITenvPer-tool rate limits in requests per minute, as comma-separated tool:rpm pairs (e.g. opengrok_execute:15,opengrok_search_code:30). Overrides OPENGROK_RATELIMIT_RPM for specific tools.OPENGROK_TIMEOUTenvHTTP request timeout in seconds for OpenGrok API calls. Increase for slow servers. Default: 30.OPENGROK_DEFAULT_MAX_RESULTSenvDefault maximum number of results returned per search query. Default: 25.OPENGROK_PASSWORD_FILEenvPath to a file containing the OpenGrok password (file-mounted secret for containers). Takes precedence over the OS keychain when OPENGROK_PASSWORD is unset.OPENGROK_MAX_RESPONSE_BYTESenvHard cap on response payload size in bytes. Overrides the context-budget default. Non-positive values are ignored.OPENGROK_SEARCH_AND_READ_CAPenvCap for the search_and_read compound tool in bytes. Overrides the context-budget default (2–8 KB depending on tier). Non-positive values are ignored.OPENGROK_STRICT_SSRFenvWhen true, reject OPENGROK_BASE_URL values pointing at private/loopback IPs at startup. Default: false (warn only; per-request guards still apply).OPENGROK_JWT_ISSUERenvExpected JWT issuer (iss claim) for HTTP transport OAuth. When set, JWTs from other issuers are rejected.OPENGROK_GRAMMAR_DIRenvDirectory containing tree-sitter WASM grammars. Overrides the bundled grammar lookup.
这些设置是根据作者在注册中心的条目生成的。如果 README 的写法不同,请以 README 为准。
它能做什么
它在你的电脑上运行;安装后,工具列表会显示在你的 AI 应用中。
基础检查i
我们检查的是任何人都能看到的信息;我们没有阅读代码。不适用的检查项不计入总数。 · 检查于 2026年11月9日
- ✓ 通过
作者与仓库一致
注册名称已通过 GitHub 账户 IcyHot09 验证,该账户拥有此仓库
- … 尚未检查
仍在维护
我们还没有从 GitHub 读取这个仓库
- … 尚未检查
有许可证
我们还没有从 GitHub 读取这个仓库
- – 不适用
端点有响应
它在你的电脑上运行,没有互联网端点
- – 不适用
使用 OAuth 登录
在你的电脑上运行,改用本地设置
- … 尚未检查
工具描述中没有隐藏指令
它在你的电脑上运行;我们只能读取互联网端点的工具列表
与“搜索与 AI 记忆”中的其他服务器比较i
- 星标数多于此分类中其他 5727 个服务器的 0%
- 发布到注册中心的时间比此分类中其他 5727 个服务器的 43% 更新
- 基础检查结果等于或优于此分类中其他 5727 个服务器的 100%
与注册中心里这个分类中所有活跃的服务器比较。只有当发布者拥有该仓库时,星标数才计入。
常见问题
OpenGrok MCP Server 安全吗?
它在 1 项适用的基础检查中通过了 1 项。我们没有阅读代码。在添加密钥或令牌之前,请先看看这个服务器要求哪些权限,并使用只具备所需权限的密钥。
它需要哪些密钥或代码?
你需要填写:OPENGROK_BASE_URL, OPENGROK_PASSWORD
它在我的电脑上运行还是在云端?
它在你的电脑上运行。你的 AI 应用会在需要时启动它,数据不会经过作者的服务器(除非它自己调用在线服务)。
它还在维护吗?
GitHub 仓库最后更新于–,最新版本(9.6.0)于2个月前进入注册中心。
哪些应用可以使用它?
支持 MCP 的应用,例如 Claude Desktop、Claude Code、Cursor 和 VS Code。你的电脑上还需要有 Node.js。
有什么可以替代它?
同一分类中有:Context7, Codebase Memory, Exa
替代选择
同一分类中其他作者的服务器,按星标数排序。
如何看卡片:↓ 每周下载量i★ GitHub 星标i三大支柱:评价 · 检查 · 使用情况i更新 = 最新版本发布到注册中心的时间i
Codebase Memory
Codebase knowledge graph for AI agents — 162 languages, sub-ms queries, 99% fewer tokens.
Exa
Connect AI agents to Exa for web search, content fetching, and multi-step research.
作者的 README
打开 README
按原文从作者的仓库复制。PopNx MCP 没有审查或背书其内容。HTML、图片和脚本已被移除。链接会离开本站。
OpenGrok MCP Server
Code intelligence for any OpenGrok-indexed codebase — search, read, blame, symbol navigation, diffs, commit history, call graphs, dependency maps, and guided investigation. Optimized for token efficiency through Code Mode and AST-aware code reads.
Quick Start
Option 1 — VS Code Extension
Install OpenGrok MCP from the VS Code Marketplace, or search "OpenGrok" in the Extensions panel. The configuration panel opens on first launch — enter your OpenGrok endpoint, username, and password, then click Save Settings and reload when prompted.
The extension provides a visual configuration UI and manages the MCP server process automatically. No Python, external Node.js install, or manual environment setup required.
Option 2 — npm / npx CLI
npm install -g opengrok-mcp-server
opengrok-mcp setup # interactive wizard: URL, credentials, MCP client registration
Or run without installing:
npx opengrok-mcp-server setup
Other CLI commands:
opengrok-mcp status # health check: validates connectivity and detects installed MCP clients
opengrok-mcp setup --test # test the stored connection without the wizard opengrok-mcp setup --set contextBudget=generous # update one stored setting non-interactively opengrok-mcp export-audit --format json --output audit.jsonl # export the audit log opengrok-mcp version # print version and exit opengrok-mcp help # show all commands
Works with any MCP-compatible client (CLI or IDE). See MCP_CLIENTS.md for config format and troubleshooting.
Credentials are stored in the OS keychain (macOS Keychain, Windows Credential Manager, Linux libsecret) with an AES-256-GCM encrypted file fallback for headless environments.
[!TIP]
Automatic Updates — The extension checks GitHub for new releases once per 24 hours and notifies you when one is available. Use OpenGrok: Check for Updates to check on demand.
The Problem
Engineers working in large codebases face a specific gap when using AI coding assistants. The model's context window contains the file currently open, the conversation, and whatever has been manually shared — but a production codebase has structure, history, and cross-module relationships that exist entirely outside that window.
A symbol defined in one module and called from seventy others. A function whose behavior only becomes clear from the three commits that shaped it. An include chain stretching across a dozen directories. A call graph showing which components depend on a service before it gets refactored.
Without access to the code index, the model fills these gaps by guessing: it fabricates file paths, invents function signatures, misattributes changes to authors. The model is not wrong because it is unintelligent — it is wrong because it is isolated.
OpenGrok already solves this for human engineers. It indexes source in dozens of programming languages, maintains a full-text index across committed history, and exposes definition lookups, reference graphs, blame, directory traversal, and file history through a REST API. The problem was that AI tools had no way to reach it.
How It Works
┌──────────────────────────────────────────────────────┐
│ AI Client (Claude, Copilot, Cursor, Codex …) │ └─────────────────────┬────────────────────────────────┘ │ MCP (stdio or HTTP) ┌─────────────────────▼────────────────────────────────┐ │ OpenGrok MCP Server (Node.js) │ │ opengrok_api ──── full API spec, once per session │ │ opengrok_execute ─ run JavaScript in sandbox │ │ │ │ OpenGrok client ── search · symbols · blame · diffs │ └─────────────────────┬────────────────────────────────┘ │ HTTP (REST + web fallback) ┌─────────────────────▼────────────────────────────────┐ │ OpenGrok │ │ search · symbols · call graphs · index health │ └──────────────────────────────────────────────────────┘
The server exposes two primary tools. opengrok_api delivers the full API specification at session start. Every subsequent operation goes through opengrok_execute: the AI writes a JavaScript program using the env.opengrok.* object — search, getFileContent, getFileAnnotate, getFileHistory, browseDir, getFileSymbols — and submits it as a single execution.
Intermediate results stay inside the sandbox; only the final return value crosses back to the context window. A complete investigation — find the symbol, read the definition, check who changed it, trace the callers — is one script, not a sequence of round-trips with results flowing through the context between each. Token savings of 80–95% are typical for complex investigations.
All env.opengrok.* calls appear synchronous inside sandbox code — the QuickJS WASM VM bridges async HTTP calls transparently over a SharedArrayBuffer + Atomics channel (8 MB data region, 62 s per-call timeout, 62 s hard execution cap), while keeping the Node.js event loop free.
Memory bank — two files persist across turns and session restarts: active-task.md (4 KB) for current investigation state and investigation-log.md (32 KB) for append-only findings. Inside the sandbox: env.opengrok.readMemory() / env.opengrok.writeMemory(). See the Memory Bank reference below.
Reference
Tool Reference
31 tools total: 2–5 in Code Mode (opengrok_api + opengrok_execute, plus 3 memory tools when OPENGROK_ENABLE_MEMORY_TOOLS=true) and 26 in standard mode (OPENGROK_CODE_MODE=false).
Primary Tools
| Tool | Purpose |
|---|---|
opengrok_search_code | Full-text, definition, reference, path, and history search. Supports file_type filtering and cursor pagination. |
opengrok_find_file | Locate files by name or directory pattern. Supports cursor pagination. |
opengrok_get_file_content | Read source code. Use start_line / end_line for large files. |
opengrok_get_file_history | Commit history for a file. Supports cursor pagination. |
opengrok_browse_directory | View folder structure and contained files. Supports cursor / limit pagination. |
opengrok_list_projects | List all indexed repositories. |
opengrok_get_file_annotate | Line-by-line blame annotation. Supports revision, start_line/end_line range, includeContent. |
opengrok_get_file_symbols | Extract classes, functions, macros, and structs from a file. Supports cursor pagination. |
opengrok_search_suggest | Query autocomplete recommendations. Supports context passthrough for ranking. |
Compound Tools
These merge multiple API calls into a single operation.
| Tool | What it replaces | Savings |
|---|---|---|
opengrok_get_symbol_context | Search definition + read source + fetch headers + get references | ~92% fewer tokens |
opengrok_search_and_read | Search + read surrounding context (cap: OPENGROK_SEARCH_AND_READ_CAP) | ~92% fewer tokens |
opengrok_batch_search | 2–5 parallel searches, deduplicated results | ~73% fewer tokens |
opengrok_index_health | Latency, connectivity, staleness score | Diagnostic |
Investigation Tools
| Tool | Purpose |
|---|---|
opengrok_what_changed | Recent line changes grouped by commit — author, date, SHA, changed lines with context |
opengrok_dependency_map | BFS traversal of #include/import chains up to depth 3; directed graph with uses/used_by |
opengrok_search_pattern | Regex code search; returns file:line:content matches |
opengrok_blame | Blame with line range (line_start / line_end) and optional diff |
opengrok_call_graph | Call chain tracing via OpenGrok API v2 (requires OPENGROK_API_VERSION=v2; refs-based fallback on v1) |
opengrok_get_file_diff | Unified diff between two revisions with context lines |
opengrok_get_compile_info | C/C++ compiler flags and include paths from local compile_commands.json |
opengrok_get_all_matches | All matching lines in a file when search shows truncated hits |
opengrok_get_file_history_with_files | Commit history with co-changed file lists via RSS feed |
opengrok_get_download_url | Direct download URL for a file (no HTTP call) |
opengrok_list_groups | Project groups (empty when admin auth required) |
opengrok_get_suggest_popularity | Popular suggestions for a project field (empty when admin auth required) |
opengrok_get_project_repositories | Repositories for a project (empty when admin auth required) |
*(Note: search tools support language filtering. Pass file_type using the canonical analyzer name — cxx for C++, golang for Go, sh for shell, javascript for JS. Aliases accepted: cpp/c++→cxx, go→golang, bash/shell→sh, js→javascript, ts→typescript, cs→csharp, py→python, rb→ruby, rs→rust.)*
defs/refs/symbol fallback notes — defs, refs, and symbol searches require a project scope (pass projects or set OPENGROK_DEFAULT_PROJECT); without one they may return too many cross-project hits. On instances where the REST endpoint returns an error or empty results for these types, the client automatically falls back to web-UI parsing so the LLM still gets answers. opengrok_call_graph needs API v2 and degrades to a refs-based view on v1.
Code Mode API
Set OPENGROK_CODE_MODE=true (the default). Call opengrok_api once at session start to receive the full API spec. All subsequent operations go through opengrok_execute.
All sandbox API calls are synchronous — flat globals (search(...)), no await. The env.opengrok.* object form (env.opengrok.search(...)) is equivalent.
Search & Discovery
| Method | Returns |
|---|---|
env.opengrok.search(query, opts?) | Full text, defs, refs, symbol, path, hist. Opts: searchType, projects, maxResults (default 5), startIndex, cursor, fileType, sort, maxHitsPerFile, dir, pathFilter, file, expandFunction |
env.opengrok.batchSearch(queries[], opts?) | One result-set per query (max 10), run in parallel on the host. Per-query expandFunction: true includes enclosing function context |
env.opengrok.findFile(pattern, opts?) | { totalCount, results: [{project, path}], cursor? } |
env.opengrok.searchSuggest(query, opts?) | { query, field, suggestions, time }. Opts: field, project/projects, context (other-field values for ranking) |
env.opengrok.getAllMatchesInFile(project, path, query, opts?) | All matching lines in a file when search results show truncated hits. Also used automatically when search() is given a file: filter (no pagination) |
search() uses canonical file type names only (e.g. cxx, golang, sh) — see the alias list above. Pass expandFunction: true to expand matching results to their enclosing function body (adds host-side reads, up to 3 files per call).
Cursor pagination — Methods that return a cursor field (search, findFile, browseDir, getFileSymbols, getFileHistory, `getFileDif
只显示了开头部分;其余内容请在仓库中阅读