show_refs
List branches and tags for Iceberg tables to track versions, manage snapshots, and maintain data lineage in Trino.
Instructions
Show Iceberg table references (branches and tags)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| catalog | Yes | catalog name | |
| schema_name | Yes | schema name | |
| table | Yes | The name of the table |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/server.py:468-492 (handler)MCP tool handler for 'show_refs'. Decorated with @mcp.tool(), this function receives the tool call, validates inputs using Pydantic Fields, and delegates to the Trino client. Returns JSON-formatted table references.
@mcp.tool(description="Show Iceberg table references (branches and tags)") def show_refs( catalog: str = Field(description="catalog name "), schema_name: str = Field(description="schema name "), table: str = Field(description="The name of the table"), ) -> str: """Show Iceberg table references (branches and tags). The refs table contains: - name: Name of the reference - type: Type of reference (BRANCH or TAG) - snapshot_id: ID of referenced snapshot - max_reference_age_in_ms: Max age before reference expiry - min_snapshots_to_keep: Min snapshots to keep (branches only) - max_snapshot_age_in_ms: Max snapshot age in branch Args: catalog: catalog name schema_name: schema name table: The name of the table Returns: str: JSON-formatted table references """ return client.show_refs(catalog, schema_name, table) - src/trino_client.py:571-596 (helper)Core implementation of show_refs in the TrinoClient class. Constructs and executes a SQL query against Trino's Iceberg $refs metadata table. Handles default catalog/schema resolution and returns JSON-formatted results.
def show_refs(self, table: str, catalog: str, schema: str) -> str: """Show Iceberg table references (branches and tags). The refs table contains: - name: VARCHAR - Name of the reference - type: VARCHAR - Type of reference (BRANCH or TAG) - snapshot_id: BIGINT - ID of referenced snapshot - max_reference_age_in_ms: BIGINT - Max age before reference expiry - min_snapshots_to_keep: INTEGER - Min snapshots to keep (branches only) - max_snapshot_age_in_ms: BIGINT - Max snapshot age in branch Args: table: The name of the table catalog: Optional catalog name (defaults to configured catalog) schema: Optional schema name (defaults to configured schema) Returns: str: JSON-formatted string containing table references """ catalog = catalog or self.config.catalog schema = schema or self.config.schema if not catalog or not schema: raise CatalogSchemaError table_identifier = f"{catalog}.{schema}.{table}$refs" query = 'SELECT * FROM "{}"' return self.execute_query(query.format(table_identifier)) - src/server.py:468-473 (schema)Input schema definition for show_refs tool using Pydantic Field. Defines three string parameters: catalog, schema_name, and table with descriptive metadata for MCP tool discovery.
@mcp.tool(description="Show Iceberg table references (branches and tags)") def show_refs( catalog: str = Field(description="catalog name "), schema_name: str = Field(description="schema name "), table: str = Field(description="The name of the table"), ) -> str: - src/server.py:468-468 (registration)MCP tool registration point. The @mcp.tool() decorator registers show_refs with the FastMCP server, making it discoverable and callable via the Model Context Protocol.
@mcp.tool(description="Show Iceberg table references (branches and tags)")