Skip to main content
Glama

topos_refactor

Read-onlyIdempotent

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.

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

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. Changed2 schema fields changedv0.11.0
    • addedInput schema / properties / gitnexus_dir / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • removedInput schema / properties / gitnexus_dir / type
      Removed value: -[
      -  "string",
      -  "null"
      -]
  2. 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`)."
  3. 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"
      +]
  4. 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 declare readOnlyHint, idempotentHint, destructiveHint=false, and openWorldHint=false, so safety is covered. The description adds genuinely useful context beyond that: the advisory (non-scoring) nature and the `.gitnexus` prerequisite for two of three engines, though it says nothing about cost, rate limits, or failure modes when the prerequisite is absent.

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-loaded with the core action, then alternatives, then engine selection, then return shape — a logical order. It is dense with backticks and parentheticals but every sentence carries information; only the engine descriptions slightly duplicate the schema.

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 helpfully describes the return shape (RefactorResult with ranked hotspots containing kind, label, score, suggestion, optional lines). Combined with prerequisite notes and sibling routing, an agent has everything needed to call it correctly.

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% and the enum `$defs` already document each target engine in detail. The description largely paraphrases those same engine meanings ('cycles (CFG loop/branch bodies)', 'dependencies (MDG Forman curvature...)'), adding little beyond what the schema provides, so the baseline 3 applies.

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 ('Rank structural refactor hotspots for one file') plus scope ('read-only, advisory'). It explicitly names what it is NOT, routing agents to `topos_evaluate_*` and `topos_assess_*`, so it is distinguishable from siblings without opening schemas.

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?

Gives explicit when/when-not: use topos_evaluate_* for pillar scoring and topos_assess_* to verify edits afterward, implying refactor is the pre-edit step. It also states per-target prerequisites ('needs `.gitnexus`' for dependencies and process), which is actionable routing guidance.

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