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);
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Since no annotations are provided, the description carries the full burden of behavioral disclosure. It effectively communicates the safety profile ('[SAFE]', 'Risk: None - read-only operation'), which is crucial for a metadata tool. It also hints at the comprehensive nature of the output ('detailed metadata', 'including all columns, data types, and foreign key relationships'), though it doesn't specify format, pagination, or error handling details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured in three sentences: purpose, usage context, and risk disclosure. Each sentence adds distinct value without redundancy. The use of emoji and bracketed labels ('[SAFE]') enhances readability while maintaining brevity. There's no wasted verbiage or unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter read-only metadata tool with no output schema, the description provides strong contextual completeness. It covers purpose, usage guidance, safety, and output scope. The main gap is the lack of output format details (e.g., JSON structure, nested objects), which would be helpful given the absence of an output schema. However, the description compensates well with clear behavioral context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the single parameter 'tableId' clearly documented as 'The ID of the table' with a minimum value constraint. The description doesn't add any meaningful parameter semantics beyond what the schema already provides, such as explaining where to find table IDs or how they relate to other tools. The baseline score of 3 is appropriate given the schema's comprehensive coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Get detailed metadata'), target resource ('for a specific table'), and scope ('including all columns, data types, and foreign key relationships'). It distinguishes from sibling tools like 'get_database_metadata' by focusing on table-level rather than database-level metadata, and from query execution tools by emphasizing structural understanding rather than data retrieval.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('to understand table structure before writing queries'), which helps differentiate it from query execution siblings. However, it doesn't explicitly state when NOT to use it or name specific alternative tools for related purposes, such as 'get_database_metadata' for broader context or 'list_database_tables' for table enumeration.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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