
OpenGrok MCP Server
io.github.IcyHot09由 GitHub 帳號 IcyHot09 發布v9.6.0更新於 Oct 24, 2026
MCP server bridging OpenGrok search engine with AI for instant context across massive codebases.
發布方自己的服務:Surface
概覽
把 OpenGrok 程式碼索引接上 AI 助理,讓它能在大型程式碼庫中搜尋、讀取、追溯作者與符號關係。
- 可以做什麼
- 搜尋程式碼與檔案:全文、定義、引用、路徑與歷史搜尋,正規表示式比對、檔案查找與查詢建議
- 讀取與瀏覽原始碼:依行範圍讀取檔案內容、瀏覽目錄、擷取符號、逐行 blame 以及版本間差異
- 調查歷史與結構:提交歷史、依提交分組的近期變更、include/import 相依圖、呼叫圖與 C/C++ 編譯資訊
- 複合操作:符號上下文、搜尋並讀取、批次搜尋與索引健康檢查
- 透過雙工具 Code Mode 在沙箱中執行 JavaScript,並可選用記憶工具跨工作階段保存調查筆記
- 適用情境
- 適合助理在已有 OpenGrok 索引的大型程式碼庫中工作,需要真實的定義、呼叫端、blame 與歷史,而不是猜測檔案路徑或函式簽章。主要用於程式碼調查與重構前的分析。
- 執行需求
- 透過 npx 或 VS Code 擴充功能在本機執行,CLI 方式需要 Node.js。需要 OPENGROK_BASE_URL 指向 OpenGrok 伺服器(完整 REST API 需 v1.13+,v1.7+ 為相容模式)並能連線該伺服器。選用認證為 OPENGROK_USERNAME 與 OPENGROK_PASSWORD 或 OPENGROK_PASSWORD_FILE;可用 HTTP_PROXY 設定代理。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 OpenGrok MCP Server,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
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
Or run without installing:
Other CLI 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
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
Compound Tools
These merge multiple API calls into a single operation.
Investigation Tools
(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
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, getFileDiff) support pagination. Pass the cursor back as opts.cursor on the next call to fetch the next page. If a cursor has expired (session restarted or too much time elapsed), the response contains { _cursorExpired: true } — restart pagination from the beginning.
Read & Navigate
History & Blame
Code Intelligence
traceCallChain callers come from refs search; callees come from tree-sitter AST analysis for supported languages (C/C++, Java, Go, Python, JS/TS, Rust, and more). Both long-running methods fan out over a background client — a rate-limit-free sibling connection with a short per-operation budget — so deep traversals don't consume the foreground rate-limit quota.
System
Example
When search() returns zero results and sampling is enabled, _suggestions: string[] is automatically injected into the result — check it before calling sample() explicitly.
Tree-sitter intelligence — range reads and expandFunction expand matches to enclosing function bodies using tree-sitter AST analysis (WASM grammars, no host toolchain needed). Per-tier line budgets apply: minimal 200 lines, standard 400 lines, generous 600 lines. Override the grammar directory with OPENGROK_GRAMMAR_DIR; contribute new grammars via npm run copy-grammars (see CONTRIBUTING.md).
fitToBuffer truncation — sandbox results that exceed the 8 MB bridge buffer are trimmed by fitToBuffer(), which keeps complete result elements rather than truncating mid-JSON. Trimmed results carry _truncated: true — narrow the query or page with cursor when you see it.
Elicitation (OPENGROK_ENABLE_ELICITATION=false to disable, default: true)
When enabled, opengrok_api prompts the user to select a working project at session start if no OPENGROK_DEFAULT_PROJECT is configured and more than one project exists. Sandbox code can also call env.opengrok.elicit() to ask the user to choose between multiple matches during execution. Requires a client that supports MCP Elicitation — Claude Code v2.1.76+ supports this. Degrades gracefully to { action: "cancel" } on other clients.
Sampling (OPENGROK_ENABLE_SAMPLING=true, default: false)
Delegates LLM calls back to the client via MCP Sampling, using the client's model subscription without separate API keys. Triggers automatically in three places: sandbox error explanation, large dependency graph summarization (>10 nodes), and zero-result query reformulation (_suggestions injection). VS Code Copilot supports sampling; other clients vary. The server degrades gracefully when sampling is unavailable.
[!WARNING] Sampling triggers are automatic — not on-demand. A single investigation session can generate many sampling calls across sandbox errors, zero-result searches, and large dependency graphs. Some clients consume premium requests per call after the first confirmation prompt. Enable with this in mind.
Memory Bank
Code Mode includes 2 tools by default (api + execute; 5 with OPENGROK_ENABLE_MEMORY_TOOLS=true). Two files persist across turns and session restarts:
Delta encoding returns [unchanged] on repeated reads of unmodified content. Richness-scored trimming keeps the highest-value log entries when space is tight.
Configuration
Core
Code Mode & Performance
Memory Bank
Rate Limiting
Response Cache
MCP Protocol
OpenGrok API
Security & Audit
Logging
Proxy
VS Code users can set opengrok-mcp.baseUrl, opengrok-mcp.codeMode, opengrok-mcp.contextBudget, opengrok-mcp.memoryBankDir, opengrok-mcp.defaultProject, opengrok-mcp.responseFormatOverride, opengrok-mcp.compileDbPaths, opengrok-mcp.enableObservationMasker, and opengrok-mcp.observationMaskerTurns in VS Code settings instead. Secret values such as the password are never written to VS Code settings.
MCP SDK Note: This version uses
@modelcontextprotocol/sdkv1.30.0 (v1 line).
HTTP Transport & Auth
By default the server communicates over stdio. For shared team deployments, the HTTP transport layer is available as a library API (startHttpTransport() in src/server/transport/http-transport.ts) but is not yet wired into the CLI entry point — OPENGROK_HTTP_PORT is documented below but main.ts does not yet read it to start the HTTP server automatically. Use startHttpTransport() directly in custom deployments.
Session Management
- Each HTTP client receives an isolated
McpServerinstance (per-session factory pattern) - Sessions expire after 30 minutes of inactivity;
OPENGROK_HTTP_MAX_SESSIONScaps concurrent sessions (default: 100) GET /mcp/sessionsreturns JSON with active session count and oldest session age
Authentication
In resource server mode, this server validates JWTs issued by your own IdP — there is no built-in /token endpoint. When OPENGROK_JWT_ISSUER is set, tokens from other issuers are rejected. RFC 9728 protected resource metadata is served at /.well-known/oauth-protected-resource.
RBAC Roles
Unknown or missing tokens are rejected with 403 Forbidden. When no authentication is configured, unauthenticated requests are granted admin (local dev mode).
CORS
Browser-based clients are gated by an origin allowlist (OPENGROK_ALLOWED_ORIGINS, comma-separated). Without auth configured, loopback origins (localhost, 127.0.0.1, [::1]) are allowed for local development; once auth is configured (OPENGROK_HTTP_AUTH_TOKEN or RBAC tokens), loopback is no longer implicit — list every allowed origin explicitly, including local ones.
Security
For the full security architecture (threat model, defense layers, hardening guide), see SECURITY.md.
Sandbox trust recommendation: When configuring OpenGrok MCP in VS Code's MCP settings, you may set sandboxEnabled: true which auto-approves tool calls without confirmation prompts. This is safe because all tool execution occurs inside the QuickJS WASM sandbox with no host access — the LLM cannot execute arbitrary system commands through this server.
VS Code Integration
[!NOTE] VS Code manages tool authorizations per workspace. If you open a different repository, re-check the OpenGrok box in the Copilot tools panel.
The configuration panel and VS Code Settings UI cover the same settings: use the panel for guided setup, secrets, testing, and reload prompts. Use opengrok-mcp.* settings in settings.json for workspace overrides, Settings Sync, and scripted defaults. Code Mode is recommended; disabling it uses legacy standard tools and excludes new Code Mode-only capabilities.
Troubleshooting
[!TIP] Run
opengrok-mcp statusto check connectivity and confirm which MCP clients are configured.
[!WARNING] After reloading VS Code or updating the extension, tools may temporarily disappear from the Copilot tools list. Click the tools icon, select "Update Tools", then run
Developer: Reload Windowto restore them.
Connection failed — Verify OPENGROK_BASE_URL. Check that your VPN or proxy is not blocking the endpoint.
401 Unauthorized — Run OpenGrok: Open Configuration to re-enter credentials.
Self-signed SSL certificate errors — Set opengrok-mcp.verifySsl to false in VS Code settings, or OPENGROK_VERIFY_SSL=false in your MCP client config.
Slow queries or timeouts — Narrow the scope with file_type filtering or target a specific project. Check indexing status with opengrok_index_health.
Verbose logging — Set OPENGROK_LOG_LEVEL=debug.
OpenGrok Compatibility
Going Further
Client Setup · Architecture · Security · Contributing · Changelog
License Information
This system is distributed under the PolyForm Noncommercial License 1.0.0.
- ✅ Permitted: Personal use, hobby projects, academic research, education
- ❌ Prohibited: Any commercial, business, enterprise, or paid utilization
Commercial Licensing: To use this extension in an enterprise context (internal tooling, CI pipelines, business infrastructure), a commercial license is strictly required. Reach out to [email protected] for enterprise tier pricing.
Read LICENSE-COMMERCIAL.md for full terms.
來源:README.md,提交 a97583c
工具
0版本歷史
1- v9.6.0最新Sep 16, 2026
評分
已滿足適用檢查項的 40%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
請在儲存庫或註冊中心條目中宣告授權條款。
其他 Grok 整合

Surface
me.grok.nova-otter-delta-cloud官方發布者
遠端 MCP 伺服器,用來展開短連結,並在助理開啟使用者貼上的網址前給出 fetch 或 skip 的判斷。
Grok Crypto Quant API
dev.fly.grok-backtest-api官方發布者
遠端 MCP 伺服器,提供按次付費的加密量化工具:無倖存者偏差回測、每日市場訊號、策略參數最佳化與代幣詐騙檢查。

Server Track Lab
由 GitHub 帳號 Surface-ops 發布
將伺服器端轉換事件送往廣告平台(Meta 即時、Google 與 LinkedIn 僅預覽),並查看工作區事件統計。

API Meter
由 GitHub 帳號 Surface-ops 發布
API Meter 依客戶、端點與方案統計 API 請求量,讓助理註冊 API、取得接入程式碼並讀取或匯出用量。
three.ws for Grok
由 GitHub 帳號 nirholas 發布
three.ws 遠端伺服器,讓助理依文字或圖片生成、綁定骨架、迭代與檢視 3D 模型和虛擬形象,並賦予其可持續沿用的代理人格。