Setup and Configuration
Installation, configuration, and connection setup for the MCP Server.
Installation
Prerequisites
- Node.js 22+
- npm (included with Node.js)
- SAP HANA database instance or SAP BTP HANA Cloud instance
Step 1: Install Dependencies
Navigate to the mcp-server directory and install dependencies:
cd mcp-server
npm installThe installation includes:
- TypeScript compiler and type definitions
- MCP SDK packages
- Database connection utilities
- All command implementations
Step 2: Build the Server
Compile TypeScript to JavaScript:
npm run buildThis generates:
build/index.js- Main MCP Server entry pointbuild/src/- All TypeScript source files compiled to JavaScript
All dependencies are installed automatically via the prepare script.
Step 3: Verify Installation
Test that the build was successful:
# Check build output exists
ls -la build/
# Should show:
# - index.js
# - src/ directory with compiled filesDatabase Connection Setup
The MCP Server requires a valid SAP HANA database connection. Choose one of these methods:
Method 1: SAP BTP Service Key (Recommended)
For SAP BTP HANA Cloud instances:
hana-cli serviceKey -i <instance-name> -k <key-name>This command:
- Connects to SAP Cloud Foundry
- Retrieves the service key
- Creates
default-env.jsonwith connection details - Validates the connection
Method 2: Interactive Connection Setup
Prompt-based connection configuration:
hana-cli connectThis will ask for:
- Host/Server address
- Port (default: 30013 or 443 for HANA Cloud)
- Username
- Password
- Schema name (optional)
- SSL/TLS settings
Method 3: Manual Configuration
Create a default-env.json file in your project root:
{
"VCAP_SERVICES": {
"hana": [{
"name": "my-hana-instance",
"tags": ["hana"],
"credentials": {
"host": "your-host.hanacloud.ondemand.com",
"port": "443",
"user": "DBADMIN",
"password": "YourPassword123!",
"schema": "YOURSCHEMA",
"encrypt": true,
"sslValidateCertificate": true
}
}]
}
}For on-premise HANA:
{
"VCAP_SERVICES": {
"hana": [{
"credentials": {
"host": "your-internal-server.com",
"port": "30013",
"user": "DBADMIN",
"password": "YourPassword123!",
"schema": "SYSTEM",
"encrypt": false
}
}]
}
}Method 4: Environment Variables
Set connection details via environment variables:
export HANA_CLI_HOST="your-host.hanacloud.ondemand.com"
export HANA_CLI_PORT="443"
export HANA_CLI_USER="DBADMIN"
export HANA_CLI_PASSWORD="YourPassword123!"
export HANA_CLI_SCHEMA="YOURSCHEMA"
export HANA_CLI_ENCRYPT="true"
npm run buildIDE Configuration
VS Code with Claude Dev Extension
Add the following to your Claude Dev MCP settings file:
Location:C:\Users\<username>\AppData\Roaming\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
Configuration:
{
"mcpServers": {
"hana-cli": {
"command": "node",
"args": [
"D:/projects/hana-developer-cli-tool-example/mcp-server/build/index.js"
],
"env": {}
}
}
}Notes:
- Replace the path with your actual project location
- Use forward slashes
/even on Windows - Connection credentials are read from
default-env.json
VS Code with Cline
Similar configuration, but the settings file location may differ. Check Cline documentation for your version.
Verification and Testing
Test Connection
Verify your connection is working:
hana-cli statusExpected output:
Connected to: hanacloud.ondemand.com:443
User: DBADMIN
Current Schema: YOURSCHEMA
Version: 2.0.0Common Connection Issues
Issue: "Connection refused"
- Cause: HANA instance not accessible or firewall blocking
- Solution:
- Verify host address and port
- Check firewall rules
- Ensure HANA instance is running
- Test network connectivity:
ping your-host.com
Issue: "Authentication failed"
- Cause: Invalid username or password
- Solution:
- Verify credentials in
default-env.json - Ensure user account exists and is active
- Check user privileges (needs SELECT, INSERT, UPDATE, DELETE)
- Try resetting password in SAP HANA or SAP BTP
- Verify credentials in
Issue: "Unknown host"
- Cause: Invalid hostname or DNS resolution failure
- Solution:
- Verify hostname spelling
- Check DNS/network configuration
- Try IP address instead of hostname
- Check SAP BTP service instance name
Issue: "SSL certificate error"
- Cause: Certificate validation failure (usually for HANA Cloud)
- Solution:
- Temporary: Set
sslValidateCertificate: false(development only) - Permanent: Install proper SSL certificates
- Update Node.js to latest version
- Check system clock for correct time
- Temporary: Set
Issue: "Schema not found"
- Cause: User doesn't have access to specified schema
- Solution:
- Verify schema name (case-sensitive)
- Check user privileges for schema
- Try without specifying schema (uses default)
- List available schemas:
hana-cli schemas
Debug Mode
Enable detailed diagnostics:
# Set debug environment variable
export DEBUG=hana-cli:*
# Run commands with debug output
hana-cli tables --debugThis outputs:
- Connection details
- Query statements
- Timing information
- Error stack traces
Connection Parameters Reference
Required Parameters
| Parameter | Description | Example |
|---|---|---|
host | Database server hostname or IP | hanacloud.ondemand.com |
port | Database port number | 443 (HANA Cloud), 30013 (On-premise) |
user | Database username | DBADMIN |
password | Database password | SecurePassword123! |
Optional Parameters
| Parameter | Description | Default | Example |
|---|---|---|---|
schema | Default schema for queries | SYSTEM | SALES |
encrypt | Enable SSL/TLS | true | true or false |
sslValidateCertificate | Validate SSL certificates | true | true or false |
connections | Max concurrent connections | 10 | 20 |
timeout | Query timeout in seconds | 300 | 600 |
Advanced Configuration
Multiple Database Connections
For working with multiple HANA instances, create separate configuration files:
# SAP BTP environment
hana-cli serviceKey -i prod-instance -k prod-key --output prod-env.json
# Development environment
hana-cli serviceKey -i dev-instance -k dev-key --output dev-env.jsonThen switch between environments:
export DEFAULT_ENV_FILE="prod-env.json"
hana-cli statusProxy Configuration
If behind a corporate proxy:
{
"VCAP_SERVICES": {
"hana": [{
"credentials": {
"host": "your-host.com",
"port": "443",
"user": "DBADMIN",
"password": "password",
"httpProxy": "http://proxy.company.com:8080",
"httpsProxy": "https://proxy.company.com:8080"
}
}]
}
}Connection Pooling
For high-concurrency scenarios:
{
"VCAP_SERVICES": {
"hana": [{
"credentials": {
"host": "your-host.com",
"connections": 50,
"minConnections": 10,
"maxConnections": 100
}
}]
}
}Security Best Practices
Credentials Management
Never hardcode credentials in code:
# ❌ Bad - hardcoded password
export HANA_CLI_PASSWORD="SecretPassword123!"
# ✅ Good - read from secure location
export HANA_CLI_PASSWORD=$(aws secretsmanager get-secret-value --secret-id hana-password)
# ✅ Good - use default-env.json (git-ignored)
cat default-env.json # Contains credentials
echo "default-env.json" >> .gitignoreFile Permissions
Protect configuration files:
# Restrict access to default-env.json
chmod 600 default-env.json
# Verify it's not readable by others
ls -la default-env.json
# Should show: -rw------- (600 permissions)Git Configuration
Never commit credentials:
# Add to .gitignore
echo "default-env.json" >> .gitignore
echo "*.env" >> .gitignore
echo "secrets/" >> .gitignore
# Verify no credentials in history
git log --all -- default-env.jsonSSL/TLS Verification
Always enable in production:
{
"encrypt": true,
"sslValidateCertificate": true
}Only disable for development:
{
"encrypt": true,
"sslValidateCertificate": false // Development only!
}Troubleshooting Connection
Connection Status Check
Complete diagnostic:
# 1. Test network connectivity
ping your-host.hanacloud.ondemand.com
# 2. Check configuration
cat default-env.json | grep -E "host|port|user"
# 3. Verify HANA CLI can read config
hana-cli status --debug
# 4. Test with explicit credentials
hana-cli status \
--host your-host.com \
--port 443 \
--user DBADMIN \
--password YourPassword \
--debugCommon Error Messages
| Error | Cause | Solution |
|---|---|---|
ECONNREFUSED | Connection refused | Check IP/port, firewall |
ENOTFOUND | DNS resolution failed | Verify hostname, check DNS |
ETIMEDOUT | Connection timeout | Check network, increase timeout |
401 Unauthorized | Invalid credentials | Check username/password |
403 Forbidden | Insufficient permissions | Check user privileges |
DEPTH_ZERO_SELF_SIGNED_CERT | SSL certificate issue | Use sslValidateCertificate: false |
See Troubleshooting Guide for more issues and solutions.
Next Steps
Verify Connection
bashhana-cli statusExplore Database
bashhana-cli schemas hana-cli tables --schema <name>Start Using MCP Server
- Configure your IDE with the build/index.js path
- Test with Claude Dev or your preferred client
- Try the quick start commands
Learn More
- Features Overview - All available capabilities
- Discovery Tools - Find the right commands
- Troubleshooting - Common issues