Skip to main content
Glama

organize_imports

Tidy Python import blocks: sort, deduplicate, remove unused imports, expand star imports, convert relative to absolute, and shorten deep paths. Dry-run preview by default, apply to write changes.

Instructions

Tidy a module's import block structurally (not formatting — black/ruff own that). Pass the file alone; no Position. One mode per call: 'organize' (default) sorts, deduplicates, and drops unused imports; 'expand_star_imports' replaces from m import * with explicit names (follow with 'organize' to prune unused ones); 'relatives_to_absolutes' rewrites relative imports as absolute; 'froms_to_imports' converts from-imports to plain imports; 'handle_long_imports' shortens deep module paths. Defaults to a Dry Run preview; set apply=true to write. An empty blast_radius means the module already conforms.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYes
modeNoorganize
rootNo
applyNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

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

With no annotations, the description carries full burden and does so thoroughly: it discloses the dry-run default, the apply=true write behavior, the meaning of an empty blast_radius, and per-mode effects including destructive actions like 'drops unused imports'. This is strong transparency for a mutation tool.

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?

Five sentences pack a wealth of information with no fluff. It front-loads the primary purpose, then clearly enumerates modes, defaults, and result interpretation. The structure is logical and every sentence earns its place.

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?

For a multi-mode refactoring tool, the description covers purpose, usage constraints, mode behaviors, and result semantics. The presence of an output schema removes the need to describe return values. The only notable gap is the undocumented 'root' parameter, which prevents a perfect score.

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

Parameters4/5

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

Despite 0% schema description coverage, the description adds rich semantics for the 'mode' parameter (explaining all possible values in detail) and for 'apply' (default false = dry run). It also implies 'file' is the only required argument. However, the optional 'root' parameter is never explained.

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+resource pair ('Tidy a module's import block') and further distinguishes itself from sibling refactoring tools by clearly focusing on import organization rather than general code restructuring. It also explicitly excludes formatting, clarifying the tool's exact scope.

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?

Provides concrete usage constraints: 'Pass the file alone; no Position' and 'One mode per call'. It also gives sequential guidance for expand_star_imports ('follow with organize'). The exclusion of formatting ('black/ruff own that') is an explicit when-not, though it doesn't name alternative sibling tools.

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/andrewesweet/ropey'

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