Skip to main content
Glama

optimize_table

Destructive

Rebuild MySQL or MariaDB tables to reclaim free space and reduce fragmentation. Preview with dry_run=True; prior size and fragmentation stats are recorded for audit.

Instructions

[WRITE][risk=medium] OPTIMIZE TABLE (rebuild, reclaim data_free). Records prior stats.

No undo (a rebuild has no inverse); the prior size/fragmentation stats are captured for the audit trail. InnoDB maps this to ALTER TABLE ... FORCE (online DDL, brief locks) — schedule off-peak for hot tables. Pass dry_run=True to preview.

Args: table: Table name (optionally schema-qualified, e.g. shop.orders). dry_run: If True, preview without running. target: Target name from config; omit for the default.

Input Schema

NameRequiredDescriptionDefault
tableYes
targetNo
dry_runNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.5.0

TDQS

A4.6/5.0
Behavior5/5

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

Goes well beyond the annotations by disclosing that there is no undo, that prior size/fragmentation stats are captured for the audit trail, the underlying InnoDB ALTER TABLE ... FORCE mapping, brief lock behavior, and the dry_run preview path. This is exactly the behavioral context a mutating tool needs.

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 tag and one-line purpose, then operational caveats, then args. The Args block mostly restates what the schema shows, which slightly dilutes density, but the added notes (config target, schema-qualified example) earn their 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?

No output schema exists, so the description should ideally say what the call returns; it only mentions that prior stats are recorded, not the result shape of the operation. Otherwise the safety, scheduling, and parameter picture is complete for a 3-param mutating tool.

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 description coverage is 0%, so the description carries the full burden and does it: it explains schema-qualified table naming with an example (shop.orders), the preview semantics of dry_run, and that target comes from config and defaults when omitted. All three parameters gain meaning beyond their bare titles.

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 (OPTIMIZE), the resource (TABLE), and the intent (rebuild, reclaim data_free), plus a severity tag. Sibling analysis tools like table_fragmentation and fragmentation_analysis are clearly distinguished from this mutating operation.

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?

Gives real operational context: schedule off-peak for hot tables, use dry_run=True to preview, and it warns there is no undo. It stops short of explicitly naming the sibling analysis tools (e.g. check table_fragmentation first) that would be the natural 'when-to' pre-step, so no explicit alternatives are given.

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