Skip to main content
Glama

find_clones

Find duplicate code clones in a codebase, ranked by ROI and filtered by similarity and copy count. Returns refined clone classes with provenance.

Instructions

Ranked candidate clone classes (unrefined; exact overlap metrics). Returns classes sorted by ROI (cross-module spread × member count × token length × load-bearing factor × cohesion), with a completeness provenance block. min_similarity (if set) must be in [0.5, 1.0] (default 0.7). A LIMITED query (limit: N) is capped at the refine budget (currently 50) — it returns at most 50 classes, all refined; pass limit: null/omit it to retrieve all classes (only the top 50 refined). completeness.refine_budget_clamped is true when a supplied limit hit that cap.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of clone classes to return, sorted by ROI descending. A supplied limit is capped at the refine budget (currently 50): `limit: N` returns at most 50 classes, all refined. Omit (null) to retrieve all classes (only the top 50 refined, the rest unrefined).
worktreeNoAbsolute path of the checkout to scope reads to — pass a linked worktree to read its branch overlay. Defaults to the server's working directory. A path that is not a linked worktree of this repo is silently ignored: results then come from the indexed checkout, with no error.
min_copiesNoMinimum number of copies for a class to be returned (defaults to 2).
min_similarityNoMinimum pairwise overlap/max_len similarity. Must be in the range [0.5, 1.0]; defaults to 0.7 (the θ threshold) when omitted. Out-of-range values are rejected.
Behavior4/5

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

With no annotations provided, the description carries the full burden and does well: it discloses the ROI sorting formula, the unrefined-vs-refined semantics, the cap/clamping behavior, the completeness provenance block, and input validation ([0.5,1.0], out-of-range rejection). This is rich behavioral disclosure for a search tool; only missing details like auth or error behavior, which are less critical here.

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 description is a dense paragraph of about 70 words with zero fluff — every sentence earns its place (sorting, provenance, validation, cap behavior). It's front-loaded with the primary purpose. It could benefit from structural separation of the parameter constraints, but the information density is high and well-ordered.

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 tool with 4 well-documented params (100% schema coverage) and no annotations, the description covers the key behavioral gaps: return semantics without an output schema (ROI sort, provenance block, refine budget field). It's reasonably complete for a search tool that requires no parameters and has no output schema — the main omission is explicit differentiation from clones_for_symbol.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already fully documents all four parameters (limit cap, worktree fallback behavior, min_copies default, min_similarity range). The description mostly restates this (limit clamped at 50, min_similarity range/default) while adding only the ROI context and the completeness.refine_budget_clamped field. That's marginal added value over the schema, matching the baseline 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool returns ranked candidate clone classes sorted by ROI, with a completeness provenance block. It's a specific verb+resource (return/find clone classes) with quantifiable scope. It distinguishes implicitly from the sibling clones_for_symbol (global vs per-symbol) but does not name the distinction explicitly, so it falls short of a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives substantial procedural context: the limit cap at 50, the refine budget behavior, and the min_similarity range enforcement. However, it provides no explicit when-to-use vs alternatives guidance, no exclusions, and never contrasts with the obvious sibling clones_for_symbol — so the tool-selection guidance is missing.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cq27-dev/rag-rat'

If you have feedback or need assistance with the MCP directory API, please join our Discord server