AgentHubAgentHub

OpenGrok MCP Setup & Guide

MCP ServerMCP RegistryOfficial

io.github.IcyHot09/opengrok-mcp-server · v9.6.0

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

Copy the install config on this page first, then verify docs and permissions upstream.

Overview

MCP server bridging OpenGrok search engine with AI for instant context across massive codebases. OpenGrok MCP Server is a MCP Server listed from MCP Registry. Transports: stdio. This page includes an overview, setup tutorial, install commands, and use cases for Trae, Tongyi Lingma, Cursor, Claude Code, and VS Code.

Use cases

AgentHub Verified AvailabilityTested & Ready

Automated pipeline validated install commands, protocol & client compatibility

Verified At2026-10-25
Install Snippets TestedCLI & JSON config syntax verified
Protocol Handshake ReadyComplies with JSON-RPC 2.0 specifications
Origin Registry ActiveSourced from official-mcp-registry
Verified ClientsClaude Code、Claude Desktop、Cursor 等
Security Tier: A+ 级 · 官方认证推荐 (A+)·Maintained by official/verified teams, audited for standard MCP protocol compliance.

Copy by platform

Choose your platform

  1. Open or create .cursor/mcp.json in your project root
  2. Click Copy config and paste; merge only this mcpServers entry if others exist
  3. Replace <placeholders> in env with real secrets (see Environment variables below)
  4. Save, then Cmd+Shift+P → Reload Window

Pre-fill Environment Variables (Optional)

Required
secret
Privacy Guarantee: Keys are replaced 100% locally in your browser memory and are NEVER uploaded or stored on any server.
Click to copy snippet
{
  "mcpServers": {
    "opengrok-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "opengrok-mcp-server"
      ],
      "env": {
        "OPENGROK_BASE_URL": "<OPENGROK_BASE_URL>"
      }
    }
  }
}

Setup tutorial

  1. Open the OpenGrok MCP Server page and confirm this MCP Server (source: MCP Registry).
  2. Copy the Cursor, Claude Code, or VS Code snippet.
  3. Merge it into mcpServers and replace env placeholders with real secrets.
  4. Reload the window, then call the MCP tools from your agent chat.

Install commands

Install commands and setup steps are in the HTML so search engines and no-JS browsers can read them without running client JavaScript.

Claude Code (local)

  1. Install Claude Code CLI
  2. Copy the command below, replace <placeholders> with real env values, then run in terminal
  3. See Environment variables below if listed
claude mcp add opengrok-mcp-server --env OPENGROK_BASE_URL=<OPENGROK_BASE_URL> -- npx -y opengrok-mcp-server

Cursor — .cursor/mcp.json (local)

  1. Open or create .cursor/mcp.json in your project root
  2. Click Copy config and paste; merge only this mcpServers entry if others exist
  3. Replace <placeholders> in env with real secrets (see Environment variables below)
  4. Save, then Cmd+Shift+P → Reload Window
{
  "mcpServers": {
    "opengrok-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "opengrok-mcp-server"
      ],
      "env": {
        "OPENGROK_BASE_URL": "<OPENGROK_BASE_URL>"
      }
    }
  }
}

VS Code — .vscode/mcp.json (local)

  1. Install GitHub Copilot in VS Code with MCP support
  2. Open or create .vscode/mcp.json in your project root
  3. Click Copy config and paste; merge only this mcpServers entry if others exist
  4. Replace <placeholders> in env with real secrets
  5. Save and Developer: Reload Window
{
  "mcpServers": {
    "opengrok-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "opengrok-mcp-server"
      ],
      "env": {
        "OPENGROK_BASE_URL": "<OPENGROK_BASE_URL>"
      }
    }
  }
}

Claude Desktop — claude_desktop_config.json (local)

  1. Open Claude Desktop claude_desktop_config.json (see remote guide for paths)
  2. Click Copy config and merge under mcpServers
  3. Replace <placeholders> in env with real secrets
  4. Fully quit and restart Claude Desktop
{
  "mcpServers": {
    "opengrok-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "opengrok-mcp-server"
      ],
      "env": {
        "OPENGROK_BASE_URL": "<OPENGROK_BASE_URL>"
      }
    }
  }
}

Trae — .trae/mcp.json (local)

  1. Trae → Settings → MCP, or edit .trae/mcp.json / global mcp.json
  2. Click Copy config and merge mcpServers
  3. Replace <placeholders> in env with real secrets
  4. Save and reload Trae
{
  "mcpServers": {
    "opengrok-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "opengrok-mcp-server"
      ],
      "env": {
        "OPENGROK_BASE_URL": "<OPENGROK_BASE_URL>"
      }
    }
  }
}

