Skip to main content
Glama
alaturqua

MCP Trino Server

by alaturqua

optimize

Compact and reorganize Iceberg table data files to improve query performance and storage efficiency. Execute maintenance operations using catalog, schema, and table parameters.

Instructions

Optimize an Iceberg table's data files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
catalogYescatalog name
schema_nameYesschema name
tableYesThe name of the table to optimize

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The actual implementation of the optimize tool. Compacts small files in an Iceberg table by executing 'ALTER TABLE {catalog}.{schema}.{table} EXECUTE optimize' SQL query and returns a success message.
    def optimize(self, catalog: str, schema: str, table: str) -> str:
        """Optimize an Iceberg table by compacting small files.
    
        Args:
            catalog (str): The catalog name. If None, uses configured default.
            schema (str): The schema name. If None, uses configured default.
            table (str): The name of the table to optimize.
    
        Returns:
            str: Success message indicating the table was optimized.
    
        Raises:
            CatalogSchemaError: If either catalog or schema is not specified and not configured.
        """
        catalog = catalog or self.config.catalog
        schema = schema or self.config.schema
        if not catalog or not schema:
            raise CatalogSchemaError
        query = f"ALTER TABLE {catalog}.{schema}.{table} EXECUTE optimize"
        self.execute_query(query)
        return f"Table {catalog}.{schema}.{table} optimized successfully"
  • src/server.py:141-157 (registration)
    MCP tool registration for the 'optimize' tool. Uses @mcp.tool decorator with description, defines parameters using Pydantic Field, and delegates execution to client.optimize().
    @mcp.tool(description="Optimize an Iceberg table's data files")
    def optimize(
        catalog: str = Field(description="catalog name "),
        schema_name: str = Field(description="schema name "),
        table: str = Field(description="The name of the table to optimize"),
    ) -> str:
        """Optimize an Iceberg table by compacting small files.
    
        Args:
            catalog: catalog name
            schema_name: schema name
            table: The name of the table to optimize
    
        Returns:
            str: Confirmation message
        """
        return client.optimize(catalog, schema_name, table)
  • Input schema for the 'optimize' tool. Uses Pydantic Field to define and validate three parameters: catalog, schema_name, and table, each with descriptive help text.
    @mcp.tool(description="Optimize an Iceberg table's data files")
    def optimize(
        catalog: str = Field(description="catalog name "),
        schema_name: str = Field(description="schema name "),
        table: str = Field(description="The name of the table to optimize"),
Behavior2/5

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

With no annotations provided, the description fails to disclose that this is a write operation modifying physical storage, potentially long-running, or idempotent. It doesn't explain that data files will be rewritten/merged, which is critical behavioral context 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.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely concise at six words with no redundancy. While appropriately front-loaded, it borders on underspecification for a maintenance operation with significant side effects. No structural issues, but sacrifices necessary detail for brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite having an output schema (reducing the need to describe return values), the description inadequately covers the behavioral implications of this maintenance operation. It omits critical context about the write nature of the operation and how it differs from other table maintenance tools.

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%, establishing a baseline of 3. The description adds no additional parameter context (e.g., hierarchical relationship between catalog/schema/table), but the schema adequately documents the three required parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly identifies the verb (optimize), resource (Iceberg table), and scope (data files), which distinguishes it from the sibling tool 'optimize_manifests'. However, it lacks specificity on what 'optimize' entails (e.g., compaction, rewriting small files).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance provided on when to use this versus siblings like 'expire_snapshots' or 'optimize_manifests', or prerequisites such as required permissions. The description offers no decision criteria for tool selection.

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/alaturqua/mcp-trino-python'

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