mcp-saphana
Enables querying, exploring, and bulk-exporting data from SAP HANA instances.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-saphanalist tables in SYS schema"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-saphana
MCP (Model Context Protocol) server for SAP HANA. Enables Claude and other MCP clients to query, explore, and bulk-export data from SAP HANA instances using the native hdbcli driver.
Features
Schema & table discovery — list schemas, list tables/views, search across schemas
Table introspection — column definitions, data types, nullability
Data sampling — fetch sample rows for profiling
Table statistics — row count, disk size, memory footprint (with privilege-aware fallback)
Column profiling — min/max/null count/distinct count for any column
Large volume export — chunked pagination via
LIMIT/OFFSETfor multi-million row exportsDual output formats —
markdown(human-readable) andjson(machine-readable)Privilege-safe — gracefully falls back when
MONITORINGprivilege is absent
Related MCP server: mcp-database
Architecture
server.py # FastMCP server (single file)
├── Lifespan connection # One persistent hdbcli connection per server lifetime
├── 9 MCP tools # Schema/table/column/query/export operations
└── Shared helpers # _get_conn, _cursor_to_rows, _handle_hana_error, _safe_jsonConnection strategy
Uses SAP HANA's native
hdbclidriver (not JDBC/ODBC)Single persistent connection via FastMCP lifespan context
Supports single-container, multi-tenant (system DB), and SAP HANA Cloud
TLS/SSL configurable via env vars
Large volume strategy
saphana_chunked_export wraps the user's SQL in a subquery with LIMIT/OFFSET and returns one chunk at a time. The caller increments chunk_index until has_more is false.
chunk 0: SELECT * FROM (user_sql) AS __q__ LIMIT 1000 OFFSET 0
chunk 1: SELECT * FROM (user_sql) AS __q__ LIMIT 1000 OFFSET 1000
...Setup
1. Install dependencies
pip install -e .
# or manually:
pip install mcp hdbcli pydantic python-dotenv2. Configure credentials
cp .env.example .env
# Edit .env with your HANA connection detailsHANA_HOST=your-hana-host.example.com
HANA_PORT=39015
HANA_USER=your_username
HANA_PASSWORD=your_password
# Optional — for HANA Cloud / multi-tenant:
HANA_DATABASE=
HANA_ENCRYPT=false
HANA_SSL_VALIDATE_CERTIFICATE=truePort reference:
Scenario | Port |
On-premise, single container |
|
On-premise, multi-tenant (System DB) |
|
SAP HANA Cloud |
|
3. Run
python server.pyTools
Tool | Description |
| Run any SELECT; auto-applies LIMIT via safe subquery wrap |
| List all accessible schemas |
| List tables/views in a schema; optional type/name filter |
| Column names, types, nullability, defaults |
| Sample N rows from a table |
| Row count + disk/memory size (falls back to COUNT(*) without MONITORING) |
| Paginated bulk export for large result sets |
| Search tables by partial name across all schemas |
| Min/max/null count/distinct for a single column |
Claude Desktop / MCP Client Configuration
Add to your MCP client config (e.g., ~/.claude/claude_desktop_config.json):
{
"mcpServers": {
"saphana": {
"command": "python",
"args": ["/path/to/mcp_saphana/server.py"],
"env": {
"HANA_HOST": "your-host",
"HANA_PORT": "39015",
"HANA_USER": "your_user",
"HANA_PASSWORD": "your_password"
}
}
}
}Or use a .env file and omit the env block (the server loads .env automatically).
Evaluations
evaluation.xml contains 10 read-only questions targeting stable SAP HANA system catalog objects. Run them with the MCP evaluation harness:
pip install anthropic
export ANTHROPIC_API_KEY=your_key
python scripts/evaluation.py \
-t stdio \
-c python \
-a server.py \
-e HANA_HOST=your-host \
-e HANA_USER=your_user \
-e HANA_PASSWORD=your_password \
evaluation.xmlNote: Question 8 in
evaluation.xmlhas a placeholder answer (FILL_IN_FROM_YOUR_INSTANCE). Fill it in by running:SELECT COUNT(*) FROM SYS.TABLES WHERE SCHEMA_NAME = 'SYS'
Known Limitations / Future Work
saphana_chunked_exportusesOFFSET-based pagination — performance degrades at very high offsets on large tables. For extreme volumes, consider SAP HANA's nativeEXPORTstatement or partition-key-based pagination.No write tools (
INSERT/UPDATE/DELETE) — read-only by design. Add asaphana_execute_dmltool with explicit destructive annotations if needed.No connection pooling — single persistent connection per server instance. For high-concurrency deployments, switch transport to
streamable_httpand manage a pool in the lifespan context.Evaluation question answers tied to standard HANA 2.0 SPS06+ catalog structure. Verify on your specific version.
Project Status
Area | Status |
Core server | ✅ Complete |
All 9 tools | ✅ Complete |
Privilege fallbacks | ✅ Complete |
| ✅ Complete |
Large volume export | ✅ Complete |
Evaluation file | ✅ Complete (Q8 needs instance-specific answer) |
Write tools (DML) | ❌ Not implemented |
Connection pooling | ❌ Not implemented |
Streaming HTTP transport | ❌ Not implemented (stdio only) |
Tests | ❌ Not implemented |
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/scairnx/mcp-saphana'
If you have feedback or need assistance with the MCP directory API, please join our Discord server