list_tables
Retrieve all table names from a connected SQLite database to understand its structure and available data sources.
Instructions
List all tables in the connected database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:221-244 (handler)The handler function that executes the list_tables tool. It checks for a connected database, queries sqlite_master for user-created tables, formats them into a comma-separated list, and returns the result as a text content response.private async listTables(): Promise<CallToolResult> { if (!this.db) { throw new Error("No database connected. Use connect_database first."); } try { const tables = this.db .prepare("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name") .all() as { name: string }[]; const tableList = tables.map(t => t.name).join(", "); return { content: [ { type: "text", text: `Tables in database (${tables.length}): ${tableList || "No tables found"}`, } satisfies TextContent, ], }; } catch (error) { throw new Error(`Failed to list tables: ${error instanceof Error ? error.message : String(error)}`); } }
- src/index.ts:78-85 (registration)Registration of the list_tables tool in the ListToolsRequestHandler. Includes the tool name, description, and input schema (empty object since no parameters required).{ name: "list_tables", description: "List all tables in the connected database", inputSchema: { type: "object", properties: {}, }, },
- src/index.ts:81-84 (schema)Input schema definition for the list_tables tool, which is an empty object indicating no input parameters are required.inputSchema: { type: "object", properties: {}, },
- src/index.ts:165-166 (registration)Switch case in the CallToolRequestHandler that dispatches calls to the list_tables tool by invoking the listTables() handler method.case "list_tables": return await this.listTables();