sap-b1-hana-mcp
Provides direct SQL access to SAP Business One HANA databases, including tools for executing read-only queries, verifying connections, listing schemas and tables, and retrieving table structure information.
Click on "Deploy 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., "@sap-b1-hana-mcp Show me the schema of the OITM table"
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.
sap-b1-hana-mcp
MCP (Model Context Protocol) server for querying SAP B1 HANA using direct SQL through SAP's official driver (@aps/ana-driver).
No installation required: it runs with npx directly from this GitHub repository. You only need to define environment variables.
Usage
1. Requirements
Node.js 20+ (only on the machine running the agent; nothing from the MCP is installed).
2. Register in opencode (or another MCP client)
Add this block to your opencode configuration (for example ~/ .config/opencode/opencode.json):
{
"mcp": {
"sap-b1-hana": {
"type": "local",
"command": ["npx", "-y", "github:leonardows1/sap-b1-hana-mcp"],
"environment": {
"HANA_HOST": "192.168.1.100",
"HANA_PORT": "30015",
"HANA_USER": "USUARIO_HANA",
"HANA_PASSWORD": "TU_CONTRASEÑA",
"HANA_DATABASE": "MI_TENANT",
"HANA_SCHEMA": "MI_EMPRESA",
"HANA_READONLY": "true"
},
"enabled": true
}
}
}Note: the first time
npxruns, it downloads and installs the package and may take more than 5 seconds. If the MCP client reports a timeout at startup, increase "timeout": 60000 in the block.
3. Environment variables
Variable | Required | Description | Example |
| Yes | HANA server host |
|
| No (default 30015) | HANA port (tenant) |
|
| Yes | HANA user |
|
| Yes | Password |
|
| No | HANA tenant (MDC) |
|
| No | Schema (SAP B1 company database) |
|
| No (default |
|
|
| No (default |
|
|
Related MCP server: soft1-mcp
MCP tools
Tool | Description |
| Executes SQL and returns rows in JSON ( |
| Checks the connection: database, version, and current schema. |
| Lists schemas on the instance (optional pattern filter). |
| Lists tables of a schema (optional pattern filter). |
| Table structure: columns, types, length, scale, nullability. |
Important note about SQL and SAP B1
SAP B1 tables and columns use mixed capitalization and are case‑sensitive: column names must be written between double quotes:
SELECT "ItemCode", "ItemName", "OnHand" FROM OITM WHERE "OnHand" > 0 ORDER BY "OnHand" DESCWithout quotes, HANA converts to uppercase and the query fail with invalid column name.
Read‑only mode
With HANA_READONLY=true (default), the server will not accept any statement that is not SELECT, WITH, EXPLAIN, SHOW or DESCRIBE. To enable writes, use HANA_READONLY=false — at your own risk.
Development
npm install
npm run build # compila TypeScript a dist/
npm test # tests unitarios (vitest)The dist/ folder is compiled and versioned: that is what runs when using npx github… without requiring a build on the user’s machine.
Architecture
Layers with manual dependency injection and SOLID principles:
src/
├── index.ts Composition root: DI, host MCP (stdio)
├── configuration/ HanaOptions + validación de variables de entorno
├── domain/ Modelos: QueryResult, SchemaInfo, TableInfo, ColumnInfo, StatementKind
├── application/ Abstracciones de servicios + ISqlGuard (Strategy) + clasificador SQL
├── infrastructure/ Única capa que toca @sap/hana-client: factory de conexión,
│ servicios de consulta/esquema, mapeo de datos (Buffer→base64, Date→ISO)
└── mcp/ Adaptadores delgados: registro de tools MCPLicenses
This project: MIT.
Driver
@sap/hana-client: SAP Developer License Agreement (distributed through npm dependency, not versioned in this repository). Seenode_modules/@sap/hana-client/developer-license-3_2.txt.
Available Tools
5 toolscheck_connectionA
Verifica la conexión a SAP B1 HANA y devuelve base de datos, versión y esquema actual. Útil para diagnosticar la configuración de variables de entorno.
Inputs: no named parameters.
execute_queryA
Ejecuta una consulta SQL contra SAP B1 HANA y devuelve las filas en JSON. En modo solo lectura (HANA_READONLY=true, por defecto) solo se permiten SELECT/WITH/EXPLAIN. IMPORTANTE: las tablas de SAP B1 usan nombres de columna con mayúsculas y minúsculas mezcladas; deben escribirse entre comillas dobles, ej: SELECT "ItemCode", "ItemName" FROM OITM. El resultado incluye: columns, rows, rowCount y truncated (true si hay más filas de las devueltas).
Inputs: sql (required), limit.
get_table_schemaA
Devuelve la estructura (columnas, tipos, longitud, escala, nulabilidad) de una tabla de SAP B1. Útil antes de escribir consultas.
Inputs: table (required), schema (required).
list_schemasA
Lista los esquemas (company databases de SAP B1) de la instancia HANA, con filtro opcional por patrón de nombre.
Inputs: pattern.
list_tablesA
Lista las tablas de un esquema de SAP B1 (ej. OITM, OCRD, OINV), con filtro opcional por patrón de nombre de tabla.
Inputs: schema (required), pattern.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool addresses a distinct capability: connection readiness, schema discovery, table listing, table-structure inspection, and arbitrary read-only SQL execution. There is no meaningful overlap between query execution and schema-discovery tools.
All tool names follow a consistent verb_noun pattern in lowercase snake_case: execute_query, check_connection, list_schemas, list_tables, get_table_schema. The naming is predictable and easy to reason about.
The five tools form a compact, well-scoped set for a read-only SAP B1 HANA query and exploration server. Each tool adds a necessary capability without redundancy.
The set covers the full read-only workflow: environment/connection checks, schema and table enumeration, schema detail retrieval, and query execution. There are no obvious missing operations for the server's stated purpose.
Related MCP Connectors
Securely query and analyze business data, dashboards, projections, alerts, and knowledge.
Query your own databases and Data Sets with read-only SQL, and build hosted dashboards.
Ask your databases questions in plain English, run read-only SQL and set up data alerts.
BETA — Run SuiteQL, read/write NetSuite records, query SuiteAnalytics, and run saved bookmarks.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI clients to query live data from SAP HANA and SQL databases through read-only SELECT queries with CSV-formatted results.MIT
- FlicenseNot gradedqualityDmaintenanceEnables read-only analysis of Soft1 ERP databases through guarded T-SQL queries, schema discovery, knowledge search, and CSV/XLSX exports.-
- AlicenseAqualityCmaintenanceEnables MCP clients to securely query databases, list tables, inspect table schemas, and test connections across Oracle, SQL Server, MySQL, PostgreSQL, and SQLite using read-only SQL tools.4MIT
- AlicenseAqualityBmaintenanceGives AI clients guarded access to SAP Business One over SAP HANA / MS SQL and the Service Layer OData API. SQL is read-only, enforced on the server; Service Layer is GET-only by default, with opt-in writes that require user approval unless a profile explicitly turns it off.7148 npm4MIT