Skip to main content
Glama

Near-duplicate function pairs

list_duplicate_functions
Read-onlyIdempotent

Identify near-duplicate function pairs in your repo before a refactor. Uses containment similarity to surface up to 50 twins, skipping small and same-file functions.

Instructions

Lists near-duplicate function pairs in the newest run, at most 50. Use it before a refactor so twins are folded together, and get_function_brief for one function's twins. It shingles source on every call, seconds on a large repo, skips functions under 8 lines and same-file pairs, and an empty list means no pair reached similarity. similarity is shared shingles over the smaller function: 1.0 admits only a function found whole inside another, 0.8 four lines in five, and repo may be any directory under the checkout.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repoNopath to the scored repo's root (default: the repo the server was started in)
similarityNocontainment threshold, shared over smaller, 0 to 1 (default 0.8)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
pairsNopairs at or above similarity, best containment first, at most 50
run_idNothe newest run whose rows were compared
schemaNopayload schema version, 1

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.6.0

TDQS

A5/5.0
Behavior5/5

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

Annotations already declare readOnly, idempotent, and non-destructive behavior. The description adds valuable runtime context: it shingles on every call, takes seconds on large repos, skips short and same-file functions, and explains that an empty list means no pair met the threshold. This goes well beyond the structured annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is dense but every clause earns its place: result scope, usage context, performance, filtering rules, empty-result meaning, threshold semantics, and repo scope. It front-loads the core purpose before diving into details.

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?

The description covers what the tool returns, the limit, empty-result meaning, performance expectations, filtering behavior, parameter semantics, and when to use it. With a rich output schema and annotations present, no critical context is missing for an agent to invoke this tool 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?

Even though schema coverage is 100%, the description adds meaningful interpretation: similarity is shared shingles over the smaller function, with 1.0 and 0.8 explained through concrete examples. It also clarifies that repo may be any directory under the checkout, going beyond the schema's generic path description.

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 precise verb and resource: 'Lists near-duplicate function pairs in the newest run, at most 50.' It clearly distinguishes this from siblings like get_function_brief by focusing on pair-level duplication in the newest run.

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?

The description explicitly says to use it before a refactor and points to get_function_brief as the alternative when only one function's twins are needed. This gives the agent both a trigger condition and a routing decision.

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