list_tables
Retrieve all table names from a MySQL database to understand its structure and available data.
Instructions
List all tables in the database
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_tables"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:318-337 (handler)The handler function that ensures a database connection, executes 'SHOW TABLES' query, and returns the list of tables as JSON.
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, including its 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:170-174 (schema)Defines the input schema for the 'list_tables' tool, which requires no parameters.
inputSchema: { type: 'object', properties: {}, required: [], }, - src/index.ts:201-202 (handler)Dispatches to the handleListTables method in the CallToolRequestHandler switch statement.
case 'list_tables': return await this.handleListTables();