list_tables
Retrieve a list of all tables within a MySQL database using the MCP MySQL Server. Simplify database exploration and management by accessing table information directly.
Instructions
List all tables in the database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:318-337 (handler)Executes the list_tables tool: ensures connection, runs 'SHOW TABLES' query, returns results as formatted JSON text.private async handleListTables() { await this.ensureConnection(); try { const [rows] = await this.connection!.query('SHOW TABLES'); return { content: [ { type: 'text', text: JSON.stringify(rows, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to list tables: ${getErrorMessage(error)}` ); } }
- src/index.ts:167-175 (registration)Registers the list_tables tool in the ListTools response with name, description, and input schema (no inputs required).{ name: 'list_tables', description: 'List all tables in the database', inputSchema: { type: 'object', properties: {}, required: [], }, },
- src/index.ts:170-174 (schema)Input schema definition for list_tables: empty properties, no required fields.inputSchema: { type: 'object', properties: {}, required: [], },
- src/index.ts:201-202 (registration)Dispatch case in CallToolRequestSchema handler that invokes the list_tables handler.case 'list_tables': return await this.handleListTables();