Skip to main content
Glama

analyze_code

Read-onlyIdempotent

Analyzes code to detect smells like long methods and large classes, then suggests refactorings to address them.

Instructions

Analyze code for smells and suggest refactorings.

Detects code smells like long methods, large classes, feature envy, and suggests appropriate refactorings to address them.

Note: This feature requires backend support. Returns backend_supported: false for backends that don't implement analysis yet.

Args: path: File or directory path to analyze smells: Optional list of smell types to check for (e.g., ['long-method', 'large-class', 'feature-envy'])

Returns: TOON-formatted string with analysis results.

Supported smell types (when backend supports analysis): - long-method: Method exceeds line threshold - large-class: Class has too many responsibilities - feature-envy: Method uses another class's data excessively - data-clumps: Same data items appear together repeatedly - primitive-obsession: Overuse of primitives instead of objects - duplicate-code: Similar code in multiple locations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
smellsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

Annotations already declare readOnlyHint=true. The description adds that it returns a TOON-formatted string and requires backend support, which is useful beyond 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?

Concise at ~250 characters, well-structured with clear sections (purpose, args, returns, supported types), no wasted words.

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?

Given the simple tool with two parameters and an output schema, the description covers purpose, parameters, backend dependency, return format, and allowed values completely.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 0% description coverage, but the description fully explains both parameters (path, smells), provides examples, and lists all supported smell types.

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 clearly states the tool analyzes code for smells and suggests refactorings, listing specific smells. It distinguishes from sibling tools like apply_refactoring and preview_refactoring, which apply changes.

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 mentions backend support requirement and provides optional smell filtering, but does not explicitly state when to use this tool over alternatives like inspect_structure.

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/marshally/mcp-refactoring'

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