get_database_metadata
Retrieve complete database schema information including all tables, columns, and field types to understand your database structure and relationships.
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
| Name | Required | Description | Default |
|---|---|---|---|
| databaseId | Yes | The ID of the database |
Implementation Reference
- The handler function that implements the get_database_metadata tool. It validates the databaseId, fetches metadata from the Metabase API, processes tables to include id, name, schema, and field count, and returns a formatted text summary.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 tool schema including name, description, and inputSchema requiring a databaseId integer.{ 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'], }, },
- src/server/MetabaseMCPServer.js:192-193 (registration)Registers and dispatches the get_database_metadata tool call to the corresponding handler method in DatabaseHandlers.case 'get_database_metadata': return await this.databaseHandlers.getDatabaseMetadata(args.databaseId);