Skip to main content
Glama
ryft-io

IcebergMCP

by ryft-io

get_table_schema

Retrieve the schema for an Apache Iceberg table by specifying its namespace and table name. This tool helps users understand table structure and data types for querying and analysis in data lakehouses.

Instructions

Provides the schema for a given Iceberg table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceYes
table_nameYes

Implementation Reference

  • The handler function that loads the Iceberg table and extracts its schema fields into the defined SchemaField format.
    def get_table_schema(
        namespace: str,
        table_name: str
    ) -> list[SchemaField]:
        """Provides the schema for a given Iceberg table""" 
        catalog: Catalog = get_catalog()
        table_obj = catalog.load_table((namespace, table_name))
        schema = table_obj.schema()
    
        fields = []
        for field in schema.fields:
            fields.append(
                {
                    "id": field.field_id,
                    "name": field.name,
                    "type": str(field.field_type),
                    "required": field.required,
                    "doc": field.doc if field.doc else None,
                }
            )
    
        return fields
  • Registers the get_table_schema function as an MCP tool using the FastMCP decorator.
    @mcp.tool()
  • Defines the output schema structure for table schema fields.
    class SchemaField(TypedDict):
        id: int
        name: str
        type: str
        required: bool
        doc: str | None
  • Helper function to initialize the GlueCatalog using AWS credentials from config.
    def get_catalog() -> GlueCatalog:
        try:
            session = boto3.Session(profile_name=iceberg_config.profile_name)
            credentials = session.get_credentials().get_frozen_credentials()
    
            catalog = GlueCatalog(
                "glue",
                **{
                    "client.access-key-id": credentials.access_key,
                    "client.secret-access-key": credentials.secret_key,
                    "client.session-token": credentials.token,
                    "client.region": iceberg_config.region,
                },
            )
        except Exception as e:
            logger.error(f"Error creating AWS connection: {str(e)}")
            raise
        return catalog

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/ryft-io/iceberg-mcp'

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