Skip to main content
Glama

Find similar functions

find_similar
Read-onlyIdempotent

Find functions that already do what you are about to write, and places this project has built the same thing twice. Pass functions with one entry per new or edited function (name and file when it is already indexed, one plain sentence when it is not) and each entry comes back with the closest functions in other files. Pass audit: true instead, with no functions, for a whole-project audit that groups the functions describing the same behaviour. A call with neither, or with both, is refused. Matching reads how the index describes a function rather than its body, and every row carries the file and line span of the function it names. For one concept rather than a set of functions, use search_by_intent.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "find_similar"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathNoAudit only: compare the functions under this repo-relative directory or file prefix, matched on whole segments (`lib` covers `lib/a.ts`, never `library/a.ts`). In a monorepo the service's directory is part of the path.
repoNoYour repo as owner/repo (git remote) or just the repo name. Resolves which Carrick project to query.
auditNoRun the whole-project audit: groups of functions that describe the same behaviour. Pass it instead of `functions`; one of the two is required.
limitNoCeiling on groups per page in the audit mode (default 20, max 50). A page is cut to what one response holds, so it can come back shorter; `clusters_note` states what this page holds and `next_offset` continues it.
top_kNoMatches per entry in the targeted mode (default 5).
offsetNoGroups to skip in the audit mode (default 0). Pass the `next_offset` from a previous call to page through.
projectNoCarrick project slug to query. Omit to auto-resolve via `repo`, or omit both when the workspace has one project.
serviceNoAn audit compares only this service. A targeted call lists this service's functions in `matches` and counts and names the matches in other services in `outside_service` (fuzzy match by service name, repo name, or trailing segment).
functionsNoOne entry per function to check, up to 20 in a call. Do not combine with `audit`.
min_linesNoShortest function to compare (audit default 3, targeted default 1). One-line and two-line wrappers carry no behaviour to reuse; the response says how many rows this hid.
scan_fromNoAudit only: where the next window starts. An audit larger than one call compares the functions in windows and each answer names its `window`; pass its `next_scan_from` to continue.
include_testsNoInclude test files, which repeat each other by design (default false).
include_callbacksNoInclude the anonymous callbacks the scan indexed, such as a `map_handler` row (default false). They cannot be imported, so a group of them is not a reuse finding.
include_generatedNoInclude generated and bundled files (default false).
similarity_thresholdNoFloor for a match. Defaults to 0.85 between two indexed functions and 0.45 for a `description`, which are different scales: one side is a stored vector and the other a sentence embedded on the spot. The answer carries `vector_basis` for which stored vectors it compared, and its hint says what that basis means for a renamed copy.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • changedInput schema / properties / functions / items / properties / description / description
      Previous value: -"One plain sentence describing a function that is not indexed yet, such as one you are about to write. Use this instead of name and file, not as well as."New value: +"One plain sentence describing a function that is not indexed yet, such as one you are about to write. Use this instead of `name`; a `file` beside it names your own file, which is left out of the answer."
    • changedInput schema / properties / service / description
      Previous value: -"Limit the comparison to one service (fuzzy match by service name, repo name, or trailing segment)."New value: +"An audit compares only this service. A targeted call lists this service's functions in `matches` and counts and names the matches in other services in `outside_service` (fuzzy match by service name, repo name, or trailing segment)."
  2. Changed3 schema fields changed
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties / audit
      Added value: +{
      +  "description": "Run the whole-project audit: groups of functions that describe the same behaviour. Pass it instead of `functions`; one of the two is required.",
      +  "type": "boolean"
      +}
    • changedInput schema / properties / functions / description
      Previous value: -"One entry per function to check, up to 20 in a call. Omit for a whole-project audit."New value: +"One entry per function to check, up to 20 in a call. Do not combine with `audit`."
  3. Changed3 schema fields changed
    • addedInput schema / properties / path
      Added value: +{
      +  "description": "Audit only: compare the functions under this repo-relative directory or file prefix, matched on whole segments (`lib` covers `lib/a.ts`, never `library/a.ts`). In a monorepo the service's directory is part of the path.",
      +  "type": "string"
      +}
    • addedInput schema / properties / scan_from
      Added value: +{
      +  "description": "Audit only: where the next window starts. An audit larger than one call compares the functions in windows and each answer names its `window`; pass its `next_scan_from` to continue.",
      +  "maximum": 9007199254740991,
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • changedInput schema / properties / service / description
      Previous value: -"Limit the comparison to one service (fuzzy match by service name, repo name, or trailing segment). Use it when an audit reports more functions than one pass compares."New value: +"Limit the comparison to one service (fuzzy match by service name, repo name, or trailing segment)."
  4. First observed

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already cover safety (readOnly, idempotent, non-destructive, closed-world), yet the description adds real behavioural context: matching reads the index's description of a function rather than its body, every row carries a file and line span, and invalid mode combinations are rejected. It stops short of describing ranking or what a 'cluster' looks like, so it is strong rather than complete.

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?

The single paragraph is front-loaded with purpose, then mode selection, then refusal rules, then a pointer to the alternative — a sensible order with no filler sentences. It is dense enough that the mode-selection rules compete for attention with the parameter guidance, which keeps it from a 5.

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?

For a 15-parameter tool with no output schema, the description covers the essential contract: two mutually exclusive modes, what each entry returns, the refused shapes, and where results come from. Pagination and response envelope fields (`clusters_note`, `next_offset`, `window`) are only described in the schema, so the description alone does not fully sketch a return value.

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 baseline is 3, and the description still adds meaning above it: it explains that `functions` entries take a name plus file when indexed or a plain sentence when not, that `file` beside a description names your own file (excluded from results), and that the two similarity_threshold defaults are on different scales. The remaining parameters are left entirely to the 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?

The description names a concrete verb and resource ('Find functions that already do what you are about to write') plus the duplicate-detection angle, so an agent knows exactly what comes back. It also explicitly separates the targeted mode from the audit mode and from the sibling search_by_intent, which no schema field does.

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?

It spells out the selection rule precisely: pass `functions` for new/edited functions, pass `audit: true` with no `functions` for a whole-project audit, and a call with neither or both is refused. It also routes the agent elsewhere for a single concept ('use search_by_intent'), which is exactly the when-to-use-alternative guidance this dimension rewards.

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.