list_database_tables
Retrieve all tables from a specific database to identify available data before executing queries. This read-only operation helps users explore database structure.
Instructions
📑 [SAFE] List all tables in a specific database. Use this to see what tables are available before querying. Risk: None - read-only operation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| databaseId | Yes | The ID of the database |
Implementation Reference
- The handler function that implements the list_database_tables tool logic, fetching database metadata and formatting the list of tables./** * List database tables */ async listDatabaseTables(databaseId) { Validators.validateDatabaseId(databaseId); this.logger.debug('Listing database tables', { databaseId }); // Use metadata endpoint as /tables endpoint doesn't exist const metadata = await this.apiClient.makeRequest(`/api/database/${databaseId}/metadata`); const tables = metadata.tables || []; return { content: [ { type: 'text', text: `Tables in Database ${databaseId}: ${tables.map(t => `- ID: ${t.id} | Schema: ${t.schema} | Name: ${t.name}` ).join('\n')}`, }, ], }; }
- The JSON schema definition for the tool, specifying the input parameters (databaseId).{ name: 'list_database_tables', description: '📑 [SAFE] List all tables in a specific database. Use this to see what tables are available before querying. Risk: None - read-only operation.', inputSchema: { type: 'object', properties: { databaseId: { type: 'integer', description: 'The ID of the database', minimum: 1, }, }, required: ['databaseId'], }, },
- src/server/MetabaseMCPServer.js:194-195 (registration)The tool registration in the MCP server's executeTool switch statement, dispatching to the handler.case 'list_database_tables': return await this.databaseHandlers.listDatabaseTables(args.databaseId);