Skip to main content
Glama
Linkly AI

Linkly AI

Official

grep

Read-only

Locate exact lines in a single document using a regex pattern, especially when no outline is available. Use after search to pinpoint names, dates, terms, or identifiers, then read surrounding context.

Instructions

[Workflow: search → grep or outline → read] Locate specific lines within a single document by regex pattern. Best for documents with has_outline=false where outline is unavailable. Use after 'search' to pinpoint exact positions of names, dates, terms, identifiers, or any pattern — then use 'read' with offset to see full context. Works on all document types, including text derived from images and scanned PDFs (OCR) and from audio and video (transcripts). Requires a doc_id from a previous search result. For searching across multiple documents, call grep once per document.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "pattern": "<pattern>",
      "doc_id": "<doc_id>"
    },
    "name": "grep"
  }
}

Input Schema

NameRequiredDescriptionDefault
afterNoLines of context to keep after each match. Falls back to `context` (default 3) when omitted.
limitNoMaximum number of matching lines to return (default: 20, max: 100)
beforeNoLines of context to keep before each match. Falls back to `context` (default 3) when omitted.
doc_idYesDocument ID to search within (obtained from search results). Opaque string — pass through verbatim from `search`. Local documents take the form `local://<integer>`; bare integer IDs from older clients remain accepted.
offsetNoNumber of matches to skip for pagination (default: 0)
contextNoLines of context before and after each match (default: 3)
patternYesRegular expression to match. RE2-compatible syntax — no lookahead or backreference. Combine multiple alternatives in a single pattern with `|`; per-branch hit counts are returned.
output_modeNoOutput mode: "content" (matching lines with context, default) or "count" (match count only, useful to preview totals before paginating)
output_formatNoOutput format. Defaults to "markdown" (human-readable); set to "json" for structured JSON (machine-parseable). Sending `null` or omitting the field both yield the default.
case_insensitiveNoCase-insensitive matching (default: false)
fuzzy_whitespaceNoFuzzy whitespace matching for PDF noise tolerance. null/omit = auto (PDF on, others off), true = force on, false = force off

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.1.0

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, so the safety profile is covered; the description adds genuinely new behavioral context — it works on OCR text from images/scanned PDFs and transcripts from audio/video, it is single-document only, and it requires a doc_id from a prior search. It also hints at per-branch hit counts being returned, though it does not discuss pagination limits or result size.

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-loads a workflow tag ('search → grep or outline → read') before the definition, then proceeds in order of purpose, alternatives, coverage, prerequisites, and multi-document caveat. It is slightly long at seven sentences, but each carries an actionable constraint rather than filler.

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 11 parameters, no output schema, and full schema coverage, the description covers the workflow position, prerequisites, document-type coverage, and the per-document restriction. The only mild gap is that return shape (beyond the implied hit counts) and pagination behavior are not summarized, though output_mode/output_format are documented in the schema.

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

Parameters3/5

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

Schema description coverage is 100%, so all 11 parameters are already documented in the schema, which sets the baseline at 3. The description mentions regex pattern and offset-based context reading, but adds no format or syntax detail (such as default context=3 or max limit=100) beyond what the schema already states.

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 ('Locate specific lines within a single document by regex pattern') plus a scope constraint (single document). It clearly distinguishes itself from 'outline' (for documents without outlines), 'read' (for full context), and 'search' (for discovery), so an agent can pick it without inspecting schemas.

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

Usage Guidelines5/5

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

Explicit routing: use after 'search' for exact positions, prefer 'outline' when has_outline=true, then use 'read' with offset for context. It also states the multi-document case ('call grep once per document') and the prerequisite ('Requires a doc_id from a previous search result'), leaving little to inference.

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