Skip to main content
Glama

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

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "properties": {}, "type": "object" }

Implementation Reference

  • 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, ); } }, });
  • Zod schema defining empty input parameters for list_tables tool (no arguments required).
    parameters: z.object({}),
  • 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); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nbbaier/mcp-turso'

If you have feedback or need assistance with the MCP directory API, please join our Discord server