Skip to main content
Glama

Find documents similar to text

find_similar_text

Find documents semantically similar to a free-form query for pre-creation deduplication and discovery checks, ranked by cosine similarity of local sentence embeddings.

Instructions

Find the documents most semantically similar to a free-form query text (for pre-creation dedup/discovery checks), 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. 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 target_types/top_k is a ValueError before any filesystem access.

Input Schema

NameRequiredDescriptionDefault
queryYes
top_kNo
min_scoreNo
target_typesNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.38.0
    • 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: default domain coverage with adr structurally excluded, ranking and sort order, top_k range validation, min_score as an inclusive cosine bound, degraded-mode behavior ({available:false, reason, message}) when embeddings are unavailable, and that invalid args raise ValueError before any filesystem access. This is unusually complete behavioral disclosure for a read tool.

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 before the mechanics, and every clause carries information. It is still a single dense paragraph with heavy parenthetical nesting, which costs some scannability against an ideal structured layout.

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 4-parameter read tool with an output schema, the definition covers invocation semantics, ranking, filtering, edge-case rows (id=null for unparseable candidates) and failure modes. Even the return-row shape is summarized, leaving no gap an agent would need before calling it correctly.

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 description coverage is 0%, so the description must compensate, and it does: it defines query as free-form text, top_k's default 10 and validated 1..100 range, min_score's default (no filter) and inclusive lower-bound meaning, and target_types' restriction role against the full default domain list. Every parameter gains meaning beyond the bare schema.

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 similar to a free-form query), plus the mechanism (cosine similarity of local sentence embeddings) and the intended purpose (pre-creation dedup/discovery). An agent can distinguish this semantic-similarity search from keyword/metadata lookups like list_* or get_* 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?

Explicitly scopes usage to 'pre-creation dedup/discovery checks', which tells the agent when this tool is the right choice. It does not name a specific alternative (e.g. find_related) or state when-not to use it, so it falls short of the top band.

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