OpenGrok

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 using only natural language.

OpenGrok MCP Server logo

OpenGrok MCP Server

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

VS Code Marketplace Installs npm MCP Registry CI GitHub Release


๐Ÿ“š Table of Contents

Overview

๐Ÿ’ก 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.


How to Install

1. From the VS Code Marketplace (Easiest)

Inside VS Code, open the Extensions view (Ctrl+Shift+X), search for "OpenGrok MCP Server", and hit Install.

2. Global NPM Package

# Run directly without installing permanently
npx opengrok-mcp-server

# Or install it globally on your system
npm install -g opengrok-mcp-server

3. Via the MCP Registry

We are officially listed in the Model Context Protocol Registry under io.github.IcyHot09/opengrok-mcp-server. Clients with registry integration can locate and install it natively.

Option 4 โ€” Install pre-built VSIX

  1. Download the latest VSIX file from GitHub Releases.
  2. Install it in VS Code:
    • Open the terminal in VS Code and run: code --install-extension opengrok-mcp-server-X.Y.Z.vsix
    • OR go to the Extensions tab โ†’ click the ยทยทยท menu โ†’ Install from VSIXโ€ฆ and select the file.
  3. Updates are automatic โ€” the extension checks GitHub Releases once per day and offers one-click install.
๐Ÿ› ๏ธ Option 5 โ€” Build from source (For developers)
git clone https://github.com/IcyHot09/opengrok-mcp-server.git
cd opengrok-mcp-server
npm install
npm run vsix          # Creates opengrok-mcp-server-*.vsix
code --install-extension opengrok-mcp-server-*.vsix

Configuration Guide

  1. Provide Connection Details:

    • After installation, the Settings panel will launch.
    • Input your OpenGrok endpoint, username, and password. Hit Save Settings. (Credentials are locked in your native OS keychain).
    • The plugin verifies the connection instantly. On your first run, VS Code will ask you to Reload the Window to register the MCP tools.
    • (Need to change this later? Use the OpenGrok: Manage Configuration command or click the gear icon in the status bar).
  2. Activate the MCP Source in Copilot:

    • Launch the GitHub Copilot Chat window. Ensure you're using Agent mode.
    • Click the paperclip/tools icon (๐Ÿ”ง) in the prompt box.
    • (If an Update Tools button appears, click it).
    • Locate OpenGrok in the list, check the box, and confirm.

โš ๏ธ Note that VS Code manages tool authorizations per workspace. If you open a different repository, you may need to re-check the OpenGrok box in Copilot.

๐Ÿ”Œ Third-Party Client Support

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 to MCP_CLIENTS.md for configuration snippets, terminal wrapper scripts, and advanced daemon setups.


Prompting Examples

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.

Tool Reference

Primary Operations

Tool NamePurpose
opengrok_search_codeGeneral search utility (full-text, defs, refs, path, history). Supports file_type filtering.
opengrok_find_fileLocate files by name or directory pattern.
opengrok_get_file_contentRead source code (requires start_line and end_line for large files).
opengrok_get_file_historyRetrieve commit history logs.
opengrok_browse_directoryView folder structure and contained files.
opengrok_list_projectsSee all indexed repositories/projects.
opengrok_get_file_annotateSee line-by-line git blame information.
opengrok_get_file_symbolsExtract classes, functions, macros, and structs rapidly from a single file.
opengrok_search_suggestGet query autocomplete recommendations.

๐Ÿš€ Optimized Workflows (Compound Tools)

๐Ÿ’ก These specialized tools merge multiple network requests into a single operation, reducing API chatter and cutting token usage by up to 90%.

Compound ToolFunctionality ReplacedEfficiency Gain
opengrok_get_symbol_context1) searches definition, 2) reads source, 3) fetches headers, 4) gets references~92% fewer tokens
opengrok_search_and_read1) executes search, 2) immediately fetches surrounding code context~92% fewer tokens
opengrok_batch_searchCombines 2-5 individual search queries~73% fewer tokens
opengrok_index_healthChecks latency and backend connectivityDiagnostic utility

(Note: The search functions support language filtering. Pass file_type as java, cxx, python, golang, etc.)

โš™๏ธ Automated Compilation Data (Optional)
Tool NameCapability
opengrok_get_compile_infoReads your local compile_commands.json to extract compiler flags, defines, and include directories for exact C/C++ accuracy.

VS Code Integration

Palette Commands

Command PromptAction Performed
OpenGrok: Manage ConfigurationLaunches the interactive settings GUI
OpenGrok: Configure CredentialsFast CLI-style input for authentication
OpenGrok: Test ConnectionValidates API access and token validity
OpenGrok: Show Server LogsExposes background process stdout/stderr
OpenGrok: Check for UpdatesPolls GitHub for new releases
OpenGrok: Status MenuOpens the context menu directly

Core Settings Profile

Expand for JSON Settings Reference
KeyFormatPrimary Usage
opengrok-mcp.baseUrlstringThe URI of your OpenGrok deployment
opengrok-mcp.usernamestringAuthentication identity
opengrok-mcp.verifySslbooleanDisable when using corporate self-signed certs (default: false)
opengrok-mcp.proxystringOptional HTTP traffic router

System Architecture

Show topological diagram
 [ 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 via esbuild. The server uses standard VS Code Node APIs without external VM requirements.


Building & Testing

# Initializing
npm install

# Code Quality & Tests
npm run lint      # Strict TypeScript & ESLint validation
npm test          # Execute the Vitest test suite

# Packaging
npm run compile   # Generate the esbuild artifact
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 new GitHub Release.

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


Troubleshooting & Support

The MCP tools are missing in Copilot Chat

  • Click the paperclip (๐Ÿ”ง) icon to "Update Tools"
  • Run Developer: Reload Window

"Connection failed" errors

  • Double-check your OPENGROK_BASE_URL
  • Make sure you aren't blocked by corporate VPNs/proxies

401 Unauthorized / Authentication failing

  • Run the OpenGrok: Configure Credentials command to save your username/password again

Self-Signed SSL Certificates

  • Turn off strict validation by setting opengrok-mcp.verifySsl to false

Slow queries or timeouts

  • Limit the scope using the file_type argument or targeting a specific project
  • OpenGrok might be indexing; run opengrok_index_health

Need verbose logs?

  • Set the environment variable OPENGROK_LOG_LEVEL=debug to get extensive stdout trace data

OpenGrok Version Compatibility

OpenGrok EngineStatusknown limitations
v1.13.x and aboveNative SupportNone (Full REST API functionality)
v1.7.0 โ€” v1.12.xLegacy ModeUses HTML scraping for symbol lookups and blame
Below v1.7.0UnsupportedUnpredictable behaviour

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.

Server Terkait