Skip to main content
Glama
Replaced by its MCP Registry listing

This endpoint is listed in the official MCP Registry as fynk MCP. If you published it, claim ownership there.

Search document text

search-document-text
Read-onlyIdempotent

Searches a document's text for literal terms or regular expressions and returns each match with surrounding text.

Use this tool when:

  • Finding a specific clause or term (e.g., notice period, liability cap, governing law).

  • Checking whether and where a document mentions something.

Prefer this over get-document-text when you only need specific passages. If a snippet is too short, search again with a larger context_chars (up to 2,000); for more than that, call get-document-text with offset as many characters before the match as you need (or 0 if the match is nearer the start) and max_chars about twice that, rather than reading the whole document.

Matching behavior:

  • Queries are literal text by default (no escaping needed for ".", "(", "$", "[").

  • Ignores case unless case_sensitive is true (e.g., to tell the defined term "Agreement" from "agreement").

  • Whitespace in a literal query matches any run of whitespace, including line breaks.

  • Matches inside longer words ("term" matches "termination" and "determined"); use regex mode with \b for whole words.

  • Pass several queries in one call for synonyms or translations (e.g., "Kündigung", "termination"); each match names the query it matched.

  • Returns the earliest matches in document order, up to max_results. If total_matches exceeds the number returned, narrow the query or raise max_results.

Regex mode (regex: true):

  • Each query is a PCRE regular expression, used as written, without delimiters. Escape special characters to match them literally ($, ., ().

  • Use it for whole words (\btermination\b), amounts (€\s?[\d.,]+), dates (\d{1,2}.\d{1,2}.\d{4}) and clause references (§\s?\d+).

  • Write \s+ between words: a space matches only a space, and the text breaks lines within sentences, especially in PDFs.

  • A pattern must match at least one character. Avoid nested repetition such as (\w+\s?)+, which can take too long and fail.

Handoff & errors:

  • Offsets are character indices into the same text get-document-text returns. Pass the returned text_hash to get-document-text to make sure the text hasn't changed in between.

  • If there is no text to search yet (text recognition of a PDF still running, or a new document's text not yet prepared) or none at all (password-protected PDF, unreadable scan), the call fails with a message giving the cause and whether retrying later can help.

  • The text follows an edit within a few seconds, so right after changing a document it may still show the previous wording.

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": {
      "document_uuid": "<document_uuid>",
      "queries": "<queries>"
    },
    "name": "search-document-text"
  }
}

Input Schema

NameRequiredDescriptionDefault
regexNoWhether each query is a PCRE regular expression rather than literal text. Defaults to false.
queriesYesThe text to look for, up to 200 characters each: literal text, or regular expressions if regex is true. A match of any of them counts.
max_resultsNoMaximum total matches across all queries, returning the earliest ones in document order. Defaults to 20.
context_charsNoHow many characters of text to include on each side of a match in its snippet. Defaults to 300.
document_uuidYesUUID of the document to search. If you don't already have the document's UUID, use the list-documents tool to find it.
case_sensitiveNoWhether upper and lower case must match. Defaults to false.

Output Schema

NameRequiredDescriptionDefault
matchesNoThe matches, in the order they occur in the text.
text_hashNoIdentifies the version of the text that was searched. get-document-text takes it, to read the same version.
total_charsNoThe length of the document's whole text, in characters.
total_matchesNoHow many matches the text holds in all. More than the number of matches returned when max_results cut the list short.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.3/5.0
Behavior3/5

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

Annotations already establish the safe read-only, idempotent, closed-world profile, so the bar is lower. The description nonetheless adds real behavioral context: matching rules (word-substring matches, whitespace runs, case default), truncation semantics via max_results/total_matches, and failure modes for missing/unready text with retry guidance and the eventual-consistency window after edits.

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?

Purpose is front-loaded in one sentence, then organized under clear headers (Usage, Matching behavior, Regex mode, Handoff & errors). It is long, but the length is proportionate to a tool with a regex mode and offset handoffs; each bullet carries actionable detail rather than restating the schema.

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?

With six parameters, a regex mode, and an output schema handling return shape, the description covers everything an agent needs to call it correctly: matching semantics, limits, error causes, retry viability, and the text_hash handoff to get-document-text.

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 coverage is 100%, so every parameter is already documented in the schema, anchoring the baseline at 3. The description does add semantic depth beyond the schema — PCRE regex semantics without delimiters and required escaping, the \s+ advice for PDF line breaks, the context_chars 2,000 ceiling plus handoff to get-document-text, and multi-query use for synonyms/translations.

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?

Opens with a specific verb and resource ("Searches a document's text for literal terms or regular expressions") plus a return-value summary. It also implicitly carves out scope against get-document-text by noting it returns only matches with surrounding snippets.

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 when-to-use bullets (finding a clause/term, checking mentions) and an explicit routing rule: "Prefer this over get-document-text when you only need specific passages," with a concrete escalation path (offset/max_chars) when the snippet is too short. Alternatives and exclusions are both named.

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