Model Context Server Protocol for your HANA DB
Model Context Protocol (MCP) server for seamless SAP HANA database integration with AI agents and development tools.
The SAP HANA MCP Server provides a robust, production-ready bridge between AI applications and SAP HANA databases through the Model Context Protocol (MCP). Designed for enterprise environments, it offers comprehensive database management capabilities with secure, scalable architecture.
hana-mcp-server/
├── 📁 src/
│ ├── 🏗️ server/ # MCP Protocol & Server Management
│ │ ├── index.js # Main server entry point
│ │ ├── mcp-handler.js # JSON-RPC 2.0 implementation
│ │ └── lifecycle-manager.js # Server lifecycle management
│ ├── 🛠️ tools/ # Tool Implementations
│ │ ├── index.js # Tool registry & discovery
│ │ ├── config-tools.js # Configuration management
│ │ ├── schema-tools.js # Schema exploration
│ │ ├── table-tools.js # Table operations
│ │ ├── index-tools.js # Index management
│ │ └── query-tools.js # Query execution
│ ├── 🗄️ database/ # Database Layer
│ │ ├── hana-client.js # HANA client wrapper
│ │ ├── connection-manager.js # Connection management
│ │ └── query-executor.js # Query execution utilities
│ ├── 🔧 utils/ # Shared Utilities
│ │ ├── logger.js # Structured logging
│ │ ├── config.js # Configuration management
│ │ ├── validators.js # Input validation
│ │ └── formatters.js # Response formatting
│ └── 📋 constants/ # Constants & Definitions
│ ├── mcp-constants.js # MCP protocol constants
│ └── tool-definitions.js # Tool schemas
├── 🧪 tests/ # Testing Framework
├── 📚 docs/ # Documentation
├── 📦 package.json # Dependencies & Scripts
└── 🚀 hana-mcp-server.js # Main entry point
npm install -g hana-mcp-server
Update your Claude Desktop configuration file:
macOS: ~/.config/claude/claude_desktop_config.json
Linux: ~/.config/claude/claude_desktop_config.json
Windows: %APPDATA%\claude\claude_desktop_config.json
{
"mcpServers": {
"HANA Database": {
"command": "hana-mcp-server",
"env": {
"HANA_HOST": "your-hana-host.com",
"HANA_PORT": "443",
"HANA_USER": "your-username",
"HANA_PASSWORD": "your-password",
"HANA_SCHEMA": "your-schema",
"HANA_SSL": "true",
"HANA_ENCRYPT": "true",
"HANA_VALIDATE_CERT": "true",
"LOG_LEVEL": "info"
}
}
}
}
Close and reopen Claude Desktop to load the new configuration.
Ask Claude: “Test the HANA database connection” or “Show me the available schemas”
That’s it! 🎉 Your HANA MCP Server is now ready to use.
Variable | Required | Description | Default |
---|---|---|---|
HANA_HOST |
✅ | HANA database hostname | - |
HANA_PORT |
✅ | HANA database port | 443 |
HANA_USER |
✅ | Database username | - |
HANA_PASSWORD |
✅ | Database password | - |
HANA_SCHEMA |
❌ | Default schema | - |
HANA_SSL |
❌ | Enable SSL connection | true |
HANA_ENCRYPT |
❌ | Enable encryption | true |
HANA_VALIDATE_CERT |
❌ | Validate SSL certificate | true |
LOG_LEVEL |
❌ | Logging level | info |
The server intelligently handles schema selection:
Scenario | Behavior |
---|---|
HANA_SCHEMA set |
Uses default schema for optional parameters |
HANA_SCHEMA not set |
Requires explicit schema specification |
Schema parameter provided | Overrides default schema |
Once configured, you can interact with your HANA database using natural language:
You can also run the server directly:
## Start with environment variables
HANA_HOST="your-host" HANA_USER="your-user" HANA_PASSWORD="your-pass" hana-mcp-server
## Or set environment variables first
export HANA_HOST="your-host"
export HANA_USER="your-user"
export HANA_PASSWORD="your-pass"
hana-mcp-server
Tool | Description | Parameters |
---|---|---|
hana_show_config |
Display current HANA configuration | None |
hana_test_connection |
Test database connectivity | None |
hana_show_env_vars |
Show environment variables (debug) | None |
Tool | Description | Parameters |
---|---|---|
hana_list_schemas |
List all database schemas | None |
hana_list_tables |
List tables in a schema | schema_name (optional) |
hana_describe_table |
Show table structure | schema_name , table_name |
hana_list_indexes |
List indexes for a table | schema_name , table_name |
hana_describe_index |
Show index details | schema_name , table_name , index_name |
Tool | Description | Parameters |
---|---|---|
hana_execute_query |
Execute SQL queries | query |
hana_execute_parameterized_query |
Execute parameterized queries | query , parameters |
hana_get_sample_data |
Get sample data from table | schema_name , table_name , limit |
hana_count_rows |
Count rows in a table | schema_name , table_name |
Tool | Description | Parameters |
---|---|---|
hana_get_system_info |
Get system information | None |
hana_get_user_info |
Get current user information | None |
hana_get_memory_usage |
Get memory usage statistics | None |
All tools return standardized JSON responses:
{
"content": [
{
"type": "text",
"text": "Tool execution result"
}
],
"isError": false,
"error": null
}
## Clone repository
git clone https://github.com/hatrigt/hana-mcp-server.git
cd hana-mcp-server
## Install dependencies
npm install
## Start development server with auto-reload
npm run dev
// src/tools/my-tools.js
const { logger } = require('../utils/logger');
const Formatters = require('../utils/formatters');
class MyTools {
static async myNewTool(args) {
logger.tool('my_new_tool', args);
try {
// Tool implementation
const result = await this.performOperation(args);
return Formatters.createResponse(result);
} catch (error) {
logger.error('Tool execution failed', error);
return Formatters.createErrorResponse(error.message);
}
}
static async performOperation(args) {
// Tool logic implementation
return "Operation completed successfully";
}
}
module.exports = MyTools;
// src/tools/index.js
const MyTools = require('./my-tools');
const TOOL_IMPLEMENTATIONS = {
// ... existing tools
my_new_tool: MyTools.myNewTool
};
// src/constants/tool-definitions.js
{
name: "my_new_tool",
description: "Performs a specific operation with detailed description",
inputSchema: {
type: "object",
properties: {
parameter1: {
type: "string",
description: "Description of parameter1"
},
parameter2: {
type: "number",
description: "Description of parameter2"
}
},
required: ["parameter1"]
}
}
{
"scripts": {
"start": "node hana-mcp-server.js",
"dev": "nodemon hana-mcp-server.js",
"test": "node tests/automated/test-mcp-inspector.js"
}
}
Issue | Cause | Solution |
---|---|---|
“Connection refused” | Network connectivity | Verify HANA host and port accessibility |
“Authentication failed” | Invalid credentials | Check username/password in configuration |
“SSL certificate error” | Certificate validation | Configure HANA_VALIDATE_CERT=false or install valid certificates |
Issue | Cause | Solution |
---|---|---|
“MCP server not visible” | Configuration path | Verify Claude Desktop config file location |
“Tools disabled” | Protocol compliance | Check JSON-RPC implementation and tool structure |
“Handler is not a function” | Tool registration | Verify tool implementation and registration |
## Set debug logging
export LOG_LEVEL="debug"
export ENABLE_FILE_LOGGING="true"
export ENABLE_CONSOLE_LOGGING="true"
## Monitor logs
tail -f hana-mcp-server.log
## Test with minimal configuration
HANA_HOST="test" HANA_USER="test" HANA_PASSWORD="test" hana-mcp-server
## Test specific functionality
echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"hana_test_connection","arguments":{}}}' | hana-mcp-server
The server uses standard JSON-RPC 2.0 error codes:
Code | Description | Action |
---|---|---|
-32700 |
Parse error | Check JSON format |
-32600 |
Invalid request | Verify request structure |
-32601 |
Method not found | Check method name |
-32602 |
Invalid params | Verify parameter format |
-32603 |
Internal error | Check server logs |
We welcome contributions from the community! Please follow these guidelines:
git checkout -b feature/amazing-feature
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Performance improvement
## Testing
- [ ] MCP Inspector tests pass
- [ ] Manual testing completed
- [ ] No breaking changes
## Checklist
- [ ] Code follows existing patterns
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] No breaking changes
This project is licensed under the MIT License - see the LICENSE{:target=“_blank”} file for details.
An MCP (Model Context Protocol) server for executing macOS terminal commands with ZSH shell. This server provides a secure way to execute shell commands with built-in whitelisting and approval mechanisms.
DevEnvInfoServer - Cursor MCP Server for Development Environment Information
A Python-based MCP (Model Context Protocol) server that predicts the origin