
# opengrok-go-mcp
**Source-code intelligence for agents, powered by OpenGrok and Go.**
*I have seen things you people wouldn’t grep.* — Senior Architect, probably.
[](LICENSE)
[](go.mod)
[](.github/workflows/ci.yml)
[](docs/tool-contracts.md)
[](evals/README.md)
---
Agent-oriented MCP server for searching, navigating, and reading code through
OpenGrok.
It turns OpenGrok into a safer code-intelligence surface for LLM agents:
- capability-gated tools that only appear when the backing OpenGrok feature works
- paginated search and file reads with stable cursors
- citation URLs on code results so answers can point back to source
- warnings for broad, heuristic, truncated, or best-effort results (`warnings[]`
codes plus a legacy `warning` string)
- automatic context expansion around search hits with explicit limits
- full, compact, and experimental gateway tool surfaces for different agent styles
If you are an AI agent reading this repository, start with [AGENTS.md](AGENTS.md)
for project constraints and agent workflow guidance.
> **Pre-1.0 note:** this MCP server is still evolving. Some tools, responses,
> and configuration paths may be broken or change before a stable 1.0 release.
> Please report issues using [docs/reporting-issues.md](docs/reporting-issues.md).
## When To Use It
Use `opengrok-go-mcp` when you want an agent to investigate a large indexed
codebase without cloning it locally. It works best for finding symbols,
reading files, tracing references, narrowing broad searches, and producing
answers with source citations.
It is intentionally honest about OpenGrok's limits. OpenGrok provides full-text
search plus ctags definitions, not a full semantic call graph or AST engine.
For structural questions, use this server to find the right files and symbols,
then verify relationships with language-aware tools when needed.
## Client Setup
**Required:** `OPENGROK_MCP_BASE_URL` — OpenGrok API base URL ending in `/api/v1`. On
startup the server discovers projects, probes capabilities, and registers only tools that
work. A typical reverse-proxied instance needs nothing else.
Copy a block below, replace the URL, restart the client.
The server defaults to `OPENGROK_MCP_AGENT_PROFILE=economy` (lean payloads, no auto
context expansion). Set `OPENGROK_MCP_AGENT_PROFILE=rich` when you want expanded
search context by default. Internal response diagnostics are off by default; set
`OPENGROK_MCP_DIAGNOSTICS=true` only when debugging pagination/search counters.
See [docs/configuration.md](docs/configuration.md) for the full environment
reference.