Skip to main content
Glama
nbbaier

MCP-Turso

list_tables

Retrieve all table names from a Turso-hosted LibSQL database to view available data structures and plan queries.

Instructions

List all tables in the database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function that executes the list_tables tool: logs action, calls listTables helper, returns JSON of tables or error content.
    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)
    Registration of the list_tables tool using server.addTool, including name, description, empty input schema, and 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 for input parameters: empty object (no parameters required).
    parameters: z.object({}),
  • Helper function that queries sqlite_master to list user tables (excluding sqlite_ internals), returns array of table names.
    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