Skip to main content
Glama

Linkly AI

grep

Read-only

[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. Cloud documents take the form `cloud://<owner>/<slug>/<root-hash>/<path>`.
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. NOTE: cloud documents (`cloud://` doc_id) do not yet support `true`; omit or set to false for cloud targets.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

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 and openWorldHint=false, so the safety profile is covered. The description adds genuinely non-obvious behavior: it works on OCR-derived text from images/scanned PDFs and on audio/video transcripts, and that doc_id must come from a prior search. It does not discuss result volume limits or pagination beyond what the schema says.

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 workflow tag, then purpose, then sequencing, then document-type coverage — a clean information hierarchy. A few sentences restate schema facts (doc_id requirement, defaults) rather than adding new value, keeping it short of a 5.

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 an 11-parameter search tool with no output schema, the definition covers the essential unknowns: where doc_id comes from, what document types are indexed, and how to scale to multiple documents. Return-shape detail is partly covered by output_mode/output_format in the schema, so the gap is minor.

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 detail (including the fuzzy_whitespace cloud caveat and RE2 syntax). The description adds no parameter-level meaning itself, and its 'use read with offset to see full context' phrasing risks being conflated with grep's own offset parameter, which is match-based pagination, not a document line offset.

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 precise verb+resource+scope: 'Locate specific lines within a single document by regex pattern.' The single-document scope immediately separates it from the cross-document 'search' sibling, and the outline fallback rationale ('documents with has_outline=false') adds a second discriminator.

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?

Gives an explicit workflow chain (search → grep/outline → read), names the alternative (outline) and the condition that selects grep over it, and tells the agent how cross-document searching must be handled ('call grep once per document'). This is when-to-use, when-to-use-something-else, and sequencing all in one.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources