Skip to main content
Glama
igordev96
by igordev96

Search code at a ref

search
Read-only

Find text in a GitLab file tree at any branch, tag, or commit without cloning; results group matches by file and can list paths or hit counts.

Instructions

Search a whole file tree at a branch, tag, or commit — git grep — without cloning it into a working tree. Matches come back grouped by file: the path, then line: text for each hit. Set output to files or count when you want to know which files, or how many hits each holds, rather than read the lines: those two ask git not to emit a matched line at all, so they stay cheap and their totals stay exact on a broad query. Matching is literal (foo|bar matches that text, not foo or bar) and case-insensitive unless you say otherwise; the ref defaults to the repository's default branch. The ref is resolved before searching, so a branch created moments ago is fetched on the miss, and the result states the commit it searched and synced_at. path is a git pathspec, passed through as git defines it: src/components/*.tsx works, but a plain pathspec's ** needs at least one directory level — use :(glob)src/**/*.tsx for zero or more. A path that matches nothing simply returns no matches. Pass context to see the lines around each match: the hunk is numbered and matched lines are marked >, which git's own context flags cannot do here — under -z they lose which line matched. Use pickaxe to find when the text appeared.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
refNoBranch, tag, or commit to search, e.g. 'fix/PROJ-7608'. Defaults to the default branch.
pathNoA git pathspec to limit the search, e.g. 'src/components/*.tsx'. Use ':(glob)src/**/*.tsx' for `**` to match zero or more directories, which a plain pathspec does not do.
queryYesText to look for, e.g. 'vehicleCount'. Literal unless `regex` is set.
regexNoTreat `query` as a POSIX extended regex (not PCRE). Default false: match it literally.
outputNoWhat to return. Default 'matches': the matching lines, grouped by file. 'files': just the paths that matched. 'count': the path and matching-line count per file, with an exact 'total'. The last two skip emitting matched lines, so they are cheaper and stay exact on a broad query.
contextNoLines to show on each side of every match (default 0, none), marked so a matched line is distinguishable from a nearby one. Built by reading each displayed file once — at most 20 files per call — because git's own context flags lose which line matched under -z. Needs output 'matches'.
projectNoGitLab project path, e.g. 'group/subgroup/repo'. Defaults to GITLAB_DEFAULT_PROJECT.
max_matchesNoMaximum rows to return (default 100): matches, or files in the other modes. Tops them out; the totals in the header stay exact.
case_sensitiveNoMatch case exactly. Default false: search ignores case.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.10.1

TDQS

A4.6/5.0
Behavior5/5

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

Beyond readOnlyHint/openWorldHint it discloses non-obvious behavior: literal matching with case-insensitive default, ref defaults to the default branch, a cold ref is fetched on miss, results report `commit` and `synced_at`, context is built by re-reading each file with a cap of 20 files per call, and max_matches caps rows while totals stay exact.

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

Conciseness4/5

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

Front-loaded with the core capability and the output shape before edge cases. It is dense but nearly every clause carries actionable detail; the ref/pathspec/context sentences could be tightened into a list for faster scanning.

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

Completeness5/5

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

Nine parameters and no output schema, yet the description effectively supplies one (grouping, line format, header fields, exact totals). Limits, defaults, and error-ish behavior (empty path match, ref fetch on miss) are all covered, so an agent can call it correctly without further information.

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 already 100%, so baseline is 3; the description earns an extra point by explaining consequences the schema only hints at — that `files`/`count` make git skip emitting matched lines so totals stay exact, and why `context` must be rendered internally. It repeats the pathspec `**` note verbatim from the schema, which slightly dilutes the added value.

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

Purpose5/5

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

States a specific verb and resource ('Search a whole file tree at a branch, tag, or commit — git grep') and adds the key scoping fact ('without cloning it into a working tree'), which separates it from get_file, list_tree, and blame. The output shape (path then 'line: text' grouped by file) further pins down what it returns.

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?

Explicitly routes to `output: files|count` when counts matter and to `pickaxe` when the question is *when* text appeared, and warns that a nonexistent path silently returns nothing. It stops short of naming get_file or log as alternatives for the reverse cases, so it's clear but not exhaustive.

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