Skip to main content
Glama
jenkeeri
by jenkeeri

opengrok-mcp

An MCP server that lets an AI agent search and read source code indexed by an OpenGrok instance. Read-only, stdio transport.

Tested against OpenGrok 1.14. It uses the REST search API and the /raw file route, both of which work anonymously on a default install.

Tools

Tool

Purpose

opengrok_search

Search by full text, def (definitions), symbol, path, hist (commit messages) and type, with paging.

opengrok_find_file

Find files by name or path pattern.

opengrok_get_file

Read a file (line-numbered) by the path returned from search, with an optional line range.

opengrok_list_projects

List the project names on the instance.

Searches are scoped to the configured default project(s); pass projects to pick others or all_projects: true to search everything.

Related MCP server: Semantic Code Search MCP Server

Install

Requires Node.js 20+.

git clone https://github.com/jenkeeri/opengrok-mcp.git
cd opengrok-mcp
npm install && npm run build

Configuration

All settings are environment variables, normally set in your MCP client's server entry:

Variable

Required

Description

OPENGROK_URL

yes

Base URL, e.g. https://opengrok.example.com

OPENGROK_DEFAULT_PROJECT

no

Comma-separated default project(s). Empty means all projects.

OPENGROK_INSTRUCTIONS

no

Free text appended to the server instructions the agent sees. Use it to describe your project layout (what each project is, naming conventions).

OPENGROK_TOKEN

no

Bearer token, if the instance needs one.

OPENGROK_USERNAME / OPENGROK_PASSWORD

no

Basic auth, if the instance needs it.

OPENGROK_TIMEOUT_MS

no

Per-request timeout (default 30000).

Example MCP client entry:

{
  "mcpServers": {
    "opengrok": {
      "command": "node",
      "args": ["/path/to/opengrok-mcp/dist/index.js"],
      "env": {
        "OPENGROK_URL": "https://opengrok.example.com",
        "OPENGROK_DEFAULT_PROJECT": "myproject",
        "OPENGROK_INSTRUCTIONS": "Project 'myproject' is the main branch; 'myproject-1.2' is a release branch."
      }
    }
  }
}

Notes

  • Use the REST parameter names projects, def, symbol and start. The web UI names (project, defs, refs) are silently ignored by the API, which makes project filtering appear broken.

  • type takes an OpenGrok analyzer name (c, cxx, java, python, ...); an unknown name returns zero results.

  • def and symbol rely on OpenGrok's language-aware indexing; use full for file types it cannot parse.

Development

npm test          # unit tests (synthetic fixtures, no network)
npm run typecheck
npm run build

License

GPL-3.0, see LICENSE.

Available Tools

4 tools
opengrok_find_fileFind files in OpenGrokA
Read-onlyIdempotent

Find files by path or file name. Returns file paths only. Examples: "main.cpp" (name), "*.sql" (wildcard), "src/net" (directory), "/.test..py/" (regex). Default scope: none (all projects).

ParametersJSON Schema
NameRequiredDescriptionDefault
typeNoFile type (analyzer name), as for opengrok_search.
startNoOffset of the first file to return (default 0); use the value a previous page suggested.
projectsNoProjects to search (default: none (all projects)). Names from opengrok_list_projects.
max_resultsNoFiles per page (default 30, max 100).
all_projectsNoSearch every project instead of the default. Ignored if projects is set.
path_patternYesPath or name pattern.

TDQS

A3.9/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly, idempotent, non-destructive, and open-world behavior, so the safety profile is covered. The description usefully adds the return shape ("file paths only") and default scope, both of which matter for a tool with no output schema. Pagination behavior lives in the schema rather than the description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose, then return shape, then a compact single-line example block, then the scope default. Every sentence carries information and nothing is repeated.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the "returns file paths only" statement is essential and present, and the scope default is called out. Pagination and project-selection mechanics are handled by the schema, so the description is sufficient, though it does not address result volume or empty-result behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% so the structured fields already document all six parameters. The description still earns credit by clarifying the format of path_pattern (name vs wildcard vs directory vs regex), which the schema only labels as "Path or name pattern" — a genuine semantic addition.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ("Find files by path or file name") and immediately scopes the result ("Returns file paths only"). This implicitly separates it from opengrok_get_file (content retrieval) and opengrok_search (content matching), though it never names those siblings explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides concrete input examples and states the default scope ("none (all projects)"), which implies usage context. However there is no explicit guidance on when to prefer this over opengrok_search or opengrok_get_file, so the routing decision is left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

