Skip to main content
Glama
alaturqua

MCP Trino Server

by alaturqua

expire_snapshots

Clean up old snapshots from Iceberg tables by defining retention periods to free up storage and improve query performance.

Instructions

Remove old snapshots from an Iceberg table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
catalogYescatalog name
schema_nameYesschema name
retention_thresholdNoAge threshold for snapshot removal (e.g., '7d', '30d')7d
tableYesThe name of the table

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Main implementation of expire_snapshots tool. Contains the function that builds and executes the SQL query 'ALTER TABLE {catalog}.{schema}.{table} EXECUTE expire_snapshots(retention_threshold => ...)' using the Trino client.
    def expire_snapshots(
        self,
        catalog: str,
        table: str,
        schema: str,
        retention_threshold: str = "7d",
    ) -> str:
        """Remove old snapshots from an Iceberg table.
    
        This operation removes snapshots older than the specified retention threshold,
        helping to manage storage and improve performance.
    
        Args:
            table: The name of the table.
            retention_threshold: Age threshold for snapshot removal (e.g., "7d").
            catalog: The catalog name. If None, uses configured default.
            schema: The schema name. If None, uses configured default.
    
        Returns:
            Success message indicating snapshots were expired.
    
        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:
            msg = "Both catalog and schema must be specified"
            raise CatalogSchemaError(msg)
        query = (
            f"ALTER TABLE {catalog}.{schema}.{table} "
            f"EXECUTE expire_snapshots(retention_threshold => '{retention_threshold}')"
        )
        self.execute_query(query)
        return f"Snapshots older than {retention_threshold} expired for table {catalog}.{schema}.{table}"
  • src/server.py:179-199 (registration)
    MCP tool registration for expire_snapshots. Decorated with @mcp.tool(), this function defines the tool's interface with Pydantic Field schemas for parameters (catalog, schema_name, table, retention_threshold) and delegates to the Trino client implementation.
    @mcp.tool(description="Remove old snapshots from an Iceberg table")
    def expire_snapshots(
        catalog: str = Field(description="catalog name "),
        schema_name: str = Field(description="schema name "),
        retention_threshold: str = Field(
            description="Age threshold for snapshot removal (e.g., '7d', '30d')", default="7d"
        ),
        table: str = Field(description="The name of the table"),
    ) -> str:
        """Remove old snapshots from an Iceberg table.
    
        Args:
            catalog: catalog name
            schema_name: schema name
            table: The name of the table
            retention_threshold: Age threshold for snapshot removal (e.g., "7d", "30d")
    
        Returns:
            str: Confirmation message
        """
        return client.expire_snapshots(catalog, schema_name, table, retention_threshold)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Remove' implies destruction, it fails to specify that this operation is irreversible, whether it deletes underlying data files or just metadata, or if it requires specific catalog permissions. This is a significant gap for a destructive maintenance operation.

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?

The description is a single, efficient sentence that is front-loaded with the action. There is no redundant text or filler. However, given the destructive nature of the operation, it may be inappropriately brief rather than truly concise, though the text itself wastes no words.

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 a complete input schema and output schema, the description is inadequate for a destructive maintenance tool. It omits critical safety warnings, irreversibility notices, and behavioral context that annotations would normally provide. For an operation that permanently removes table history, one sentence is insufficiently complete.

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%, documenting all four parameters including the default '7d' value for retention_threshold. The description mentions 'old snapshots' which loosely maps to the retention concept, but adds no syntax details, format examples, or semantic meaning beyond what the schema already provides. Baseline 3 is appropriate.

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 states the action ('Remove') and target ('old snapshots from an Iceberg table'), providing specific verb and resource identification. However, it does not differentiate from sibling maintenance tools like 'optimize' or 'show_snapshots', leaving some ambiguity about when to choose this over similar operations.

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?

The description provides no guidance on when to use this tool versus alternatives, nor does it mention prerequisites (like requiring the table to exist) or warnings about irreversibility. It fails to distinguish snapshot expiration from other table maintenance operations available in the sibling list.

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