list_tables
Retrieve all table names from a Turso-hosted LibSQL database to understand database structure and available data.
Instructions
List all tables in the database
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/index.ts:51-63 (handler)The execute handler for the 'list_tables' tool. Logs execution, calls listTables(db), returns JSON formatted list or error.execute: async () => { try { logger.info("Executing list_tables"); const tables = await listTables(db); return content(JSON.stringify({ tables }, null, 2)); } catch (error) { logger.error("Failed to list tables", error); return content( `Error listing tables: ${error instanceof Error ? error.message : String(error)}`, true, ); } },
- src/index.ts:47-64 (registration)Registers the 'list_tables' tool with FastMCP server, including description, Zod input schema (empty object), and execute handler.server.addTool({ name: "list_tables", description: "List all tables in the database", parameters: z.object({}), execute: async () => { try { logger.info("Executing list_tables"); const tables = await listTables(db); return content(JSON.stringify({ tables }, null, 2)); } catch (error) { logger.error("Failed to list tables", error); return content( `Error listing tables: ${error instanceof Error ? error.message : String(error)}`, true, ); } }, });
- src/index.ts:50-50 (schema)Zod schema defining empty input parameters for list_tables tool (no arguments required).parameters: z.object({}),
- src/utils.ts:18-25 (helper)Helper function that executes SQL query to fetch and return list of table names from sqlite_master, excluding system tables.export async function listTables(client: Client): Promise<string[]> { const result = await client.execute({ sql: "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'", args: [], }); return result.rows.map((row) => row.name as string); }