Skip to main content
Glama

Find related documents

find_related

Find documents semantically related to an existing document by ranking local sentence embeddings via cosine similarity. Optionally restrict by target types and minimum score.

Instructions

Find the documents most semantically related to an existing document, given its type/id, ranked by cosine similarity of local sentence embeddings (fastembed/bge-small, the similarity extra). By default every whole-body domain is searched (req, uc, tsk, qa, prb, gol, rsk, dec, sop, feat, vcr, sysrs, txt; adr is excluded structurally) -- restrict with target_types; the source document itself is excluded from the results. Returns up to top_k (default 10, validated 1..100) hits as {type, id, title, status, path, score} rows, sorted by score descending; min_score (default: no filter) is an inclusive cosine lower bound. An unparseable candidate still appears, embedded from its full raw text, with id = null and the <failed to parse> marker title/status. When the embedding feature is unavailable (SPECMGR_SIMILARITY_DISABLED present, or the backend/model fails to load), returns the structured {available: false, reason, message} result instead of raising. A bad type/id/target_types/top_k is a ValueError before any filesystem access; a missing source is the domain's own XNotFoundError.

Input Schema

NameRequiredDescriptionDefault
idYes
typeYes
top_kNo
min_scoreNo
target_typesNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.38.0
    • changedInput schema / properties / type / enum
      Previous value: -[
      -  "req",
      -  "uc",
      -  "tsk",
      -  "qa",
      -  "prb",
      -  "gol",
      -  "rsk",
      -  "dec",
      -  "sop",
      -  "feat",
      -  "vcr",
      -  "sysrs"
      -]New value: +[
      +  "req",
      +  "uc",
      +  "tsk",
      +  "qa",
      +  "prb",
      +  "gol",
      +  "rsk",
      +  "dec",
      +  "sop",
      +  "feat",
      +  "vcr",
      +  "sysrs",
      +  "txt"
      +]
    • changedOutput schema / $defs / SimilarityHit / description
      Previous value: -"One ranked similarity hit: a candidate document plus its score (ACC-001/ACC-002).\n\nParameters\n----------\ntype:\n    The hit's domain name: one of the whole-body domains\n    (``req``, ``uc``, ``tsk``, ``qa``, ``prb``, ``gol``, ``rsk``,\n    ``dec``, ``sop``, ``feat``, ``vcr``, ``sysrs``) -- ``adr`` is\n    structurally excluded from the candidate set (issue #46, ADR\n    750842b2's **corpus and registry** sub-decision).\nid:\n    The hit document's specmgr-assigned id (the validated frontmatter\n    value, the domain's own defaults applied for a blank key --\n    exactly what ``list_<domain>`` surfaces), or ``None`` when the\n    candidate file failed to parse (REQ-009: the marker rows are not\n    addressable).\ntitle:\n    The hit document's first H1 title, or the fixed marker\n    ``\"<failed to parse>\"`` for an unparseable candidate.\nstatus:\n    The hit document's validated ``frontmatter.status`` value, or the\n    fixed marker ``\"<failed to parse>\"`` for an unparseable candidate.\npath:\n    The real, absolute (``.resolve()``d) filesystem path to the hit\n    document's on-disk file, for a caller that wants to read it\n    directly instead of going through the matching ``get_<domain>``\n    tool (which it cannot do for an unparseable candidate -- its\n    ``id`` is ``None``).\nscore:\n    The cosine similarity of the hit document's embedding against the\n    query (dot product on L2-normalized vectors, in [-1, 1]); the\n    result list is sorted by ``score`` descending, ties in the\n    candidate enumeration's own deterministic order."New value: +"One ranked similarity hit: a candidate document plus its score (ACC-001/ACC-002).\n\nParameters\n----------\ntype:\n    The hit's domain name: one of the whole-body domains\n    (``req``, ``uc``, ``tsk``, ``qa``, ``prb``, ``gol``, ``rsk``,\n    ``dec``, ``sop``, ``feat``, ``vcr``, ``sysrs``, ``txt``) -- ``adr``\n    is structurally excluded from the candidate set (issue #46, ADR\n    750842b2's **corpus and registry** sub-decision).\nid:\n    The hit document's specmgr-assigned id (the validated frontmatter\n    value, the domain's own defaults applied for a blank key --\n    exactly what ``list_<domain>`` surfaces), or ``None`` when the\n    candidate file failed to parse (REQ-009: the marker rows are not\n    addressable).\ntitle:\n    The hit document's first H1 title, or the fixed marker\n    ``\"<failed to parse>\"`` for an unparseable candidate.\nstatus:\n    The hit document's validated ``frontmatter.status`` value, or the\n    fixed marker ``\"<failed to parse>\"`` for an unparseable candidate.\npath:\n    The real, absolute (``.resolve()``d) filesystem path to the hit\n    document's on-disk file, for a caller that wants to read it\n    directly instead of going through the matching ``get_<domain>``\n    tool (which it cannot do for an unparseable candidate -- its\n    ``id`` is ``None``).\nscore:\n    The cosine similarity of the hit document's embedding against the\n    query (dot product on L2-normalized vectors, in [-1, 1]); the\n    result list is sorted by ``score`` descending, ties in the\n    candidate enumeration's own deterministic order."
  2. First observedv0.36.0

TDQS

A4.7/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so thoroughly: it discloses the embedding backend, the feature-disabled fallback returning {available: false, reason, message} instead of raising, the exact error taxonomy (ValueError before filesystem access vs the domain's XNotFoundError), and how unparseable candidates appear (id = null, '<failed to parse>' marker).

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 and scope are front-loaded and every clause carries information, but it is delivered as one dense block mixing defaults, failure modes, and error types; light structuring would improve scanability without losing content.

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?

For a 5-parameter read tool with an output schema, the description covers selection criteria, defaults, ranking, exclusion rules, and failure behavior. The return-row description ({type, id, title, status, path, score}) is technically redundant with the output schema but harmless and aids comprehension.

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 0%, so the description must compensate, and it does: top_k default 10 with validation range 1..100, min_score as an inclusive cosine lower bound defaulting to no filter, target_types as an optional restriction, and type/id as the source document identifier. It also clarifies that adr is unreachable via type, information absent from the enum documentation.

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?

States a specific verb ('find') and resource ('documents most semantically related to an existing document') plus the mechanism (cosine similarity of local embeddings). The 'given its type/id' framing distinguishes it from query-text-based tools like find_similar_text, so an agent can route correctly without opening the schema.

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?

Explains the default search scope (all whole-body domains, adr structurally excluded), how to narrow it via target_types, and that the source document is excluded. It does not explicitly name an alternative tool (e.g. find_similar_text) or state when to prefer it, which keeps this short of a 5.

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

Deploy Server

Other Tools