Cherry Studio — MCP settings (local)

  1. Cherry Studio → Settings → MCP Servers → Add (STDIO)
  2. Or import JSON: click Copy config and merge mcpServers
  3. Replace <placeholders> in env; ensure Node.js / uv (npx, uvx) are installed
  4. Enable the server and check tools load
{
  "mcpServers": {
    "opengrok-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "opengrok-mcp-server"
      ],
      "env": {
        "OPENGROK_BASE_URL": "<OPENGROK_BASE_URL>"
      }
    }
  }
}

Tongyi Lingma — MCP config (local)

  1. Lingma Settings → MCP → + → STDIO or config file
  2. Click Copy config and merge mcpServers
  3. Replace <placeholders> in env; need Node.js 18+ (npx) or uv (uvx)
  4. Confirm connected before using tools in agent chat
{
  "mcpServers": {
    "opengrok-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "opengrok-mcp-server"
      ],
      "env": {
        "OPENGROK_BASE_URL": "<OPENGROK_BASE_URL>"
      }
    }
  }
}

Windsurf — mcp_config.json (local)

  1. Edit ~/.codeium/windsurf/mcp_config.json
  2. Click Copy config and merge mcpServers (stdio same as Cursor)
  3. Replace <placeholders> in env, save, refresh Cascade
{
  "mcpServers": {
    "opengrok-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "opengrok-mcp-server"
      ],
      "env": {
        "OPENGROK_BASE_URL": "<OPENGROK_BASE_URL>"
      }
    }
  }
}

Cline — MCP Servers (local)

  1. Cline panel → Settings → MCP Servers
  2. Click Copy config and merge
  3. Replace <placeholders> in env, then save
{
  "mcpServers": {
    "opengrok-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "opengrok-mcp-server"
      ],
      "env": {
        "OPENGROK_BASE_URL": "<OPENGROK_BASE_URL>"
      }
    }
  }
}

WorkBuddy — .workbuddy/mcp.json (local)

  1. Edit ~/.workbuddy/mcp.json (user) or project .workbuddy/mcp.json
  2. Or Plugins → MCP Servers → Configure MCP and paste the JSON below
  3. Replace <placeholders> in env; on Windows prefer absolute paths for command/scripts
  4. Save, restart WorkBuddy, confirm connector status is green
{
  "mcpServers": {
    "opengrok-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "opengrok-mcp-server"
      ],
      "env": {
        "OPENGROK_BASE_URL": "<OPENGROK_BASE_URL>"
      }
    }
  }
}

Troubleshooting & Common ErrorsFAQ

Common connection errors and verified fixes for OpenGrok MCP Server

Getting 'connection closed' or exit code 1 in Cursor / Claude Code for OpenGrok MCP Server?

Usually caused by missing runtime paths or IDE environment inheritance. Fix steps: 1. Verify Node.js 18+ (npx) or Python 3.10+ (uvx) is installed; 2. Run 'which npx' or 'which uvx' in terminal, and replace 'command' with absolute path; 3. Reload or restart the client window after modifying config.

Fix Snippet
# Check binary path in terminal:
which npx
node -v
Getting 'spawn npx ENOENT' or 'command not found'?

The editor background process does not inherit your full terminal PATH. Solution: Globally install the package, or set the absolute binary path (e.g. C:\Program Files\nodejs\npx.cmd on Windows, or /usr/local/bin/npx on macOS).

Missing required environment variable or authentication failure?

OpenGrok MCP Server requires environment variables (OPENGROK_BASE_URL). Ensure you have added valid keys under the 'env' object in your config file without trailing whitespace.

Fix Snippet
// .cursor/mcp.json 或 claude_desktop_config.json
{
  "env": {
    "OPENGROK_BASE_URL": "your_actual_key_here"
  }
}

Tool Mock Playground

Sandbox

OpenGrok MCP Server Tool Interface Simulation · Preview tool schema & outputs without local runtime

Sandbox Ready
fn: opengrok_mcp_serverExecute the core tool interface of OpenGrok MCP Server
Request ArgumentsJSON Schema
{
  "target": "OpenGrok MCP Server",
  "action": "execute",
  "options": {
    "mode": "standard",
    "timeoutMs": 5000
  }
}
💡Parameters generated dynamically by Agent runtime
Agent Tool Output

Click 'Run Mock' above

to preview the raw response returned to the LLM

Env: AgentHub Virtual SandboxJSON-RPC 2.0

Decision Guide: Why & When to Use

Assess suitability before installing to save trial-and-error time

Best Suited For
  • PR review
  • Changelog generation
  • Cross-repo issue search
