Skip to main content
Glama
MikelA92

Metabase MCP Server

by MikelA92

get_database_metadata

Retrieve complete database schema including all tables, columns, and field types to understand data structure and relationships for analysis.

Instructions

๐Ÿ” [SAFE] Get complete metadata for a database including ALL tables, columns, and field types. This is comprehensive and may return large amounts of data. Use this when you need to understand the full database schema. Risk: None - read-only, but returns large payloads.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseIdYesThe ID of the database

Implementation Reference

  • The primary handler function that executes the get_database_metadata tool. Fetches comprehensive metadata from the Metabase API endpoint `/api/database/${databaseId}/metadata`, processes tables with field counts, and returns a formatted text response suitable for MCP.
      async getDatabaseMetadata(databaseId) {
        Validators.validateDatabaseId(databaseId);
        
        this.logger.debug('Getting database metadata', { databaseId });
        const metadata = await this.apiClient.makeRequest(`/api/database/${databaseId}/metadata`);
        
        const tables = metadata.tables?.map(t => ({
          id: t.id,
          name: t.name,
          schema: t.schema,
          fieldCount: t.fields?.length || 0,
        })) || [];
    
        return {
          content: [
            {
              type: 'text',
              text: `Database Metadata (ID: ${databaseId}):
    Database: ${metadata.name}
    Engine: ${metadata.engine}
    Total Tables: ${tables.length}
    
    Tables:
    ${tables.map(t => 
      `- ID: ${t.id} | Schema: ${t.schema} | Name: ${t.name} | Fields: ${t.fieldCount}`
    ).join('\n')}`,
            },
          ],
        };
      }
  • Defines the input schema, description, and name for the get_database_metadata tool, used by the MCP server for tool listing and validation.
    {
      name: 'get_database_metadata',
      description: '๐Ÿ” [SAFE] Get complete metadata for a database including ALL tables, columns, and field types. This is comprehensive and may return large amounts of data. Use this when you need to understand the full database schema. Risk: None - read-only, but returns large payloads.',
      inputSchema: {
        type: 'object',
        properties: {
          databaseId: {
            type: 'integer',
            description: 'The ID of the database',
            minimum: 1,
          },
        },
        required: ['databaseId'],
      },
    },
  • Registers and dispatches the get_database_metadata tool call to the appropriate handler method in the main executeTool switch statement.
    case 'get_database_metadata':
      return await this.databaseHandlers.getDatabaseMetadata(args.databaseId);

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