list_tables
Retrieve all tables for a given database connection. Specify the connection and optional database to list available tables.
Instructions
Lists tables for the selected connection.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connection | Yes | ||
| database | No |
Implementation Reference
- src/index.js:74-82 (handler)The handler that executes the 'list_tables' tool logic. It takes a 'connection' (required) and optional 'database' argument, runs 'SHOW TABLES' (or 'SHOW TABLES FROM `database`') via the database manager, and returns the result.
case "list_tables": { const { connection, database } = args || {}; if (!connection) return fail("'connection' field is required."); const sql = database ? `SHOW TABLES FROM \`${database}\`` : "SHOW TABLES"; const rows = await db.runReadOnly(connection, sql); return ok(rows); } - src/tools.js:23-34 (schema)The input schema definition for the 'list_tables' tool, specifying 'connection' (required, enum from readableConnections) and 'database' (optional string).
{ name: "list_tables", description: "Lists tables for the selected connection.", inputSchema: { type: "object", properties: { connection: { type: "string", enum: readableConnections }, database: { type: "string" }, }, required: ["connection"], }, }, - src/index.js:31-37 (registration)The tool definitions are built by buildToolDefinitions() and returned in response to ListToolsRequestSchema, which effectively registers all tools (including 'list_tables') with the MCP server.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: buildToolDefinitions( readableConnections, writableConnections, allConnections, ), }));