list-tables
Retrieve a list of all user tables in a Firebird database. Simplify database navigation and analysis by identifying available tables for querying or management tasks.
Instructions
Lists all user tables in the current Firebird database.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/database.ts:182-206 (handler)The handler function for the "list-tables" MCP tool. It calls the underlying listTables() function, handles logging and errors, and returns a formatted response with the list of tables.handler: async () => { logger.info("Listing tables in the database"); try { const tables = await listTables(); logger.info(`Found ${tables.length} tables`); return { content: [{ type: "text", text: formatForClaude({ tables }) }] }; } catch (error) { const errorResponse = wrapError(error); logger.error(`Error listando tablas: ${errorResponse.error} [${errorResponse.errorType || 'UNKNOWN'}]`); return { content: [{ type: "text", text: formatForClaude(errorResponse) }] }; } }
- src/tools/database.ts:80-80 (schema)Zod input schema definition for the "list-tables" tool, which requires no arguments.export const ListTablesArgsSchema = z.object({}); // No arguments
- src/tools/database.ts:178-207 (registration)Registration of the "list-tables" tool within the setupDatabaseTools() function, defining name, description, schema, and handler.tools.set("list-tables", { name: "list-tables", description: "Lists all user tables in the current Firebird database.", inputSchema: ListTablesArgsSchema, handler: async () => { logger.info("Listing tables in the database"); try { const tables = await listTables(); logger.info(`Found ${tables.length} tables`); return { content: [{ type: "text", text: formatForClaude({ tables }) }] }; } catch (error) { const errorResponse = wrapError(error); logger.error(`Error listando tablas: ${errorResponse.error} [${errorResponse.errorType || 'UNKNOWN'}]`); return { content: [{ type: "text", text: formatForClaude(errorResponse) }] }; } } });
- src/db/queries.ts:454-489 (helper)Core helper function listTables() that executes a SQL query on Firebird's RDB$RELATIONS system table to retrieve names of all user tables (excluding system tables and views).export const listTables = async (config = DEFAULT_CONFIG): Promise<string[]> => { // Try to load config from global variable first const globalConfig = getGlobalConfig(); if (globalConfig && globalConfig.database) { logger.info(`Using global configuration for listTables: ${globalConfig.database}`); config = globalConfig; } try { logger.info('Obteniendo lista de tablas de usuario'); const sql = ` SELECT RDB$RELATION_NAME FROM RDB$RELATIONS WHERE RDB$SYSTEM_FLAG = 0 AND RDB$VIEW_SOURCE IS NULL ORDER BY RDB$RELATION_NAME `; const tables = await executeQuery(sql, [], config); // Firebird puede devolver nombres con espacios al final, así que hacemos trim const tableNames = tables.map((table: any) => table.RDB$RELATION_NAME.trim()); logger.info(`Se encontraron ${tableNames.length} tablas de usuario`); return tableNames; } catch (error: any) { // Propagar el error si ya es un FirebirdError if (error instanceof FirebirdError) { throw error; } const errorMessage = `Error al listar tablas: ${error.message || error}`; logger.error(errorMessage); throw new FirebirdError(errorMessage, 'TABLE_LIST_ERROR', error); } };