Skip to main content
Glama

topos_refactor

Read-onlyIdempotent

Rank structural refactor hotspots in a single file by cyclomatic complexity, dependency curvature, or process choke points, returning scored suggestions to guide targeted improvements.

Instructions

Rank structural refactor hotspots for one file (read-only, advisory). Does not score the four pillars — use topos_evaluate_* for medals and topos_assess_* to verify edits afterward. target selects the engine: cycles (CFG loop/branch bodies), dependencies (MDG Forman curvature on imports; needs .gitnexus), or process (execution choke points; needs .gitnexus). Returns a RefactorResult with ranked hotspots (kind, label, score, suggestion, optional lines).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum hotspots to return (default 5).
targetYesWhich analysis engine to run: `cycles` (CFG), or `dependencies` / `process` (need `.gitnexus`).
filepathYesSource file path relative to the MCP file root.
gitnexus_dirNoOverride `.gitnexus` directory (`dependencies` / `process` targets).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.6.0
    • changedInput schema / $defs / RefactorTargetKind / oneOf
      Previous value: -[
      -  {
      -    "const": "cycles",
      -    "description": "CFG cycle-basis: loop/branch bodies driving cyclomatic complexity.",
      -    "type": "string"
      -  },
      -  {
      -    "const": "dependencies",
      -    "description": "MDG Forman curvature: load-bearing import edges (needs `.gitnexus`).",
      -    "type": "string"
      -  },
      -  {
      -    "const": "process",
      -    "description": "Process-graph choke points (needs `.gitnexus`).",
      -    "type": "string"
      -  },
      -  {
      -    "const": "graphify",
      -    "description": "Graphify orphan nodes / fragile inferred edges.",
      -    "type": "string"
      -  }
      -]New value: +[
      +  {
      +    "const": "cycles",
      +    "description": "CFG cycle-basis: loop/branch bodies driving cyclomatic complexity.",
      +    "type": "string"
      +  },
      +  {
      +    "const": "dependencies",
      +    "description": "MDG Forman curvature: load-bearing import edges (needs `.gitnexus`).",
      +    "type": "string"
      +  },
      +  {
      +    "const": "process",
      +    "description": "Process-graph choke points (needs `.gitnexus`).",
      +    "type": "string"
      +  }
      +]
    • removedInput schema / properties / graphify_dir
      Removed value: -{
      -  "default": null,
      -  "description": "Override Graphify output directory (`target=graphify` only).",
      -  "type": [
      -    "string",
      -    "null"
      -  ]
      -}
    • changedInput schema / properties / target / description
      Previous value: -"Which analysis engine to run: `cycles` (CFG), `dependencies` /\n`process` (need `.gitnexus`), or `graphify` (need Graphify graph)."New value: +"Which analysis engine to run: `cycles` (CFG), or `dependencies` /\n`process` (need `.gitnexus`)."
  2. Changed9 schema fields changedv0.4.0
    • addedInput schema / $defs
      Added value: +{
      +  "RefactorTargetKind": {
      +    "description": "Engine selector for `topos_refactor`.",
      +    "oneOf": [
      +      {
      +        "const": "cycles",
      +        "description": "CFG cycle-basis: loop/branch bodies driving cyclomatic complexity.",
      +        "type": "string"
      +      },
      +      {
      +        "const": "dependencies",
      +        "description": "MDG Forman curvature: load-bearing import edges (needs `.gitnexus`).",
      +        "type": "string"
      +      },
      +      {
      +        "const": "process",
      +        "description": "Process-graph choke points (needs `.gitnexus`).",
      +        "type": "string"
      +      },
      +      {
      +        "const": "graphify",
      +        "description": "Graphify orphan nodes / fragile inferred edges.",
      +        "type": "string"
      +      }
      +    ]
      +  }
      +}
    • addedInput schema / $schema
      Added value: +"https://json-schema.org/draft/2020-12/schema"
    • addedInput schema / properties / filepath
      Added value: +{
      +  "description": "Source file path relative to the MCP file root.",
      +  "type": "string"
      +}
    • addedInput schema / properties / gitnexus_dir
      Added value: +{
      +  "default": null,
      +  "description": "Override `.gitnexus` directory (`dependencies` / `process` targets).",
      +  "type": [
      +    "string",
      +    "null"
      +  ]
      +}
    • addedInput schema / properties / graphify_dir
      Added value: +{
      +  "default": null,
      +  "description": "Override Graphify output directory (`target=graphify` only).",
      +  "type": [
      +    "string",
      +    "null"
      +  ]
      +}
    • addedInput schema / properties / limit
      Added value: +{
      +  "default": 5,
      +  "description": "Maximum hotspots to return (default 5).",
      +  "format": "uint",
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • removedInput schema / properties / params
      Removed value: -{
      -  "additionalProperties": false,
      -  "properties": {
      -    "filepath": {
      -      "minLength": 1,
      -      "type": "string"
      -    },
      -    "gitnexus_dir": {
      -      "anyOf": [
      -        {
      -          "type": "string"
      -        },
      -        {
      -          "type": "null"
      -        }
      -      ],
      -      "default": null
      -    },
      -    "limit": {
      -      "default": 5,
      -      "maximum": 50,
      -      "minimum": 1,
      -      "type": "integer"
      -    },
      -    "target": {
      -      "enum": [
      -        "cycles",
      -        "dependencies",
      -        "process"
      -      ],
      -      "type": "string"
      -    }
      -  },
      -  "required": [
      -    "target",
      -    "filepath"
      -  ],
      -  "type": "object"
      -}
    • addedInput schema / properties / target
      Added value: +{
      +  "$ref": "#/$defs/RefactorTargetKind",
      +  "description": "Which analysis engine to run: `cycles` (CFG), `dependencies` /\n`process` (need `.gitnexus`), or `graphify` (need Graphify graph)."
      +}
    • changedInput schema / required
      Previous value: -[
      -  "params"
      -]New value: +[
      +  "target",
      +  "filepath"
      +]
  3. Addedv0.3.11

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already cover the read-only, idempotent, non-destructive profile, and the description reinforces that with "read-only, advisory." It adds meaningful context beyond annotations by disclosing that `dependencies` and `process` require `.gitnexus`, and by describing the RefactorResult shape with ranked hotspots.

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 compact and front-loaded with the core purpose. Every sentence serves a distinct role: purpose, exclusions, target selector, and return shape. Minor redundancy exists because "read-only, advisory" restates annotations and the target details repeat schema enum text, but this does not materially hurt usability.

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 compensates by specifying the return structure: "RefactorResult with ranked `hotspots` (`kind`, `label`, `score`, `suggestion`, optional lines)." It also covers prerequisites and alternatives, making the tool callable correctly with the information provided.

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 description coverage is 100%, so the schema already documents `target`, `filepath`, `limit`, and `gitnexus_dir`. The description enriches `target` by explaining engine semantics, but these largely mirror the schema's own enum descriptions. No additional meaning is added for `filepath`, `limit`, or `gitnexus_dir`.

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 specific verb and resource: "Rank structural refactor hotspots for one file." It immediately distinguishes itself from evaluation and assessment siblings by saying "Does not score the four pillars." This leaves little ambiguity about what the tool is for.

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?

It explicitly routes the agent away from this tool for pillar scoring and verification: "use `topos_evaluate_*` for medals and `topos_assess_*` to verify edits afterward." It also gives target-specific guidance, including the `.gitnexus` prerequisite for `dependencies` and `process` engines.

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