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).

Example tool call

This call uses example arguments supplied in the tool’s input schema.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "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.",
      "query": "supply-chain risk"
    },
    "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. 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"
      +]
  2. 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\"."
  3. 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."
      +  }
      +]
  4. First observed

TDQS

A4.3/5.0
Behavior5/5

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

Beyond the annotations (which already state readOnly/idempotent/non-destructive), it discloses the retrieval mechanism (BGE-base-en embeddings, cosine over 500-char overlapping windows), the hard input cap of 200K chars, and the truncation-flag behavior. Offsets are called out as the mechanism for verifying verbatim quotes, which tells the agent what trust guarantees the output carries.

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?

Content is front-loaded — purpose, inputs, outputs, then usage, then implementation details — and most sentences carry distinct information. The middle clause ('search_within saves context, returns only the passages that matter') is somewhat redundant filler, and the run-on construction around it reads awkwardly.

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?

With no output schema, the description does the work of describing the return shape (top-N passages, offsets, similarity scores) and the size limits, which is what an agent needs to call it correctly. Minor omissions remain: passage ordering, behavior when nothing matches, and how result_id resolution failures surface.

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 four parameters are already documented in structured form; the description mostly restates them ('pass the text you already pulled... plus a natural-language query'). It does add the truncation-and-flag behavior tied to the text parameter, but says nothing about limit semantics or the text-vs-result_id precedence beyond what the schema already states.

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 opens with a specific verb and scope: 'Semantic search INSIDE a fetched record,' and immediately clarifies the input (text already pulled) and the output (top-N passages with character offsets and similarity scores). It is clearly distinguishable from retrieval siblings like ask_pipeworx_grounded, which it explicitly positions as the next step rather than a substitute.

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

Usage Guidelines4/5

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

It gives a concrete trigger ('Use when the record is too big to cram into the prompt') and names the complementary tool plus the workflow (fetch with the gateway, then ground over the relevant passages). What is missing is an explicit when-not — e.g., when the text is short enough to inline, or when to prefer ask_pipeworx_grounded over chunk-and-search.

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.