Skip to main content
Glama
dfine-io

dfine-semantic

Official
by dfine-io

Find duplicate code

find_duplicates
Read-onlyIdempotent

Find near-duplicate code across files by passing files or line ranges, returning candidate matches for review and refactoring.

Instructions

List code in other files that nearly matches the given files or line ranges. Use it in reviews and refactors - pass changed line ranges ("src/a.ts:10-40") for sharper pairs. Treat every pair as a candidate - read both ranges before you call it a duplicate. Expect it to be off per project - ask the user before you turn it on. Turn it on with index_project duplicates: true - the first build can take over an hour on large projects. Covers .ts, .tsx, .js, .jsx, .mjs files; skips tests, specs and .d.ts files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoAbsolute project root - omit to use the working directory
filesYesRoot-relative or absolute paths, optionally with lines: "src/a.ts:10-40"
limitNoMax pairs per file
excludeNoRoot-relative or absolute folders or files to leave out, e.g. ["src/generated"]
thresholdNoMin similarity - raise to 0.92 for fewer false pairs, lower for more recall

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
notesYesSync notes, why a file or exclude entry has no pairs, and how to read the pairs
pairsYesCandidates, best first per file
statusYes"off": duplicate search is not enabled for this project, which is not the same as no duplicates

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.4

TDQS

A4.3/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, and openWorldHint=false, so the safety profile is covered structurally. The description adds real operational context beyond that: first build latency ('can take over an hour on large projects'), the per-project off-by-default behavior, coverage of .ts/.tsx/.js/.jsx/.mjs and skipping of tests/specs/.d.ts, and the 'treat every pair as a candidate' caveat. It does not disclose the result/pair shape, but with an output schema present that is acceptable.

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?

Front-loads the core behavior in the first sentence and then layers usage, prerequisites, and caveats compactly. The dash-separated clauses are dense but each carries actionable information; minor tightening is possible but nothing is padding.

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?

Given five parameters, full schema coverage, an output schema, and annotations, the description supplies the missing operational layer: enabling prerequisite, cost warning, file-type scope, and false-positive caveat. It omits only return-shape details, which the output schema already covers.

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 description coverage is 100%, so the baseline is 3. The description goes further by giving a concrete line-range syntax example ('src/a.ts:10-40') and explaining the intent behind line-range inputs (sharper pairs), which the schema does not convey, plus threshold-like tuning guidance ('raise to fewer false pairs').

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 and resource ('List code in other files that nearly matches the given files or line ranges'), and narrows scope to a near-match similarity search rather than general search. It also names the sibling index_project as the enabling mechanism, so an agent can distinguish it from semantic_search.

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?

Explicitly tells the agent when to use it ('in reviews and refactors'), how to sharpen results (pass changed line ranges), when to ask the user before enabling ('ask the user before you turn it on'), and names the prerequisite (index_project duplicates: true). Both when-to-use and gating conditions are covered.

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