Skip to main content
Glama

suggest_refactoring

Read-onlyIdempotent

WHEN: developer wants to improve code quality before a PR merge or code review. Triggers: 'refactor', 'clean up', 'simplify', 'too long method', 'nested ifs', 'code smells', 'améliorer le code'. Suggest concrete refactoring actions for YOUR custom D365 F&O X++ code. [!] Only runs on custom/extension code (D365_CUSTOM_MODEL_PATH). Refactoring standard Microsoft code is not actionable. Analyzes: long methods (extract method), deep nesting (guard clauses), row-by-row operations (set-based), large switch statements (strategy pattern), hardcoded strings (constants), unprotected CLR calls (error handling), wide transactions (narrow scope). Returns before/after code examples.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodNameNoOptional: specific method to analyze.
objectNameYesObject name to analyze, e.g. 'ALMMyClass', 'ALMMyTable'

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / objectName / description
      Previous value: -"Object name to analyze, e.g. 'HSOMyClass', 'HSOMyTable'"New value: +"Object name to analyze, e.g. 'ALMMyClass', 'ALMMyTable'"
  2. First observed

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already signal readOnly, idempotent, non-destructive; the description goes beyond by stating the scope constraint (custom/extension code only, D365_CUSTOM_MODEL_PATH) and the exact analysis capabilities (e.g., long methods → extract method, nested ifs → guard clauses). It also discloses the return format ('before/after code examples'), which the schema does not. No contradiction with annotations.

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?

The description is two sentences plus a compact list; the WHEN and TRIGGERS are front-loaded, and each listed pattern maps to a concrete refactoring suggestion. No filler or repeated schema content.

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?

The tool has only 2 parameters and no output schema, but the description tells an agent what triggers it, what code it operates on, what patterns it finds, and what the result looks like (before/after examples). That is enough for an agent to invoke it and interpret the response.

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?

The schema covers both parameters with descriptions (100% coverage), so the description does not need to repeat them. The description adds general context that objectName refers to a custom D365 F&O object and methodName is optional for focusing the analysis, but it does not add parameter-specific syntax or format details beyond the schema. Baseline 3 is appropriate.

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 uses a specific verb ('Suggest') and resource ('custom D365 F&O X++ code'), states it returns before/after examples, and enumerates the refactoring patterns it analyzes (long methods, deep nesting, etc.). It is clearly distinct from siblings like fix_best_practice_violations or detect_performance_issues because it focuses on refactoring suggestions with code examples rather than compliance or performance diagnosis.

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?

The description explicitly states 'WHEN' and lists natural-language triggers ('refactor', 'clean up', 'simplify', 'code smells', 'améliorer le code') that an agent can match. It also states a critical exclusion: only custom/extension code is supported, and refactoring standard Microsoft code is 'not actionable.' This gives clear go/no-go context.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.