Skip to main content
Glama

Search Within a Source

search_within
Read-onlyIdempotent

Semantic search INSIDE a fetched record. Pass the text you already pulled (e.g. a SEC 10-K body, an article, a long tool result) plus a natural-language query; get back the top-N passages with character offsets and similarity scores. Use when the record is too big to cram into the prompt, search_within saves context, returns only the passages that matter, and every passage carries an offset so the agent can verify a verbatim quote. Pairs with ask_pipeworx_grounded: fetch with the gateway, ground over the relevant passages instead of the whole document. BGE-base-en embeddings + cosine over 500-char overlapping windows; cap is 200K chars (longer inputs are truncated and flagged).

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": {
      "query": "<query>"
    },
    "name": "search_within"
  }
}

Input Schema

NameRequiredDescriptionDefault
textNoThe document text to search inside (max ~200K chars). Omit when you pass result_id.
limitNoMax passages to return (1-20, default 5).
queryYesNatural-language query, what passages do you want? E.g. "supply-chain risk", "fiscal year 2024 revenue", "drug interactions with warfarin".
result_idNoSearch a result saved with _handle:true instead of passing text (offsets refer to the stored text). Pass text or result_id.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • removedInput schema / examples
      Removed value: -[
      -  {
      -    "query": "supply-chain risk",
      -    "text": "Apple Inc. reported fiscal 2023 revenue of $383.285 billion, driven by strong iPhone and Services growth. Net income was $96.995 billion. The company faced supply-chain risk in China during the quarter."
      -  }
      -]
  2. Changed3 schema fields changed
    • addedInput schema / properties / result_id
      Added value: +{
      +  "description": "Search a result saved with _handle:true instead of passing text (offsets refer to the stored text). Pass text or result_id.",
      +  "type": "string"
      +}
    • changedInput schema / properties / text / description
      Previous value: -"The document text to search inside (max ~200K chars)."New value: +"The document text to search inside (max ~200K chars). Omit when you pass result_id."
    • changedInput schema / required
      Previous value: -[
      -  "text",
      -  "query"
      -]New value: +[
      +  "query"
      +]
  3. Changed1 schema field changed
    • changedInput schema / properties / query / description
      Previous value: -"Natural-language query — what passages do you want? E.g. \"supply-chain risk\", \"fiscal year 2024 revenue\", \"drug interactions with warfarin\"."New value: +"Natural-language query, what passages do you want? E.g. \"supply-chain risk\", \"fiscal year 2024 revenue\", \"drug interactions with warfarin\"."
  4. Changed1 schema field changed
    • addedInput schema / examples
      Added value: +[
      +  {
      +    "query": "supply-chain risk",
      +    "text": "Apple Inc. reported fiscal 2023 revenue of $383.285 billion, driven by strong iPhone and Services growth. Net income was $96.995 billion. The company faced supply-chain risk in China during the quarter."
      +  }
      +]
  5. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Well beyond the readOnly/idempotent/non-destructive annotations, the description discloses the retrieval mechanics (BGE-base-en embeddings, cosine similarity over 500-char overlapping windows), the return payload (top-N passages with character offsets and similarity scores), and the hard input cap of 200K chars with truncation flagged. The offset detail matters because it lets the agent verify verbatim quotes, which annotations alone would never convey.

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?

Purpose, usage, and mechanics are front-loaded, and the final sentence packs the model, windowing, and cap into one clause. However, the sentence "Use when the record is too big... search_within saves context, returns only the passages that matter" is a run-on that duplicates the value proposition already stated, costing a little efficiency.

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?

There is no output schema, so the description carries the burden of explaining returns, and it does: top-N passages with character offsets and similarity scores, plus truncation flagging. Combined with the usage and mechanics detail, an agent has everything needed to call this correctly and interpret the result.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning on top: text is explicitly "the text you already pulled", result_id is an either/or with text where offsets refer to stored text, and the character cap is restated with truncation behavior. This is more than a paraphrase of the schema, though it doesn't add format or syntax details beyond what is already documented.

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?

"Semantic search INSIDE a fetched record" gives a specific verb and resource, and the description immediately frames the input as text you already pulled (10-K body, article, long tool result). It is clearly separable from siblings like ask_pipeworx_grounded, which is described as grounding over the whole document rather than retrieving passages from one.

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?

"Use when the record is too big to cram into the prompt" states the selecting condition explicitly, and the pairing sentence tells the agent how to chain with ask_pipeworx_grounded: fetch first, then ground over retrieved passages. The result_id parameter provides a second, clearly motivated usage path. No when-not is given, but the when-to guidance and named alternative are unusually concrete.

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.