list_tables
Retrieve all base tables in the current database with row counts and comments for schema inspection.
Instructions
List all base tables in the current database with row counts and comments.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:71-81 (handler)The handler function that executes the 'list_tables' tool logic. It queries information_schema.TABLES to list all base tables with row counts and comments.
async () => { const results = await db.query(` SELECT TABLE_NAME, TABLE_ROWS, TABLE_COMMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_TYPE = 'BASE TABLE' `); return { content: [{ type: 'text', text: JSON.stringify(results, null, 2) }], }; } ); - src/index.ts:67-70 (schema)The schema definition for the 'list_tables' tool: accepts no inputs (empty object schema) and describes the output as listing base tables with row counts and comments.
{ description: 'List all base tables in the current database with row counts and comments.', inputSchema: z.object({}), }, - src/index.ts:65-81 (registration)Registration of the 'list_tables' tool via server.registerTool() with its name, schema, and handler.
server.registerTool( 'list_tables', { description: 'List all base tables in the current database with row counts and comments.', inputSchema: z.object({}), }, async () => { const results = await db.query(` SELECT TABLE_NAME, TABLE_ROWS, TABLE_COMMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_TYPE = 'BASE TABLE' `); return { content: [{ type: 'text', text: JSON.stringify(results, null, 2) }], }; } ); - src/db.ts:42-45 (helper)The db.query helper function used by the list_tables handler to execute the SQL query against the MySQL database.
export async function query(sql: string, params?: any[]) { const [rows] = await pool.query(sql, params); return rows; }