Skip to main content
Glama
MikelA92

Metabase MCP Server

by MikelA92

get_field_values

Retrieve distinct values from a Metabase field to understand column data content and identify available options for analysis.

Instructions

๐Ÿ” [SAFE] Get distinct values for a field (useful for understanding what values exist in a column). May return many values for high-cardinality fields. Risk: None - read-only, but may return large results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldIdYesThe ID of the field

Implementation Reference

  • The primary handler function for the 'get_field_values' MCP tool. It validates the fieldId, fetches distinct values from the Metabase API endpoint `/api/field/${fieldId}/values`, limits display to first 100 values, and returns a formatted MCP response.
      async getFieldValues(fieldId) {
        Validators.validateFieldId(fieldId);
        
        this.logger.debug('Getting field values', { fieldId });
        const values = await this.apiClient.makeRequest(`/api/field/${fieldId}/values`);
        
        const distinctValues = values.values || [];
        
        return {
          content: [
            {
              type: 'text',
              text: `Field Values (ID: ${fieldId}):
    Total Distinct Values: ${distinctValues.length}
    
    ${distinctValues.length > 0 ? `Values:\n${distinctValues.slice(0, 100).join(', ')}${distinctValues.length > 100 ? `\n... and ${distinctValues.length - 100} more values` : ''}` : 'No values found'}`,
            },
          ],
        };
      }
  • The tool schema definition including name, description, and input validation schema requiring a single integer 'fieldId' parameter.
    {
      name: 'get_field_values',
      description: '๐Ÿ” [SAFE] Get distinct values for a field (useful for understanding what values exist in a column). May return many values for high-cardinality fields. Risk: None - read-only, but may return large results.',
      inputSchema: {
        type: 'object',
        properties: {
          fieldId: {
            type: 'integer',
            description: 'The ID of the field',
            minimum: 1,
          },
        },
        required: ['fieldId'],
      },
    },
  • The tool dispatch/registration in the MCP server's executeTool method switch statement, which routes calls to the FieldHandlers.getFieldValues method.
    case 'get_field_values':
      return await this.fieldHandlers.getFieldValues(args.fieldId);

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