list-tables
Retrieve all user tables from a Firebird database to understand its structure and available data sources for analysis.
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:178-207 (registration)Registration of the 'list-tables' MCP tool including the handler function that calls listTables() and formats the response.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/tools/database.ts:80-80 (schema)Zod input schema for the list-tables tool (empty object as no parameters are required).export const ListTablesArgsSchema = z.object({}); // No arguments
- src/db/queries.ts:454-489 (helper)Helper function listTables that performs the actual SQL query to list all user tables from the Firebird system table RDB$RELATIONS.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); } };