HANA Cloud ML Bridge MCP server

Bridges SAP HANA Cloud databases with machine learning operations through a three-layer architecture that enables model management, execution contexts, and standardized communication for both inference and training workflows.
Back to servers
Provider
HatriGt
Release date
Mar 08, 2025
Language
Python

This Model Context Protocol server enables integration between SAP HANA Cloud Database and Cursor IDE, providing standardized interfaces for managing ML models, execution environments, and communication protocols. It acts as a bridge that allows applications to interact with models deployed on HANA Cloud.

Prerequisites

Before installing the MCP server, ensure you have:

  • Python 3.8 or newer
  • SAP HANA Cloud Database instance
  • Flask
  • HDBCLI (SAP HANA Client for Python)
  • Pandas

Installation

Step 1: Clone the Repository

git clone https://github.com/yourusername/hana-mcp-server.git
cd hana-mcp-server

Step 2: Set Up Virtual Environment

Create and activate a Python virtual environment, then install the required dependencies:

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt

Step 3: Run the Setup Script

Execute the setup script and follow the interactive prompts to configure your HANA Cloud connection:

python setup.py

Configuration

Environment Variables

The server is configured using environment variables, which can be set in a .env file in the project root:

# HANA Cloud Connection
HANA_HOST=your-hana-host.hanacloud.ondemand.com
HANA_PORT=443
HANA_USER=DBADMIN
HANA_PASSWORD=your-secure-password

# Server Configuration
SERVER_PORT=5000
LOG_LEVEL=INFO
ENABLE_SSL=false
SSL_CERT_PATH=/path/to/cert.pem
SSL_KEY_PATH=/path/to/key.pem

# Security Settings
AUTH_REQUIRED=true
API_KEY=your-api-key
ALLOWED_ORIGINS=https://cursor.sh,http://localhost:3000

Configuration Options

  • HANA Connection:

    • HANA_HOST: Your HANA Cloud instance hostname
    • HANA_PORT: Port number (typically 443 for cloud instances)
    • HANA_USER: Database username
    • HANA_PASSWORD: Database password
  • Server Settings:

    • SERVER_PORT: Port on which the MCP server will listen
    • LOG_LEVEL: Logging detail level (DEBUG, INFO, WARNING, ERROR)
    • ENABLE_SSL: Whether to use HTTPS (true/false)
    • SSL_CERT_PATH and SSL_KEY_PATH: Paths to SSL certificates if enabled
  • Security:

    • AUTH_REQUIRED: Whether API authentication is required
    • API_KEY: Authentication key for accessing the API
    • ALLOWED_ORIGINS: Comma-separated list of allowed CORS origins

Running the Server

Starting the Server

Once configured, start the MCP server with:

python server.py

For production environments, consider using a WSGI server like Gunicorn:

gunicorn -w 4 -b 0.0.0.0:5000 server:app

Verifying the Server

Check if the server is running correctly by accessing the health endpoint:

curl http://localhost:5000/api/health

You should receive a JSON response with status information.

Using the API

Authentication

If authentication is enabled, include the API key in all requests:

curl -H "X-API-Key: your-api-key" http://localhost:5000/api/models

Managing Models

List Available Models

curl -H "X-API-Key: your-api-key" http://localhost:5000/api/models

Register a New Model

curl -X POST -H "Content-Type: application/json" -H "X-API-Key: your-api-key" \
     -d '{"name": "sentiment_analysis", "version": "1.0", "description": "Sentiment analysis model", "schema": {"input": "string", "output": "classification"}}' \
     http://localhost:5000/api/models

Get Model Details

curl -H "X-API-Key: your-api-key" http://localhost:5000/api/models/sentiment_analysis/1.0

Managing Contexts

Create an Execution Context

curl -X POST -H "Content-Type: application/json" -H "X-API-Key: your-api-key" \
     -d '{"model_id": "sentiment_analysis", "model_version": "1.0", "parameters": {"batch_size": 32}}' \
     http://localhost:5000/api/contexts

Execute a Model in Context

curl -X POST -H "Content-Type: application/json" -H "X-API-Key: your-api-key" \
     -d '{"input": "This product is amazing!"}' \
     http://localhost:5000/api/contexts/{context_id}/execute

Cursor IDE Integration

The MCP server integrates with Cursor IDE through a dedicated endpoint:

curl -X POST -H "Content-Type: application/json" -H "X-API-Key: your-api-key" \
     -d '{"query": "SELECT * FROM CUSTOMER WHERE REGION = \"EAST\"", "context": "data_exploration"}' \
     http://localhost:5000/api/cursor/execute

Troubleshooting

Common Issues

  • Connection Errors: Verify your HANA Cloud credentials and network connectivity
  • Authentication Failures: Check that your API key matches the one in the configuration
  • Missing Models: Ensure models are properly registered before attempting to use them
  • Context Errors: Verify that the context ID exists and is associated with a valid model

Logging

Check the server logs for detailed error information:

tail -f logs/mcp_server.log

You can increase verbosity by setting LOG_LEVEL=DEBUG in your .env file.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later