When NOT to Use
  • Replacing human security audit
  • Unauthorized repo access
Recommended Workflow Pairing:View Scenario →

OpenGrok MCP Server + Scenario Prompt → Complete Agent Automation

MCP hands-on: install to visible results

Follow the full lab (expected UI/output + contrast checks). After installing this item, verify with the tutorial prompts.

Open tutorial →

Related resources

Often paired with

中文公文写作

v2.0.46

SkillClawHub7210.6k

io.clawhub.gongyu0918-debug/chinese-official-writing

用于中文公文、事务性材料和新闻稿件的起草、改写、压缩、润色、审校、文种核对、去口语化、降 AI 味及 Word 格式处理,适用于机关、企事业单位、学校和新闻机构。涵盖申请、请示、报告、通知、通告、意见、决定、决议、议案、公报、命令、函、复函、批复、说明、方案、纪要、公告、公示、通报、制度、规定、办法、细则、操作规程、工作要点、总结、调研、讲话、致辞、主持词、述职、可研、审查材料、技术需求、新闻消息、编者按、新闻评论,以及采购、整改、反馈和 AI 算力等场景。

source

Keep exploring AgentHub

Most people compare similar tools or check scenario guides before installing—start here.

Listing badge: put AgentHub on your site

Copy either snippet into your project homepage, docs, or GitHub README. The badge is a hotlinked SVG — nothing to host — and it links back to this page so visitors can find the install steps.

PreviewListed on AgentHub: OpenGrok MCP Server
HTML
<a href="https://myagenthub.cn/p/io.github.IcyHot09/opengrok-mcp-server" title="Listed on AgentHub: OpenGrok MCP Server" target="_blank" rel="noopener">
  <img src="https://myagenthub.cn/badge/io.github.IcyHot09/opengrok-mcp-server?lang=en" alt="Listed on AgentHub: OpenGrok MCP Server" height="20" style="border:0"/>
