Skip to main content
Glama

query_documents

Search ingested documents by hybrid keyword and semantic matching to retrieve ranked chunks with file paths and context for local RAG.

Instructions

Search ingested documents with hybrid keyword + semantic matching. Use the returned order as the ranking; score may disagree with it. Each has filePath, chunkIndex, text, fileTitle, score (lower is closer), and source (for ingest_data items). Optional sourceContext provides heading paths and original line or physical PDF page ranges; multiple heading paths mean the chunk crosses sections.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMax results (default 10, range 1-100). Lower favors precision, higher recall.
queryYesSearch query. Preserve specific user terms (for keyword match); add context when the query is vague (for semantic match).
scopeNoOptional absolute path prefix(es) — one string or a list (unioned) — restricting results to a filePath equal to or under a prefix. "/docs/api" matches "/docs/api/auth.md" but not "/docs/apiv2". Must be absolute (server OS style); a relative prefix matches nothing — derive one from a filePath returned by an earlier query, or omit scope.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.19.0
    • changedInput schema / properties / limit / description
      Previous value: -"Max results (default 10, range 1-20). Lower favors precision, higher recall."New value: +"Max results (default 10, range 1-100). Lower favors precision, higher recall."
    • changedInput schema / properties / limit / maximum
      Previous value: -20New value: +100
  2. Changed3 schema fields changedv0.15.3
    • changedInput schema / properties / limit / description
      Previous value: -"Maximum number of results to return (default: 10, range: 1-20). Recommended: 5 for precision, 10 for balance, 20 for broad exploration."New value: +"Max results (default 10, range 1-20). Lower favors precision, higher recall."
    • changedInput schema / properties / query / description
      Previous value: -"Search query. Include specific terms and add context if needed."New value: +"Search query. Preserve specific user terms (for keyword match); add context when the query is vague (for semantic match)."
    • addedInput schema / properties / scope
      Added value: +{
      +  "description": "Optional absolute path prefix(es) — one string or a list (unioned) — restricting results to a filePath equal to or under a prefix. \"/docs/api\" matches \"/docs/api/auth.md\" but not \"/docs/apiv2\". Must be absolute (server OS style); a relative prefix matches nothing — derive one from a filePath returned by an earlier query, or omit scope.",
      +  "oneOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    }
      +  ]
      +}
  3. Changed3 schema fields changedv0.15.0
    • changedInput schema / properties / limit / description
      Previous value: -"Maximum number of results to return (default: 10). Recommended: 5 for precision, 10 for balance, 20 for broad exploration."New value: +"Maximum number of results to return (default: 10, range: 1-20). Recommended: 5 for precision, 10 for balance, 20 for broad exploration."
    • addedInput schema / properties / limit / maximum
      Added value: +20
    • addedInput schema / properties / limit / minimum
      Added value: +1
  4. Changed2 schema fields changedv1.0.0
    • changedInput schema / properties / limit / description
      Previous value: -"Maximum number of results to return (default: 5, max recommended: 20)"New value: +"Maximum number of results to return (default: 10). Recommended: 5 for precision, 10 for balance, 20 for broad exploration."
    • changedInput schema / properties / query / description
      Previous value: -"Natural language search query (e.g., \"transformer architecture\", \"API documentation\")"New value: +"Search query. Include specific terms and add context if needed."
  5. First observed

TDQS

A3.7/5.0
Behavior4/5

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

With no annotations, the description carries the full burden, and it does disclose non-obvious behavior: result ordering is authoritative over score, score is lower-is-closer, source is only populated for ingest_data items, and multiple heading paths signal a cross-section chunk. It omits any statement of read-only safety, rate limits, or empty-result behavior, keeping it below a 5.

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 purpose, then dense but load-bearing detail about result fields and sourceContext semantics. Every sentence carries information, though the back half packs several distinct facts into long clauses that could be slightly tighter.

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?

There is no output schema, and the description compensates well by enumerating the return fields (filePath, chunkIndex, text, fileTitle, score, source) and explaining sourceContext. With no annotations, it should also cover the read-only nature and any scope-omission fallback, which it leaves implicit.

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 the schema already documents query, limit, and scope thoroughly (including the absolute-path prefix rule). The description's detail is almost entirely about returned fields, not input parameters, so it adds little beyond the schema; baseline 3 applies.

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

Purpose4/5

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

States a specific verb and resource ('Search ingested documents') and specifies the retrieval mechanism ('hybrid keyword + semantic matching'), so the agent knows exactly what capability this is. It does not name or contrast any sibling (e.g. read_chunk_neighbors or list_files), so it falls short of the sibling-differentiating 5.

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

Usage Guidelines3/5

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

Provides real guidance on interpreting output ('use the returned order as the ranking; score may disagree with it') and on query construction, which implies the tool's role. However, it never says when to prefer this over siblings like read_chunk_neighbors or list_files, and gives no exclusions or prerequisites, so usage is only implied.

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