get_field_values
Retrieve distinct values from a database field to understand what data exists in a specific column, useful for data exploration and 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
| Name | Required | Description | Default |
|---|---|---|---|
| fieldId | Yes | The ID of the field |
Implementation Reference
- The main handler function in FieldHandlers class that executes the get_field_values tool: validates fieldId, fetches values from Metabase API `/api/field/${fieldId}/values`, formats the distinct values into a text response limited to first 100.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'}`, }, ], }; }
- Tool schema definition including name, description, and inputSchema requiring integer fieldId >=1.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'], }, },
- src/server/MetabaseMCPServer.js:212-213 (registration)Registration/dispatch in MetabaseMCPServer.executeTool switch statement: maps tool name to fieldHandlers.getFieldValues.case 'get_field_values': return await this.fieldHandlers.getFieldValues(args.fieldId);
- src/client/MetabaseClient.js:419-425 (helper)Supporting MetabaseClient method that performs the actual API request to fetch field values, used by the handler via apiClient.async getFieldValues(fieldId) { Validators.validateFieldId(fieldId); const values = await this.makeRequest(`/api/field/${fieldId}/values`); return values.values || []; }