Skip to main content
Glama

akb_grep

Search documents for exact text or regex patterns. Get matching documents and lines, or use count_only/files_with_matches for summaries. Optionally replace matches across all documents.

Instructions

Search for exact text or regex patterns across document content. Unlike akb_search (semantic/meaning-based), this finds exact string matches — use it for specific terms, URLs, code snippets, version numbers, etc. Returns matching documents (each with its uri) and matched lines. Optionally pass replace to find-and-replace across all matching documents. Three response shapes (mutually exclusive): default lines, count_only=true (grep -c — per-doc counts + total, no snippets), files_with_matches=true (grep -l — just the URIs that contain the pattern). The default shape always reports BOTH returned_* (what fit under limit) and total_* (full corpus matches) plus a truncated flag — if truncated, switch to count_only/files_with_matches for the full picture instead of bumping limit.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYesSearch pattern. By default matched as literal text (ILIKE) — metacharacters like |, ., *, (), [], +, ? are treated as literal characters. Set regex=true to enable PostgreSQL regex (required for alternation and wildcards).
vaultNoLimit to a specific vault
collectionNoLimit to a specific collection
regexNoTreat pattern as PostgreSQL regex. REQUIRED to use alternation (|), wildcards (.*), character classes, anchors, etc. When false (default), the entire pattern including any metacharacters is matched literally.
case_sensitiveNoCase-sensitive matching (default: case-insensitive)
replaceNoReplacement string. If provided, replaces all matches in EVERY matching document across the search scope (git commit + re-index per doc). Supports regex backreferences (\1, \2) when regex=true. For precise edits to a single known document, prefer akb_edit instead.
limitNoMax documents to return
count_onlyNoReturn counts only (grep -c semantics). Response: {pattern, total_matches, total_docs, by_doc:{uri:count,...}}. Use for 'how many X are there?' questions — much cheaper than fetching every line.
files_with_matchesNoReturn only the URIs that contain matches (grep -l semantics). Response: {pattern, n_files, files:[uri,...]}. Use for 'which documents mention X?' questions.
Behavior5/5

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

Despite no annotations, the description thoroughly discloses behavior: default literal matching (ILIKE) vs regex, case sensitivity, replace side effects (git commit + re-index per doc), and response shapes with truncated flag. It clearly communicates that replace is a mutation and advises alternatives for single-document edits.

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?

The description is comprehensive but slightly verbose. It is well-structured with front-loaded purpose and sibling distinction, and logically organized sections. Every sentence adds value, but could be tightened slightly.

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?

The description is complete: covers search behavior, sibling comparison, response shapes, parameter guidance, and replace side effects. No output schema is provided, so the description adequately explains return values and shapes. For a complex tool with 9 parameters, this is very complete.

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

Parameters5/5

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

Schema coverage is 100%, but the description adds significant value beyond parameter descriptions: explains that pattern is literal by default (ILIKE) and when to use regex, replaces semantics including backreferences, and response shapes for count_only and files_with_matches. Provides usage guidance for each option.

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?

The description clearly states the tool's purpose: 'Search for exact text or regex patterns across document content.' It distinguishes from akb_search by contrasting exact string matches vs semantic/meaning-based search, and provides specific use cases (specific terms, URLs, code snippets, version numbers).

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?

Explicitly states when to use this tool (exact matches) versus akb_search (semantic). Also advises when to use akb_edit for single-document edits. Provides detailed guidance on the three response shapes and when to use each (e.g., if truncated, use count_only/files_with_matches instead of increasing limit).

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dnotitia/akb'

If you have feedback or need assistance with the MCP directory API, please join our Discord server