OpenGrok

by icyhot09

Not rated
GitHub

Description

OpenGrok MCP Server is a native Model Context Protocol (MCP) VS Code extension that seamlessly bridges the gap between your organization's OpenGrok indices and GitHub Copilot Chat. It arms your AI assistant with the deep, instantaneous repository context required to traverse…

About

OpenGrok MCP Server is a native Model Context Protocol (MCP) VS Code extension that seamlessly bridges the gap between your organization's OpenGrok indices and GitHub Copilot Chat. It arms your AI assistant with the deep, instantaneous repository context required to traverse, understand, and search massive codebases…

Details

Author
icyhot09
Categories
Developer Tools, Search, Knowledge Base

Setup

Install OpenGrok in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/icyhot09/opengrok-mcp-server

Follow the installation instructions in the repository README, then restart your MCP client.

MCP server bridging OpenGrok search engine with AI for instant context across massive codebases

- Overview
-
How to Install
-
Configuration Guide
-
Prompting Examples
-
Tool Reference
-
VS Code Integration
-
System Architecture
-
Building & Testing
-
Troubleshooting & Support
-
License Information

💡Self-Contained Architecture:The VS Code extension includes the MCP server pre-packaged. You don't need Python, external Node.js installations, or complex environment setups. Just install and go.

Option 1 — VS Code Extension (Recommended)

InstallOpenGrok MCPfrom the VS Code Marketplace, or search "OpenGrok" in the Extensions panel.

The extension provides a visual configuration UI and manages the MCP server process automatically.

npm install -g opengrok-mcp-server opengrok-mcp setup # interactive wizard: URL, credentials, MCP client registration

The wizard stores credentials securely in the OS keychain (macOS Keychain, Windows Credential Manager, Linux libsecret) with an encrypted file fallback for headless Linux.

- After installation, theSettings panelwill launch.
- Input your OpenGrok endpoint, username, and password. HitSave Settings.(Credentials are locked in your native OS keychain).
- The plugin verifies the connection instantly. On your first run, VS Code will ask you toReload the Windowto register the MCP tools.
- (Need to change this later? Use theOpenGrok: Manage Configurationcommand or click the gear icon in the status bar).

- Launch theGitHub Copilot Chatwindow. Ensure you're usingAgentmode.
- Click the paperclip/tools icon (🔧) in the prompt box.
- (If anUpdate Toolsbutton appears, click it).
- LocateOpenGrokin the list, check the box, and confirm.

⚠️ Note that VS Code manages tool authorizationsper workspace. If you open a different repository, you may need to re-check the OpenGrok box in Copilot.

setupsupportsClaude Code CLI,GitHub Copilot CLI, andCodex CLI. VS Code is configured automatically by the extension — no CLI step needed. Credentials are stored in the OS keychain with an AES-256-GCM encrypted file fallback for headless/CI environments.

While tailored for VS Code, the integrated server logic runs perfectly with other agents natively supporting the MCP protocol, including:

Claude Desktop|Cursor IDE|Windsurf|Claude Code|Google Antigravity

👉 Refer toMCP_CLIENTS.mdfor configuration snippets and advanced daemon setups.

Talk to GitHub Copilot Chat naturally about your codebase:

Find the implementation of the render_pipeline function within the graphics engine project. Retrieve the contents of /src/utils/math.cpp from line 450 to 520. What is the definition of TextureManager? Please show me the header file declaration too. Look for all places in the code where ThreadPool is instantiated or referenced.

💡 These specialized tools merge multiple network requests into a single operation, reducing API chatter and cutting token usage byup to 90%.

(Note: The search functions support language filtering. Passfile_typeasjava,cxx,python,golang, etc.)

🔍 Investigation & Analysis Tools (v5.6+)

🧬 Code Mode (v5+) — For Large Multi-Language Codebases

SetOPENGROK_CODE_MODE=trueto switch to a 5-tool interface optimised for multi-step investigations:

Allenv.opengrok.*calls appearsynchronousinside your code — the sandbox bridges async HTTP calls transparently using a SharedArrayBuffer + Atomics channel. Token savings of 80–95% are typical for complex investigations.

v9.0+ sandbox methods for interactive prompts and AI assistance:

Whenenv.opengrok.search()returnszero resultsand sampling is available,_suggestions: string[]is automatically injected into the result — check it before callingsample()explicitly.

// Example opengrok_execute code const refs = env.opengrok.search("handleCrash", { searchType: "refs", maxResults: 5 }); const first = refs.results[0]; const content = env.opengrok.getFileContent(first.project, first.path, { startLine: first.matches[0].lineNumber - 5, endLine: first.matches[0].lineNumber + 10, }); return { callerFile: first.path, code: content.content };

The sandbox exposes aLiving Document Memory Bank— two persistent markdown files that survive across turns:

Access viaenv.opengrok.readMemory(filename)/env.opengrok.writeMemory(filename, content)inside the sandbox, or via theopengrok_read_memory/opengrok_update_memory/opengrok_memory_statustools in classic mode. Delta encoding returns[unchanged]on repeated reads; richness-scored trimming keeps the most valuable log entries when space is tight.

Project Picker & Interactive Disambiguation (Elicitation)

WhenOPENGROK_ENABLE_ELICITATION=true, the server uses MCP Elicitation in two places:
- Session startopengrok_api(Code Mode) prompts the user to select a working project if noOPENGROK_DEFAULT_PROJECTis configured and more than one project exists.
- Mid-execution— Sandbox JS can callenv.opengrok.elicit(message, schema)to ask the user to choose between multiple matching files, revisions, or projects at any point during execution.

Requires a client that supports MCP Elicitation:

Enable in the VS Code configuration panel, or setOPENGROK_ENABLE_ELICITATION=truein your MCP client environment config. The server degrades gracefully to{ action: "cancel" }on unsupported clients — no errors.

The server delegates LLM calls back to the client via MCP Sampling — using the client's model subscription without needing separate API keys. Used in three places:
- Sandbox error explanation— Whenopengrok_executecode fails, sampling generates a concise explanation and fix suggestion.
- Dependency graph summarization— Largeopengrok_dependency_mapgraphs (>10 nodes) are summarized via sampling in legacy mode.
- Zero-result query reformulation(v9.0+, Code Mode) — Whenenv.opengrok.search()returns 0 results, sampling auto-injects_suggestionsinto the result object. Sandbox JS can also callenv.opengrok.sample(prompt)explicitly for any AI-generated text.

