Skip to main content
Glama
onimsha

Airtable OAuth MCP Server

by onimsha

list_tables

Retrieve tables from an Airtable base to view structure and field information for data management.

Instructions

List tables in a specific base

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
base_idYesThe Airtable base ID
detail_levelNoLevel of detail to include in responsetableIdentifiersOnly

Implementation Reference

  • The handler function for the 'list_tables' MCP tool. Authenticates via _get_authenticated_client, fetches the base schema using AirtableClient.get_base_schema(base_id), and returns either basic table identifiers or detailed info including fields based on the detail_level parameter.
    @self.mcp.tool(description="List tables in a specific base")
    async def list_tables(
        base_id: Annotated[str, Field(description="The Airtable base ID")],
        detail_level: Annotated[
            Literal["tableIdentifiersOnly", "withFieldInfo"],
            Field(
                description="Level of detail to include in response",
                default="tableIdentifiersOnly",
            ),
        ] = "tableIdentifiersOnly",
    ) -> list[dict[str, Any]]:
        """List tables in a specific base with optional field information."""
        client = await self._get_authenticated_client()
        schema = await client.get_base_schema(base_id)
    
        if detail_level == "tableIdentifiersOnly":
            return [
                {
                    "id": table.id,
                    "name": table.name,
                }
                for table in schema.tables
            ]
        else:  # withFieldInfo
            return [
                {
                    "id": table.id,
                    "name": table.name,
                    "description": table.description,
                    "primaryFieldId": table.primary_field_id,
                    "fields": [
                        {
                            "id": field.id,
                            "name": field.name,
                            "type": field.type,
                            "description": field.description,
                            "options": field.options,
                        }
                        for field in table.fields
                    ],
                }
                for table in schema.tables
            ]
  • Pydantic schema definition for the input arguments of the list_tables tool, matching the inline annotations used in the handler.
    class ListTablesArgs(BaseArgs):
        """Arguments for list_tables tool."""
    
        base_id: str = Field(description="The Airtable base ID")
        detail_level: Literal["tableIdentifiersOnly", "withFieldInfo"] = Field(
            default="tableIdentifiersOnly",
            description="Level of detail to include in response",
        )
  • The _register_tools() method is called during server initialization to register all MCP tools, including list_tables via its @self.mcp.tool decorator.
    # Register all MCP tools
    self._register_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/onimsha/airtable-mcp-server-oauth'

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