list_tables
Retrieve all table names from your database to understand its structure and available data sources for querying and management.
Instructions
List all tables in the database
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:755-773 (handler)The handler function that ensures connection and executes 'SHOW TABLES' to list all tables in the MySQL database, returning JSON-formatted results.
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:301-309 (registration)Registration of the 'list_tables' tool in the ListTools response, defining name, description, and empty input schema (no parameters required).
{ name: 'list_tables', description: 'List all tables in the database', inputSchema: { type: 'object', properties: {}, required: [], }, }, - src/index.ts:304-307 (schema)Input schema for list_tables tool: empty object, no required properties.
inputSchema: { type: 'object', properties: {}, required: [], - src/index.ts:543-544 (helper)Dispatcher case in CallToolRequestSchema handler that routes 'list_tables' calls to the handleListTables method.
case 'list_tables': return await this.handleListTables();