Skip to main content
Glama

Compare two folders function by function

compare_folders
Read-onlyIdempotent

Pairs functions across two folders using an embedding model to identify matching implementations and list unmatched code, returning a JSON report for porting or cross-platform comparison.

Instructions

Compare two folders function by function, in one language or across languages: a port and its original (the source first, the target second), or two implementations of one app (iOS and Android). Every function of one folder is paired with the function of the other that does the same job, by the embedding model, and what has no counterpart is listed. Returns the JSON report of jscpd --compare: 'code' and 'tests' sections, each with 'sides' (per folder: 'functions', 'matched', 'percentage', 'files', 'unmatched', 'readyToPort': unported functions whose callees are all ported) and 'pairs' (each with both functions, 'similarity', 'level' high/medium/low, 'renamed' and 'matchedBy' code or name). Read a few low pairs and the pairs matched by name before relying on them. Needs the embedding model; the first comparison of two folders embeds every function and can take minutes, later ones reuse the cached vectors.

Input Schema

NameRequiredDescriptionDefault
leftYesThe first folder (or file): the source of a port, or one of two implementations. It must lie inside the scanned folders: give it relative to one of them, or absolute.
limitNoMaximum number of entries of each list ('pairs', 'unmatched', 'readyToPort', 'files') in the response. 'functions' always carries the full count, so a small limit still tells you how much was found.
rightYesThe second folder (or file): the target of a port, or the other implementation. It must lie inside the scanned folders too, and must not contain the first or lie inside it.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv5.4.2

TDQS

A4.6/5.0
Behavior5/5

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

Beyond the readOnly/idempotent annotations, the description discloses the operational cost ('needs the embedding model', 'the first comparison ... can take minutes, later ones reuse the cached vectors') and describes the full returned report. It also flags correctness risk by warning that name-matched and low-level pairs should be spot-checked, which the annotations cannot convey.

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?

It is front-loaded with purpose and argument ordering and every sentence carries information. The long parenthetical enumeration of returned sections is dense but justified because no output schema exists, though it could be tightened.

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?

With no output schema, the description fully carries the return-value burden: it names the 'code'/'tests' sections, the per-side fields including 'readyToPort', and the 'pairs' fields including 'similarity', 'level', 'renamed' and 'matchedBy'. Combined with model requirements and caching behavior, an agent has what it needs to call this correctly.

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 already 100%, so the baseline is 3, but the description adds the semantic ordering rule (left is the source, right the target) and implies the left/right containment constraint the schema also states. The 'limit' parameter's truncation behavior is left entirely to the schema, so it isn't a full 5.

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 gives a specific verb and resource — compare two folders function by function — and immediately names the two scenarios it serves (a port and its original, or two implementations of one app such as iOS and Android). That is enough to distinguish it from the sibling tools get_statistics, check_duplication and get_file_clones, which operate on duplication statistics or clone lists rather than cross-folder function pairing.

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?

It spells out both intended scenarios and the argument ordering (source first, target second), and it adds a concrete interpretation rule: read a few low-similarity pairs and the pairs matched by name before relying on them. It never explicitly states when not to use it or names a sibling as the alternative for plain clone or duplication queries, so a 4 rather than a 5.

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