hana_describe_table
Retrieve table structure details including column names, data types, and constraints from SAP HANA Cloud Database to understand data organization and relationships.
Instructions
Describe the structure of a specific table
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| schema_name | No | Name of the schema containing the table (optional) | |
| table_name | Yes | Name of the table to describe |
Implementation Reference
- src/tools/table-tools.js:53-102 (handler)Main execution logic for hana_describe_table tool: handles args, defaults schema, validates inputs, queries table columns, formats and returns structure.static async describeTable(args) { logger.tool('hana_describe_table', args); let { schema_name, table_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 required parameters const validation = Validators.validateRequired(args, ['table_name'], 'hana_describe_table'); if (!validation.valid) { return Formatters.createErrorResponse('Error: table_name parameter is required', validation.error); } // Validate schema and table names const schemaValidation = Validators.validateSchemaName(schema_name); if (!schemaValidation.valid) { return Formatters.createErrorResponse('Invalid schema name', schemaValidation.error); } const tableValidation = Validators.validateTableName(table_name); if (!tableValidation.valid) { return Formatters.createErrorResponse('Invalid table name', tableValidation.error); } try { const columns = await QueryExecutor.getTableColumns(schema_name, table_name); if (columns.length === 0) { return Formatters.createErrorResponse(`Table '${schema_name}.${table_name}' not found or no columns available`); } const formattedStructure = Formatters.formatTableStructure(columns, schema_name, table_name); return Formatters.createResponse(formattedStructure); } catch (error) { logger.error('Error describing table:', error.message); return Formatters.createErrorResponse('Error describing table', error.message); } }
- Input schema definition for hana_describe_table, specifying optional schema_name and required table_name.{ name: "hana_describe_table", description: "Describe the structure of a specific table", inputSchema: { type: "object", properties: { schema_name: { type: "string", description: "Name of the schema containing the table (optional)" }, table_name: { type: "string", description: "Name of the table to describe" } }, required: ["table_name"] } },
- src/tools/index.js:14-24 (registration)ToolRegistry maps tool names to implementations, registering hana_describe_table to TableTools.describeTable.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 };