</a>
Markdown (GitHub README)
[![Listed on AgentHub: OpenGrok MCP Server](https://myagenthub.cn/badge/io.github.IcyHot09/opengrok-mcp-server?lang=en)](https://myagenthub.cn/p/io.github.IcyHot09/opengrok-mcp-server)

Badges are generated on the fly from /badge/<package-id>, so name and listing changes propagate automatically. Keep the link target unchanged — it is what counts as the referral.

Unified Manifest

{
  "id": "io.github.IcyHot09/opengrok-mcp-server",
  "type": "mcp-server",
  "version": "9.6.0",
  "displayName": "OpenGrok MCP Server",
  "description": "MCP server bridging OpenGrok search engine with AI for instant context across massive codebases.",
  "repository": {
    "url": "https://github.com/IcyHot09/opengrok-mcp-server",
    "source": "github"
  },
  "homepage": "https://github.com/IcyHot09/opengrok-mcp-server",
  "distribution": {
    "packages": [
      {
        "registryType": "npm",
        "identifier": "opengrok-mcp-server",
        "version": "9.6.0",
        "runtimeHint": "npx",
        "transport": "stdio",
        "environmentVariables": [
          {
            "name": "OPENGROK_BASE_URL",
            "description": "OpenGrok server base URL (e.g. https://opengrok.example.com/source/)",
            "isRequired": true
          },
          {
            "name": "OPENGROK_USERNAME",
            "description": "OpenGrok authentication username. Leave unset for anonymous access."
          },
          {
            "name": "OPENGROK_PASSWORD",
            "description": "OpenGrok authentication password. Prefer storing via OS keychain using 'npx opengrok-mcp-server setup'.",
            "isSecret": true
          },
          {
            "name": "OPENGROK_VERIFY_SSL",
            "description": "Verify TLS certificates. Set to false for self-signed or internal CA certs."
          },
          {
            "name": "OPENGROK_CODE_MODE",
            "description": "Enable Code Mode: 2-tool sandbox interface with env.opengrok.* JavaScript API. Reduces AI token usage by ~90%."
          },
          {
            "name": "OPENGROK_ENABLE_MEMORY_TOOLS",
            "description": "Register the 3 memory tools in Code Mode (memory status, read, update). Off = api + execute only."
          },
          {
            "name": "OPENGROK_DEFAULT_PROJECT",
            "description": "Default project to scope all searches. Can be overridden per call."
          },
          {
            "name": "OPENGROK_CONTEXT_BUDGET",
            "description": "Response size tier controlling token usage."
          },
          {
            "name": "OPENGROK_API_VERSION",
            "description": "OpenGrok REST API version. Use v2 for call graph features (requires OpenGrok 1.12+)."
          },
          {
            "name": "HTTP_PROXY",
            "description": "HTTP/HTTPS proxy URL for all OpenGrok API requests (e.g. http://proxy.company.com:8080). Also set as HTTPS_PROXY."
          },
          {
            "name": "OPENGROK_RESPONSE_FORMAT_OVERRIDE",
            "description": "Force a specific response format for all tools. Leave unset for per-tool auto-selection (recommended)."
          },
          {
            "name": "OPENGROK_MEMORY_BANK_DIR",
            "description": "Directory 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."
          },
          {
            "name": "OPENGROK_LOCAL_COMPILE_DB_PATHS",
            "description": "Comma-separated paths to compile_commands.json for C/C++ compiler flag and include-path extraction. Leave unset for automatic workspace discovery."
          },
          {
            "name": "OPENGROK_ENABLE_ELICITATION",
            "description": "Interactive 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."
          },
          {
            "name": "OPENGROK_ENABLE_SAMPLING",
            "description": "AI 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)."
          },
          {
            "name": "OPENGROK_SAMPLING_MODEL",
            "description": "Model preference for MCP Sampling (used for error explanation and query reformulation)."
          },
          {
            "name": "OPENGROK_ENABLE_FILES_API",
            "description": "Files API Cache — avoids re-uploading unchanged investigation notes. Requires Files API support in the MCP client."
          },
          {
            "name": "OPENGROK_ENABLE_OBSERVATION_MASKER",
            "description": "Observation 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)."
          },
          {
            "name": "OPENGROK_OBSERVATION_MASKER_TURNS",
            "description": "Number of most-recent opengrok_execute results to keep as full text before masking older ones. Default: 10."
          },
          {
            "name": "OPENGROK_SAMPLING_MAX_TOKENS",
            "description": "Maximum tokens for AI sampling responses (error explanation, query reformulation). Range: 64–4096."
          },
          {
            "name": "OPENGROK_AUDIT_LOG_FILE",
            "description": "Path to write structured audit events (CSV/JSON). Appends tool invocations, elicitation events, and errors. Leave unset to disable."
          },
          {
            "name": "OPENGROK_RATELIMIT_RPM",
            "description": "Maximum requests per minute to the OpenGrok server. Default: 60."
          },
          {
            "name": "OPENGROK_PER_TOOL_RATELIMIT",
            "description": "Per-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."
          },
          {
            "name": "OPENGROK_TIMEOUT",
            "description": "HTTP request timeout in seconds for OpenGrok API calls. Increase for slow servers. Default: 30."
          },
          {
            "name": "OPENGROK_DEFAULT_MAX_RESULTS",
            "description": "Default maximum number of results returned per search query. Default: 25."
          },
          {
            "name": "OPENGROK_PASSWORD_FILE",
            "description": "Path to a file containing the OpenGrok password (file-mounted secret for containers). Takes precedence over the OS keychain when OPENGROK_PASSWORD is unset."
          },
          {
            "name": "OPENGROK_MAX_RESPONSE_BYTES",
            "description": "Hard cap on response payload size in bytes. Overrides the context-budget default. Non-positive values are ignored."
          },
          {
            "name": "OPENGROK_SEARCH_AND_READ_CAP",
            "description": "Cap 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."
          },
          {
            "name": "OPENGROK_STRICT_SSRF",
            "description": "When true, reject OPENGROK_BASE_URL values pointing at private/loopback IPs at startup. Default: false (warn only; per-request guards still apply)."
          },
          {
            "name": "OPENGROK_JWT_ISSUER",
            "description": "Expected JWT issuer (iss claim) for HTTP transport OAuth. When set, JWTs from other issuers are rejected."
          },
          {
            "name": "OPENGROK_GRAMMAR_DIR",
            "description": "Directory containing tree-sitter WASM grammars. Overrides the bundled grammar lookup."
          }
        ]
      }
    ],
    "remotes": []
  },
  "dependencies": [],
  "installTargets": [
    "claude-code",
    "claude-desktop",
    "cursor",
    "vscode",
    "trae",
    "cherry-studio",
    "lingma",
    "windsurf",
    "cline",
    "workbuddy"
  ],
  "keywords": [],
  "provenance": {
    "origin": "official-mcp-registry",
    "originalId": "io.github.IcyHot09/opengrok-mcp-server",
    "originalUrl": "https://registry.modelcontextprotocol.io/v0.1/servers/io.github.IcyHot09%2Fopengrok-mcp-server/versions/latest",
    "isOfficial": true,
    "status": "active"
  }
}
OpenGrok MCP Setup & Guide - AgentHub