Skip to main content
Glama

Lists all tables in a database

list_tables

Lists all tables in a Turso database. Provide the database name to retrieve its table names.

Instructions

Lists all tables in a database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNoDatabase name (optional, uses context if not provided)

Implementation Reference

  • Tool handler for 'list_tables' - registers the tool via server.tool(), resolves database name, calls database_client.list_tables(), and returns the response.
    // Database tools
    server.tool(
    	{
    		name: 'list_tables',
    		description: 'Lists all tables in a database',
    		schema: DatabaseOnlySchema,
    	},
    	async ({ database }) => {
    		try {
    			const database_name = resolve_database_name(database);
    			if (database) set_current_database(database);
    
    			const tables = await database_client.list_tables(database_name);
    			return create_tool_response({ database: database_name, tables });
    		} catch (error) {
    			return create_tool_error_response(error);
    		}
    	},
  • Core implementation of list_tables - queries sqlite_schema to get table names from the database, filtering out sqlite_ internal tables.
    export async function list_tables(
    	database_name: string,
    ): Promise<string[]> {
    	try {
    		const client = await get_database_client(
    			database_name,
    			'read-only',
    		);
    
    		// Query the sqlite_schema table to get all tables
    		const result = await client.execute({
    			sql: `SELECT name FROM sqlite_schema 
                WHERE type = 'table' 
                AND name NOT LIKE 'sqlite_%'
                ORDER BY name`,
    		});
    
    		// Extract table names from the result
    		return result.rows.map((row) => row.name as string);
    	} catch (error) {
    		throw new TursoApiError(
    			`Failed to list tables for database ${database_name}: ${
    				(error as Error).message
    			}`,
    			500,
    		);
    	}
    }
  • Zod schema for the 'list_tables' tool input - accepts an optional database name.
    const DatabaseOnlySchema = z.object({
    	database: z.string().optional().describe('Database name (optional, uses context if not provided)'),
    });
  • Registration of 'list_tables' tool via server.tool() with its name, description, schema, and handler callback.
    // Database tools
    server.tool(
    	{
    		name: 'list_tables',
    		description: 'Lists all tables in a database',
    		schema: DatabaseOnlySchema,
    	},
    	async ({ database }) => {
    		try {
    			const database_name = resolve_database_name(database);
    			if (database) set_current_database(database);
    
    			const tables = await database_client.list_tables(database_name);
    			return create_tool_response({ database: database_name, tables });
    		} catch (error) {
    			return create_tool_error_response(error);
    		}
    	},
    );
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It states the tool lists tables, implying a read-only operation, but does not disclose if it returns names only, includes system tables, or requires specific permissions. The behavior is minimally transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single, clear sentence with no redundancy. Every word contributes to the purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple list tool with one optional parameter and no output schema, the description is adequate but lacks details on return format, ordering, or limitations (e.g., whether all tables include temporary tables). Some gaps remain.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already describes the database parameter as optional and context-dependent. The description adds no further meaning beyond 'database', so baseline score of 3 applies (schema coverage is 100%).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tautological: description restates name/title.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives (e.g., describe_table for a single table, list_databases to enumerate databases). There is no mention of prerequisites or context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/spences10/mcp-turso-cloud'

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