
SAP HANA CLI
io.github.SAP-samples由 GitHub 帳號 SAP-samples 發布v4.202607.1更新於 Oct 24, 2026
150+ SAP HANA database tools as MCP tools for AI assistants
概覽
一個 MCP 伺服器,向 AI 助理提供 SAP HANA 資料庫開發指令,涵蓋資料表與檢視檢視、HDI 及 BTP 操作。
- 可以做什麼
- 檢視資料表、檢視、結構描述、預存程序、函式與索引等資料庫物件,讀取資料行與中繼資料,並可轉換為 CDS 或 EDMX 格式。執行資料操作與批次工作,例如匯出、匯入、資料表複製、資料同步、批次授權、批次更新與批次刪除,並支援試執行預覽。透過資料表熱點、查詢計畫、警示與健康檢查分析效能與運作狀態。管理 HDI 容器與雲端服務,包括 BTP 與 Cloud Foundry 整合。透過路由工具呼叫 180 多個指令中的任一個,預設僅提供少量工具,其餘依需求探索。
- 適用情境
- 適合在開發過程中讓助理操作 SAP HANA 資料庫:瀏覽結構描述與檢視、產生 CDS 或 EDMX 定義、搬移或比較資料、檢查效能,以及管理 HDI 容器與 BTP 服務。
- 執行需求
- 透過 npx 從 npm 套件 hana-cli 以 stdio 在本機執行;需要 Node.js 22 或更新版本,建議使用 Node.js 24。需要可連線的 SAP HANA 資料庫與連線憑證,憑證會從 default-env.json、.env、.cdsrc-private.json 或使用者主目錄 .hana-cli 資料夾中的檔案解析。BTP 相關指令另需 PATH 中有 SAP BTP CLI。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 SAP HANA CLI,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
SAP HANA Developer Command Line Interface
⚠️ Important Notice - Major Updates (Feb/March 2026)
Version 4.x introduces significant changes including Express 5 migration, refactored database connection handling, and major performance improvements. While we've tested extensively, please be aware of potential issues in your specific environment.
If you encounter problems:
-
Report Issues: Please open an issue on our GitHub Issues page with details about your environment and the problem you're experiencing.
-
Rollback to Stable Version: If you need to quickly revert to the last stable release before these major changes, you can install version 3.202601.0 (January 2026):
What's Changed: The change log describes all notable changes including Express 5 migration, database connection refactoring, CLI startup performance optimization (60-77% faster), expanded test coverage (85%+ coverage), and the new VitePress documentation site.
📚 Documentation
Complete documentation is available in the docs/ folder and organized with VitePress. This README will maintain a high-level overview and quick links to the most important sections of the documentation but over time expect that more and more detailed documentation will be added to the docs folder as the project evolves.
Quick Links:
- Getting Started - Installation and setup
- Command Reference - All 20+ commands with examples
- Features Guide - CLI, API, MCP, and more
- API Reference - REST API documentation
- FAQ - Frequently asked questions
- Troubleshooting - Common issues and solutions
Run Documentation Locally
Build For Production
See docs/README.md for complete documentation setup details.
Description
This sample is intended to shown how one could build a developer-centric SAP HANA command line tool, particularly designed to be used when performing local SAP HANA development in non-SAP tooling (like VSCode). It utilizes the default-env.json that is often used in local development for connectivity to a remote SAP HANA DB (although it can of course be used with a local SAP HANA, express edition instance as well). There is no intention to replacing the hdbsql tool as a generic SQL console. Instead this sample will focus on simplifying and grouping common and complex commands that otherwise might a lot of separate scripts.
Introduction Video: https://youtu.be/dvVQfi9Qgog
However the tool isn't limited to only local development. It also works well when developing in the cloud. The hana-cli tool can also run well from a cloud shell in the SAP Business Application Studio, Google Cloud Shell, AWS Cloud9, etc. We can also run against a SAP HANA service for SAP BTP or SAP HANA Cloud instance. This demonstrates that the tool can run just about anywhere you can get a command line that has access to the Node.js Runtime. We can also connect to a remote HANA instance even if it isn't running in the same cloud environment in which we are performing our development tasks.
Supported Environments
Running in Cloud Shells Video: https://youtu.be/L7QyVLvAIIQ
Requirements / Download and Installation
If you would rather just access the tool directly, it is now available in npm as well. You can install via:
Installation Methods
Otherwise you can also run it from the sources as described here:
-
Install Node.js on your development machine https://nodejs.org/en/download/. Version 22 or later is required; Node.js 24 (LTS) is highly recommended, following the SAP CAP 10 recommendation.
-
Clone the repository from https://github.com/SAP-samples/hana-developer-cli-tool-example
- Run NPM install from the root of the hana-developer-cli-tool-example project you just cloned to download dependencies
- Run NPM link from the cloned project root to make the hana-cli command available from everywhere https://docs.npmjs.com/cli/link
BTP CLI Installation
The hana-cli tool includes several commands that interact with SAP Business Technology Platform (BTP) services. All BTP-related functionality in this tool relies on the SAP BTP Command Line Interface (btp CLI) being installed and available in your system's PATH.
About the BTP CLI
The btp CLI is SAP's official command-line tool for managing resources and services on the SAP Business Technology Platform. It provides capabilities for managing global accounts, directories, subaccounts, entitlements, service instances, and more. The hana-cli tool wraps and extends many of these capabilities with developer-friendly commands.
Installing the BTP CLI with install-btp.sh
For Linux and macOS users, this repository includes a convenient installation script install-btp.sh that automates the installation of the BTP CLI.
The script performs the following actions:
- Downloads the latest BTP CLI installer from the SAP Development Tools download page
- Makes the installer executable and runs it with automatic confirmation
- Configures shell aliases for easier BTP CLI usage
- Adds the BTP CLI binary location to your PATH
To use the installation script:
After running the script, you may need to restart your terminal or run source ~/.bashrc to apply the PATH changes.
Note: Windows users should download the BTP CLI from the SAP Development Tools page and follow the platform-specific instructions there.
Verifying the Installation
Once installed, you can verify the BTP CLI is available by running:
You can also use the hana-cli tool itself to check your BTP CLI configuration:
This will display your current BTP target information including global account, directory, and subaccount if configured.
Security
This application primarily uses the default-env.json that is often used in local development for connectivity to a remote HANA DB (although it can of course be used with a local SAP HANA, express edition instance as well). For more details on how the default-env.json works, see the readme.md of the @sap/xsenv package or the @sap/hdi-deploy package.
Connection Configuration Resolution Order
The tool doesn't simply look for a default-env.json file in the current directory however. There are numerous options and places it will look for the connection parameters. Here is the order in which it checks:
- First we look for the Admin option and use a default-env-admin.json - this overrides all other parameters
- If no admin option or if there was an admin option but no default-env-admin.json could be found in this directory or 5 parent directories, then look for
.cdsrc-private.jsonin this directory or 5 parent directories and usecds bindfunctionality to lookup the credentials securely. This is the most secure option, but please note: this will make each command take a few seconds longer as credentials are no longer stored locally but looked up from cf or k8s dynamically with each command - If no
.cdsrc-private.jsonfound in this directory or 5 parent directories, then look for a .env file in this directory or up to 5 parent directories - No .env file found or it doesn't contain a VCAP_SERVICES section, then check to see if the --conn parameter was specified. If so check for that file in the current directory or up to 5 parent directories
- If the file specified via the --conn parameter wasn't found locally then check for it in the ${homedir}/.hana-cli/ folder
- If no specific configuration file was was found then look for a file named default-env.json in the current directory or up to 5 parent directories
- Last resort if nothing has been found up to this point - look for a file named default.json in the ${homedir}/.hana-cli/ folder
Examples
A lot of the functionality of this tool revolves around typical tasks you face while doing HANA database development. For example you might want to get a list of all views in your current schema/container:
Then perhaps you want to inspect a view to see the columns and their data types:
But there are multiple output options for inspection. Perhaps you are using Cloud Application Programming Model and need to create a proxy entity in CDS for a view. This tool will read the catalog metadata and convert it to CDS:
Or maybe you are service enabling this view and you want to see it converted to EDMX:
This tool will even create a temporary OData V4 service for any existing table, view or Calculation View and launch a test Fiori Ui locally. [Fioir Example]
Project Structure and Documentation
Utils Documentation
For developers looking to understand or extend the internal utilities used by this CLI tool, comprehensive documentation is available in the utils/README.md file. This documentation covers:
- Core Utilities: base module, connection management, database inspection, SQL injection protection
- CLI Integration: BTP, Cloud Foundry, and XSA CLI integration utilities
- Database Abstraction: Multi-database support (HANA, PostgreSQL, SQLite) with factory pattern
- Usage Examples: Practical examples for using the utility modules
The utils folder contains reusable modules that provide the foundation for all CLI commands, including database connectivity, terminal UI components, security utilities, and internationalization support.
HTTP Routes Documentation
The hana-cli tool includes a built-in web server that exposes all CLI functionality through RESTful HTTP endpoints. Detailed documentation for all HTTP routes is available in the routes/README.md file. This documentation covers:
- Base Configuration Endpoints: GET/PUT operations for managing CLI prompts and settings
- HANA Database Endpoints: Complete API for listing and inspecting HANA database objects (tables, views, schemas, containers, etc.)
- Documentation Endpoints: Access to README and CHANGELOG as HTML
- WebSocket Support: Real-time communication for long-running operations
- Static Resources: UI5 application and DFA integration
The web server is automatically started when using certain CLI commands with the -w or --web flag, making all hana-cli functionality accessible via HTTP requests at http://localhost:3010 (configurable port).
Swagger/OpenAPI Documentation
The hana-cli web server now includes comprehensive Swagger/OpenAPI 3.0 documentation for all REST API endpoints. This provides an interactive interface for exploring and testing all HTTP APIs, making it easier to integrate hana-cli functionality into your own applications.
Key Features:
- Interactive API Documentation: Browse all 27+ documented endpoints with full request/response schemas
- Try-It-Out Functionality: Test any API endpoint directly from the browser
- Auto-Generated Specification: Documentation automatically generated from JSDoc comments in route files
- OpenAPI 3.0 Standard: Industry-standard specification for maximum compatibility
- Organized Categories: Endpoints grouped into 10 logical categories (Configuration, HANA System, HANA Objects, HDI, Cloud Services, etc.)
- Export Support: Download the raw OpenAPI JSON specification for client SDK generation
Accessing Swagger UI:
For complete implementation details, usage examples, and customization options, see the SWAGGER_IMPLEMENTATION.md documentation.
Web Applications (Fiori Launchpad UI)
The hana-cli tool includes a complete browser-based interface built with SAP UI5 and the Fiori Launchpad, providing a graphical alternative to the command-line interface. This web interface offers an intuitive, tile-based navigation system for all database operations.
Key Features:
- Fiori Launchpad Interface: Modern, responsive UI with organized tile groups
- Multiple UI5 Applications: Specialized apps for listing, inspecting, and managing database objects
- Real-Time Operations: WebSocket-based communication for live updates and long-running tasks
- Mass Conversion Tool: Bulk convert tables to CDS, HDBTable, or HDBMigrationTable formats
- System Information Dashboard: View connection details, version info, and system status
- Database Object Browser: Interactive exploration of tables, views, schemas, functions, indexes, and more
- Cloud Foundry Integration: Manage HDI, SBSS, Schema, and SecureStore service instances
- Theme Support: Automatic light/dark mode detection and customization
- Integrated Help: SAP Digital Foundation Adapter (DFA) with contextual assistance
Quick Start:
The web UI runs on http://localhost:3010 by default and provides access to all CLI functionality through an easy-to-use graphical interface. For complete documentation of all web applications, UI5 components, configuration, and development guides, see the app/README.md file.
MCP (Model Context Protocol) Integration
The hana-cli tool includes a Model Context Protocol (MCP) server, enabling AI assistants like Claude to interact with SAP HANA databases through natural language. The server uses a progressive discovery model — starting with ~22 focused tools and expanding on demand to all 186 commands.
Key Features:
- Progressive tool discovery — tier-1 tools always available, others via router or dynamic promotion
- Router tool (
hana_execute) dispatches any of 183+ commands by name - AI-guided command recommendations and smart search
- Seamless integration with Claude Desktop, VS Code, Cursor, and other MCP clients
--fullmode available for environments where tool count is not a concern
For detailed setup instructions, configuration options, and usage examples, please refer to:
- docs/03-features/mcp-integration.md - Complete MCP overview and setup guide
- mcp-server/README.md - Server installation and configuration
Standard Parameters and Conventions
The hana-cli tool follows consistent parameter naming, aliasing, and default value conventions across all commands to provide a predictable and intuitive user experience.
Command Categories Overview
Global Standard Parameters
All commands support the following standard connection and debugging parameters:
Common Command Parameters
Commands are organized into categories, each with their own standardized parameters:
Data Manipulation Commands
Commands like export, import, compareData, tableCopy, dataSync, etc.
Batch Operations
Commands like massGrant, massUpdate, massDelete, massExport, etc.
List/Inspect Commands
Commands like tables, schemas, users, procedures, functions, etc.
Naming Conventions
The tool follows these conventions for parameter naming:
- Single Operations: Use singular names (e.g.,
schema,table,user) - Source/Target Operations: Use paired names (e.g.,
sourceSchema/targetSchema,sourceTable/targetTable) - Boolean Flags: Use descriptive names (e.g.,
dryRun,includeHeaders,withGrantOption) - Aggregation Parameters: Use plural or descriptive names (e.g.,
columns,indexes,keyColumns)
Alias Conventions
Aliases follow these consistent patterns:
- Single-letter alias: First letter of the parameter (e.g.,
-sfor schema,-tfor table) - Extended alias: Meaningful abbreviation (e.g.,
-drfor dryRun,-batchfor batchSize) - No self-referential aliases: Parameter name itself is not used as an alias (e.g.,
--schemahas alias-sonly) - Maximum aliases: Parameters typically have at most 2 aliases to avoid confusion
Default Values
Default values are standardized to ensure consistent behavior:
Usage Examples
Using Standard Parameters
Common Parameter Combinations
Current Schema Defaults (**CURRENT_SCHEMA**)
The vast majority of schema-aware commands now use **CURRENT_SCHEMA** as the default value for schema parameters. This special placeholder allows you to work with your current database context without explicitly specifying the schema name each time.
Supported Commands with Current Schema Default
The following command categories fully support the **CURRENT_SCHEMA** placeholder:
Listing Commands (30+ commands):
- All schema navigation:
tables,views,indexes,functions,procedures,triggers,sequences,synonyms,libraries,roles,objects - Specialized lists:
partitions,columnStats,spatialData,ftIndexes,graphWorkspaces,tableHotspots,tableGroups,calcViewAnalyzer
Data Manipulation Commands (10+ commands):
export,import,dataProfile,dataDiff,compareData,compareSchema,tableCopy,dataSync
Analysis Commands (10+ commands):
dataValidator,duplicateDetection,erdDiagram,dataLineage,referentialCheck, and more
Current Schema Examples
For a complete list of all commands with **CURRENT_SCHEMA** support, see the CONSISTENCY_REVIEW_COMPLETE.md document.
Multi-Profile Database Support
All database-connected commands now support the --profile parameter (alias -p), enabling you to work with different database configurations without switching connections or redefining credentials.
Supported Commands with Profile Parameter
The --profile parameter is available in:
- All data operations:
export,import,dataProfile,dataDiff,dataSync,duplicateDetection,referentialCheck,tableCopy - List operations:
tables,views,indexes,functions,procedures,triggers,sequences,libraries,roles,objects,partitions,columnStats,spatialData,ftIndexes,graphWorkspaces,tableHotspots,tableGroups,calcViewAnalyzer - Analysis tools:
compareData,compareSchema,dataValidator,dataLineage,erdDiagram, and more
Profile Parameter Examples
For more details on database profile configuration, see the utils/README.md documentation.
Quality Assurance Notes
The consistency of these parameters has been standardized across all 200+ commands in the tool. This standardization ensures:
- Predictability: Users can rely on consistent parameter behavior across commands
- Discoverability: Common parameters work the same way in different contexts
- Scripting: Automation scripts are more maintainable with consistent patterns
- Error Reduction: Familiar patterns reduce mistakes and learning curve
- Multi-Environment Support: Profile parameter enables seamless switching between database instances
For detailed analysis of all command consistency improvements deployed in February 2026, including the 30 commands and 50+ parameters updated, see:
- CONSISTENCY_REVIEW_COMPLETE.md - Complete review report
- COMMAND_CONSISTENCY_FIXES.md - Implementation details
- COMMAND_CONSISTENCY_ANALYSIS.md - Detailed audit findings
For detailed information about specific commands, use the built-in help:
Commands
📊 Visual Command Reference Guide: For command structure diagrams, parameter relationships, and quick examples for all commands, see the Command Structure Reference Guide. This separate document provides visual flowcharts and detailed usage patterns for:
- Connection & setup commands
- Data operations (export, import, sync)
- Database inspection & analysis
- HDI container management
- Backup & recovery operations
- Performance analysis tools
- Mass operations
- Cloud integration
Each command diagram shows the command syntax, available parameters, and typical usage patterns.
Unit Testing
This project includes comprehensive unit tests to ensure code quality and reliability. The test suite covers core functionality, command execution, and database operations.
For detailed information about running tests, writing new tests, and understanding the test structure, please refer to the Unit Testing Documentation.
Running Tests
Quick start for running tests:
Code Coverage
The project uses nyc (Istanbul) for code coverage reporting. To generate code coverage reports:
After running coverage tests, open ./coverage/index.html in your browser to view the detailed interactive coverage report.
The project aims for 80% code coverage across:
- Lines
- Statements
- Functions
- Branches
For more information about code coverage configuration and interpretation, see the Coverage section in the Unit Testing Documentation.
Cross-Platform Support
The HANA CLI tool is designed to work seamlessly across Windows, Linux, and macOS platforms. This section describes the cross-platform features and testing strategies employed to ensure consistent behavior.
Platform Compatibility
The tool has been tested and validated on:
- Windows: Windows 10 and later
- Linux: Ubuntu, Debian, RHEL, and other major distributions
- macOS: macOS 10.15 (Catalina) and later
Cross-Platform Features
Path Handling
The tool automatically handles platform-specific path differences:
- Uses Node.js
pathmodule for all path operations - Automatically detects and uses correct path separators (
/on Unix,\on Windows) - Normalizes paths for consistent behavior across platforms
- Supports both absolute and relative paths on all platforms
Environment Variables
Platform-specific environment variables are handled correctly:
- Windows: Uses
APPDATAfor configuration files - macOS: Uses
HOME/Library/Preferenceswith fallback toHOME/Library/Application Support - Linux: Uses
HOME/.configfor configuration files
Line Endings
The project uses .gitattributes to ensure consistent line endings:
- Text files (
.js,.json,.md, etc.) use LF (\n) in the repository - Windows scripts (
.cmd,.bat,.ps1) use CRLF (\r\n) - Binary files are handled appropriately
Cross-Platform Testing
The project includes comprehensive cross-platform testing:
Continuous Integration
GitHub Actions CI runs the full test suite on all three platforms:
- Ubuntu Latest: Tests Linux compatibility
- Windows Latest: Tests Windows compatibility
- macOS Latest: Tests macOS compatibility
- Node.js versions: 20.x, 22.x, and 24.x on each platform
The CI workflow validates:
- Package installation on each platform
- All unit tests pass on each platform
- Cross-platform specific tests
- Platform-specific path handling
- CLI command execution
Mock Filesystem Testing
Tests use mock-fs to simulate different filesystem structures:
- Tests can simulate Windows, macOS, and Linux filesystems
- Validates path handling without requiring multiple OS environments
- Tests platform-specific configuration file locations
- Ensures consistent behavior across platforms
Development Recommendations
When contributing to this project, follow these cross-platform best practices:
- Always use
path.join()orpath.resolve()instead of string concatenation for paths - Use
os.EOLfor platform-appropriate line endings in generated content - Test environment variable fallbacks for Windows (
APPDATA,USERPROFILE) and Unix (HOME) - Tag platform-specific tests with
@windowsor@unixas appropriate - Use
cross-envin npm scripts for environment variable consistency - Avoid hard-coded path separators (
/or\) in code
For more details on cross-platform testing, see the Cross-Platform Testing section in the Unit Testing Documentation.
How to obtain support
This project is provided "as-is": there is no guarantee that raised issues will be answered or addressed in future releases.
License
Copyright (c) 2026 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file.
來源:README.md,提交 26cbc4e
工具
0版本歷史
1- v4.202607.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分