Skip to main content
Glama

Topos Structural Comparison

topos_compare_code
Read-onlyIdempotent

Compute the AST tree-edit distance between two code snippets for clone detection or refactoring impact measurement.

Instructions

Compute the AST (tree-edit) distance between two source-code strings.

Read-only and idempotent; parses both snippets in memory, never writes or scores. Use for clone detection or to measure refactor impact; the topos_assess_* tools already fold this in as an anti-gaming check, so call it directly only for the raw number. Returns a ComparisonResult: normalized_distance in [0, 1], similarity (= 1 - it), raw_distance, an operations edit-count map, and source_valid/target_valid (error set if either fails to parse).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYesArguments for ``topos_compare_code``.
Behavior5/5

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

Adds context beyond annotations: 'Read-only and idempotent; parses both snippets in memory, never writes or scores.' Fully consistent with idempotentHint and readOnlyHint. No contradiction.

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?

Two sentences in the first paragraph state core purpose; second paragraph adds return details. No redundant information. Efficient and front-loaded.

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?

Covers purpose, usage, behavior, and return structure. Lacks discussion of error handling or large-code performance, but adequate given schema coverage and annotations.

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 baseline is 3. The description does not repeat parameter details but adds value by explaining the return structure (ComparisonResult fields). This helps semantic understanding indirectly.

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 specifies a clear verb+resource: 'Compute the AST (tree-edit) distance between two source-code strings.' It distinguishes itself from siblings like 'topos_compare_files' and notes that the 'topos_assess_*' tools already incorporate this.

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?

Explicitly states when to use (clone detection, refactor impact) and when not to use directly (the assess tools already fold it in). Could be slightly more precise about exclusions, but clear enough.

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/Krv-Labs/topos'

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