opengrok_get_fileRead file from OpenGrokA
Read-onlyIdempotent

Read a file's content (line-numbered) by the full path returned from search, e.g. "//dir/file.c". Use start_line/end_line for large files; output is cut at 30000 characters.

ParametersJSON Schema
NameRequiredDescriptionDefault
end_lineNoLast line (1-based, inclusive).
file_pathYesFull path as returned by search, starting with "/<project>/".
start_lineNoFirst line (1-based, inclusive).

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly/idempotent/non-destructive, so the safety profile is covered. The description adds real behavioral context beyond them: line-numbered output and a hard 30000-character truncation limit, which the agent needs to plan pagination. It doesn't cover error behavior on bad paths.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two tightly written sentences with the essential path-source constraint front-loaded and the pagination/truncation caveat second. Every clause carries information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description must carry the return format, and it does: line-numbered content with a 30000-character cap. Complete enough to call correctly, with only error-handling and exact truncation semantics left implicit.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description reinforces file_path's required format with an example and explains the purpose of start_line/end_line for large files, tying parameters to behavior rather than restating types.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Read a file's content') plus the key qualifier that the path must be the full path returned from search, which separates it from opengrok_find_file. It does not explicitly name the sibling tools, but the resource and path-source constraint make its role distinguishable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives clear context for using start_line/end_line on large files and tells the agent where file_path comes from ('returned from search'). It stops short of an explicit when-not-to-use statement against opengrok_find_file or opengrok_search, but the routing guidance is strong.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

opengrok_list_projectsList OpenGrok projectsA
Read-onlyIdempotent

List the project names available on the OpenGrok instance (valid values for the projects argument).

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint, idempotentHint, openWorldHint and destructiveHint=false, so the safety profile is fully covered. The description adds that the payload is project names usable as the projects argument, which is useful but does not describe ordering, format, or whether results reflect a live instance.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One sentence, zero filler, and the key output semantic is front-loaded immediately after the core action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter, read-only listing tool with no output schema, the description conveys enough: what is returned (project names) and what they are for. Only the shape/ordering of the returned list is unspecified, which is a minor gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool takes zero parameters, so the baseline of 4 applies. The description nevertheless explains the role of the output values relative to the projects argument of sibling tools, which is mildly more than the empty schema conveys.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific verb+resource pair ('List the project names available on the OpenGrok instance'), which is easily separable from the search/get_file/find_file siblings. It does not explicitly call out those siblings, so it lands at 4 rather than 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The parenthetical '(valid values for the projects argument)' gives concrete context: this is the discovery step that feeds the projects parameter of the search tool. No explicit when-not or named alternatives are given, so it stops short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv0.1.0
    • First observedopengrok_find_file
    • First observedopengrok_get_file
    • First observedopengrok_list_projects
    • First observedopengrok_search

TDQS

A4.1/5.0

Scored across 4 tools

Disambiguation4/5

Each tool targets a distinct action: search content, read a file, find files by path, list projects. The only overlap is that opengrok_search's 'path' parameter can also filter by path, which could be confused with opengrok_find_file, but the descriptions clarify that search returns matching lines while find_file returns only paths.

Naming Consistency4/5

All tools use the opengrok_ prefix and snake_case. Three follow verb_noun (get_file, find_file, list_projects), while search is just a verb, a minor deviation from the otherwise consistent pattern.

Tool Count5/5

Four tools is well-scoped for a read-only code search server. Each tool has a clear, non-redundant role: search content, retrieve file contents, find files, and list projects.

Completeness4/5

The core read-only workflows (search, read, find, list projects) are covered. Minor gaps exist, such as no direct file history/blame tool and no explicit directory listing beyond find_file patterns, but agents can work around these with existing tools.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables LLMs to perform high-performance code search and analysis across multiple languages using symbol indexing, regex text search, and structural AST pattern matching. It also provides tools for technology stack detection and dependency analysis with persistent caching for optimized performance.
    9
    MIT