hana_list_tables
List all tables in a specific schema within SAP HANA Cloud Database to manage database structure and access data efficiently.
Instructions
List all tables in a specific schema
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| schema_name | No | Name of the schema to list tables from (optional) |
Implementation Reference
- src/tools/table-tools.js:15-48 (handler)The main handler function for the 'hana_list_tables' tool. It handles optional schema_name (defaults from config), validates it, queries tables using QueryExecutor.getTables, formats the result, and returns a formatted response or error.static async listTables(args) { logger.tool('hana_list_tables', args); let { schema_name } = args || {}; // Use default schema if not provided if (!schema_name) { if (config.hasDefaultSchema()) { schema_name = config.getDefaultSchema(); logger.info(`Using default schema: ${schema_name}`); } else { return Formatters.createErrorResponse( 'Schema name is required', 'Please provide schema_name parameter or set HANA_SCHEMA environment variable' ); } } // Validate schema name const schemaValidation = Validators.validateSchemaName(schema_name); if (!schemaValidation.valid) { return Formatters.createErrorResponse('Invalid schema name', schemaValidation.error); } try { const tables = await QueryExecutor.getTables(schema_name); const formattedTables = Formatters.formatTableList(tables, schema_name); return Formatters.createResponse(formattedTables); } catch (error) { logger.error('Error listing tables:', error.message); return Formatters.createErrorResponse('Error listing tables', error.message); } }
- The input schema definition for the 'hana_list_tables' tool, defining schema_name as an optional string parameter.name: "hana_list_tables", description: "List all tables in a specific schema", inputSchema: { type: "object", properties: { schema_name: { type: "string", description: "Name of the schema to list tables from (optional)" } }, required: [] } },
- src/tools/index.js:14-24 (registration)The TOOL_IMPLEMENTATIONS object registers 'hana_list_tables' mapping to TableTools.listTables, used by ToolRegistry.executeTool to dispatch tool calls.const TOOL_IMPLEMENTATIONS = { hana_show_config: ConfigTools.showConfig, hana_test_connection: ConfigTools.testConnection, hana_show_env_vars: ConfigTools.showEnvVars, hana_list_schemas: SchemaTools.listSchemas, hana_list_tables: TableTools.listTables, hana_describe_table: TableTools.describeTable, hana_list_indexes: IndexTools.listIndexes, hana_describe_index: IndexTools.describeIndex, hana_execute_query: QueryTools.executeQuery };