list_tables
Retrieve a list of all tables in a MySQL or MongoDB database to view and manage schema structure. Integrates with the MCP server for standardized database operations.
Instructions
List all tables in the database
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"required": [],
"type": "object"
}
Implementation Reference
- src/index.ts:755-773 (handler)The handler function that ensures DB connection and executes 'SHOW TABLES' query to list all tables, returning JSON stringified 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 (schema)Tool definition including name, description, and input schema (no parameters required).{ name: 'list_tables', description: 'List all tables in the database', inputSchema: { type: 'object', properties: {}, required: [], }, },
- src/index.ts:543-544 (registration)Switch case registration that dispatches 'list_tables' tool calls to the handleListTables method.case 'list_tables': return await this.handleListTables();