hana_describe_table
Analyze and retrieve the structure of a specified table in SAP HANA Cloud Database using schema and table names, enabling efficient data management and integration with Cursor IDE.
Instructions
Describe the structure of a specific table
Input 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 |
Input Schema (JSON Schema)
{
"properties": {
"schema_name": {
"description": "Name of the schema containing the table (optional)",
"type": "string"
},
"table_name": {
"description": "Name of the table to describe",
"type": "string"
}
},
"required": [
"table_name"
],
"type": "object"
}
Implementation Reference
- src/tools/table-tools.js:53-102 (handler)The static async describeTable(args) method that implements the core logic of the hana_describe_table tool: handles optional schema_name using config default, validates inputs, queries table columns via QueryExecutor.getTableColumns(schema_name, table_name), formats the structure, and returns formatted response or error.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 tool specifying properties schema_name (optional string) and table_name (required string).{ 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)TOOL_IMPLEMENTATIONS mapping registers 'hana_describe_table' to TableTools.describeTable function.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 };