Skip to main content
Glama
MikelA92

Metabase MCP Server

by MikelA92

get_table_metadata

Retrieve detailed table metadata including column definitions, data types, and foreign key relationships to understand database structure before querying.

Instructions

๐Ÿ” [SAFE] Get detailed metadata for a specific table including all columns, data types, and foreign key relationships. Use this to understand table structure before writing queries. Risk: None - read-only operation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableIdYesThe ID of the table

Implementation Reference

  • The main handler function that executes the get_table_metadata tool: validates input, fetches table query metadata from Metabase API, processes fields, and returns formatted text content.
      async getTableMetadata(tableId) {
        Validators.validateTableId(tableId);
        
        this.logger.debug('Getting table metadata', { tableId });
        const table = await this.apiClient.makeRequest(`/api/table/${tableId}/query_metadata`);
        
        const fields = table.fields?.map(f => ({
          id: f.id,
          name: f.name,
          type: f.base_type,
          description: f.description,
        })) || [];
    
        return {
          content: [
            {
              type: 'text',
              text: `Table Metadata:
    ID: ${table.id}
    Name: ${table.name}
    Schema: ${table.schema}
    Database: ${table.db?.name}
    Total Fields: ${fields.length}
    
    Fields:
    ${fields.map(f => 
      `- ${f.name} (${f.type})${f.description ? ` - ${f.description}` : ''}`
    ).join('\n')}`,
            },
          ],
        };
      }
  • The input schema and description definition for the get_table_metadata tool, used for validation and tool listing.
    {
      name: 'get_table_metadata',
      description: '๐Ÿ” [SAFE] Get detailed metadata for a specific table including all columns, data types, and foreign key relationships. Use this to understand table structure before writing queries. Risk: None - read-only operation.',
      inputSchema: {
        type: 'object',
        properties: {
          tableId: {
            type: 'integer',
            description: 'The ID of the table',
            minimum: 1,
          },
        },
        required: ['tableId'],
      },
    },
  • The switch case in executeTool that registers and dispatches calls to the getTableMetadata handler.
    case 'get_table_metadata':
      return await this.databaseHandlers.getTableMetadata(args.tableId);
  • Instantiation of the DatabaseHandlers class, which contains the getTableMetadata method.
    this.databaseHandlers = new DatabaseHandlers(this.apiClient);

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/MikelA92/metabase-mcp-mab'

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