hana_list_tables
Retrieve a list of all tables within a specified schema on the HANA Cloud Database using the Model Context Protocol for efficient data management and integration.
Instructions
List all tables in a specific schema
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| schema_name | No | Name of the schema to list tables from (optional) |
Input Schema (JSON Schema)
{
"properties": {
"schema_name": {
"description": "Name of the schema to list tables from (optional)",
"type": "string"
}
},
"required": [],
"type": "object"
}
Implementation Reference
- src/tools/table-tools.js:15-48 (handler)The handler function that implements the core logic of hana_list_tables: validates input, queries the database for tables in the schema, formats the result, and handles errors.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); } }
- src/tools/index.js:14-24 (registration)Tool registration mapping where 'hana_list_tables' is registered to the TableTools.listTables implementation.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 };
- JSON schema definition for the hana_list_tables tool, specifying the optional schema_name 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: [] } },