- VS Code Copilot
- Claude Code— support pending (tracked inanthropics/claude-code#1785)

The server degrades gracefully when sampling is unavailable —sample()returnsnull,_suggestionsis not injected.

For the standalone server (npx opengrok-mcp-serveror Claude Code), set these environment variables:

VS Code users can setopengrok-mcp.codeMode,opengrok-mcp.contextBudget,opengrok-mcp.memoryBankDir,opengrok-mcp.defaultProject,opengrok-mcp.responseFormatOverride,opengrok-mcp.compileDbPaths,opengrok-mcp.enableObservationMasker, andopengrok-mcp.observationMaskerTurnsin VS Code settings instead.

MCP SDK Note:This version uses@modelcontextprotocol/sdkv1.29.0. MCP SDK v2 is in pre-alpha; we will migrate when stable (expected Q3-Q4 2026). v2 will enable enhanced completions for tool parameters and resource templates.

By default the server communicates overstdio(standard MCP). For team deployments, you can also expose aStreamable HTTP endpoint:

OPENGROK_HTTP_PORT=3666 npm run serve # or add to your MCP client config: # "OPENGROK_HTTP_PORT": "3666"

- Each HTTP client receives an isolatedMcpServerinstance (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

In resource server mode, this server validates JWTs issued by your own IdP — there is no built-in/tokenendpoint. RFC 9728 protected resource metadata is served at/.well-known/oauth-protected-resource.

Fail-safe: unknown or missing tokens default toreadonly, notadmin.

v7.0 includes a comprehensive security audit with the following hardening:

- OPENGROK_HTTP_CLIENT_IDandOPENGROK_HTTP_CLIENT_SECRETremoved. Migrate toOPENGROK_JWKS_URI+OPENGROK_RESOURCE_URIfor OAuth 2.1 (resource server model — bring your own IdP).
- Memory bankmigrate()removed — the legacy 6-file layout is no longer supported. The 2-file layout (active-task.md+investigation-log.md) has been the default since v5.4.
- CORS is now allowlist-only whenOPENGROK_ALLOWED_ORIGINSis set; unauthenticated wildcard CORS is disabled.

[ AI Client ] [ Integration Layer ] [ Data Source ] │ │ +---------------+ │ +-------------------+ │ +----------------------+ │ GitHub │<──(stdio)──┼──────>│ OpenGrok MCP │<────┼─────>│ OpenGrok REST API & │ │ Copilot Chat │ │ │ Server (Node.js) │HTTP │ │ Web Interface │ +---------------+ │ +-------------------+ │ +----------------------+ │ ▲ │ │ │ │ (Configures & Hosts) │ (Context Optimization) ▼ │ │ │ +---------------+ │ o Context Fetch │ +----------------------+ │ VS Code │ │ o Multi-Search │ │ Local File System │ │ Extension │ │ o Auto-Truncate │<─────┤ (compile_commands) │ +---------------+ │ │ +----------------------+

The underlying code is completely packaged in the marketplace extension viaesbuild. The server uses standard VS Code Node APIs without external VM requirements.

# Initializing npm install # Code Quality & Tests npm run lint # Strict TypeScript & ESLint validation npm test # Execute the Vitest test suite (1113 tests) npm run test:sandbox # Sandbox integration tests (requires compile first) npm run test:coverage # Coverage report (≥89% threshold) # Packaging npm run compile # Generate the esbuild artifact (includes sandbox-worker.js) npm run vsix # Create the downloadable extension file

We leverage GitHub Actions for automated CD. Tagging a commit (e.g.,v1.2.3) automatically triggers the build matrix and attaches artifacts to a newGitHub Release.

For deep-dives into the architecture or PR guidelines, please readCONTRIBUTING.md.

The MCP tools are missing in Copilot Chat

- Click the paperclip (🔧) icon to "Update Tools"
- RunDeveloper: Reload Window

- Double-check yourOPENGROK_BASE_URL
- Make sure you aren't blocked by corporate VPNs/proxies

401 Unauthorized / Authentication failing

- Run theOpenGrok: Configure Credentialscommand to save your username/password again

- Turn off strict validation by settingopengrok-mcp.verifySsltofalse

- Limit the scope using thefile_typeargument or targeting a specific project
- OpenGrok might be indexing; runopengrok_index_health

- Set the environment variableOPENGROK_LOG_LEVEL=debugto get extensive stdout trace data

This system is distributed under thePolyForm 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 torudroy09@gmail.comfor enterprise tier pricing.

ReadLICENSE-COMMERCIAL.mdfor full terms.

This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.

Semantic code search for AI agents without indexing your codebase or storing any data. Fast and accurate.

Create and read feature flags, review experiments, generate flag types, search docs, and interact with GrowthBook's feature flagging and experimentation platform.

Word search, crossword, and sudoku generator MCP server with printable PDF worksheets, themed word banks, and verifiable LLM evals. Local-first, from the makers of puzzletide.com.

Official MCP server for Stimulsoft Reports & Dashboards documentation. Semantic search across FAQ, Programming Manual, Server/User Manual, and Server/Cloud API for .NET, WPF, Avalonia, WEB, Blazor, Angular, React, JS, PHP, Java, and Python platforms.

Searching and access your AI coding sessions from Claude Code, Gemini CLI, opencode, and OpenAI Codex.

Search Apple's Developer Documentation with smart search and wildcard support.

MCP server that exposes ast-grep (sg) as two tools for structural code search.

Search everything your terminal ever printed. Local MCP server over per-command recorded output: full-text search, exit codes, diffs, secret redaction. Built and maintained by an AI agent (Soren Achebe).

Let AI agents search, register, and manage domains via API

Search, compare, and get docs for 210+ APIs ranked by CLI and agent relevance

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.