Skip to main content
Glama

hana_list_indexes

Retrieve all indexes for a specified table in SAP HANA Cloud Database to analyze database structure and optimize queries.

Instructions

List all indexes for a specific table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schema_nameNoName of the schema containing the table (optional)
table_nameYesName of the table to list indexes for

Implementation Reference

  • Main handler function for 'hana_list_indexes' tool. Handles input validation, schema defaulting, executes query to fetch indexes, groups and formats results, and returns formatted response.
    static async listIndexes(args) { logger.tool('hana_list_indexes', 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_list_indexes'); 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 results = await QueryExecutor.getTableIndexes(schema_name, table_name); if (results.length === 0) { return Formatters.createResponse(`πŸ“‹ No indexes found for table '${schema_name}.${table_name}'.`); } // Group by index name const indexMap = {}; results.forEach(row => { if (!indexMap[row.INDEX_NAME]) { indexMap[row.INDEX_NAME] = { type: row.INDEX_TYPE, isUnique: row.IS_UNIQUE === 'TRUE', columns: [] }; } indexMap[row.INDEX_NAME].columns.push(row.COLUMN_NAME); }); const formattedIndexes = Formatters.formatIndexList(indexMap, schema_name, table_name); return Formatters.createResponse(formattedIndexes); } catch (error) { logger.error('Error listing indexes:', error.message); return Formatters.createErrorResponse('Error listing indexes', error.message); } }
  • Tool implementation mapping where 'hana_list_indexes' is registered to IndexTools.listIndexes method.
    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 };
  • Input schema definition for the 'hana_list_indexes' tool, specifying parameters and requirements.
    { name: "hana_list_indexes", description: "List all indexes for 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 list indexes for" } }, required: ["table_name"] } },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/HatriGt/hana-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server