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-mcpShow 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: SQL Server 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.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description takes on the full burden. It discloses that the tool verifies connectivity and returns database/version/schema, which is helpful. However, it does not state whether the operation is read-only, whether special credentials are required, or how failures are surfaced.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, focused sentence. It leads with the action and resource, then lists the return values and the diagnostic use case with no filler or redundant text.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter connectivity check with no output schema, this description gives sufficient context: what will happen, what will be returned, and why you'd call it. Nothing essential is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters, so the input schema is fully described by itself. There is no parameter semantics to add; the baseline of 4 applies, and the description appropriately does not invent irrelevant parameter guidance.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb ('Verifica') and resource ('la conexión a SAP B1 HANA'), and clarifies what it returns: database, version, and current schema. This clearly differentiates it from siblings like execute_query or list_tables, which operate on queries and table listings.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It gives a clear context for use: diagnosing the configuration of environment variables. It doesn't explicitly list exclusions or alternatives, but the diagnostic purpose is enough to distinguish it from the querying and listing siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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).
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | Sentencia SQL a ejecutar (SELECT, WITH o EXPLAIN). | |
| limit | No | Máximo de filas a devolver (por defecto 100). |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full behavioral disclosure. It reveals the read-only mode, the crucial SAP B1 mixed-case column naming rule with a double quote example, and the exact response shape including 'columns', 'rows', 'rowCount', and 'truncated' semantics.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured, starting with purpose, then constraints, a critical usage warning, and finally the response contract. Each sentence earns its place without redundancy, making it easy to consume despite the rich content.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the simple schema, no output schema, and two intuitive parameters, this description is self-contained. It defines what the tool does, the read-only constraints, the important casing/quote behavior, and what the result contains, leaving nothing essential unspecified.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is already 100%, so the schema documents both sql and limit. The description adds extra parameter-related guidance through the SQL quoting warning and example, which helps the agent construct valid queries beyond the schema's basic description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description begins with 'Ejecuta una consulta SQL contra SAP B1 HANA y devuelve las filas en JSON', naming a specific verb, target system, and return format. This clearly differentiates the tool from metadata-only siblings like list_tables and get_table_schema.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly states the default read-only mode and the restricted allowed SQL statements ('SELECT/WITH/EXPLAIN'), giving an obvious usage boundary. It does not explicitly name sibling tools or when-not-to-use cases, but the read-only restriction is a clear contextual guideline.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_table_schemaA
Devuelve la estructura (columnas, tipos, longitud, escala, nulabilidad) de una tabla de SAP B1. Útil antes de escribir consultas.
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | Nombre de la tabla (ej. OITM). | |
| schema | Yes | Nombre del esquema (ej. MI_EMPRESA). |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are present, so the description carries the responsibility of indicating behavior. It communicates that the tool is read-only and returns metadata rather than data, which is the core behavioral trait. However, it does not mention edge-case behavior such as errors when the table or schema does not exist.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two short sentences, front-loads what the tool returns, and adds a practical timing guideline with no filler. Every sentence contributes to selecting the tool correctly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple metadata retrieval tool with two fully documented parameters, the description is largely complete: it names the output fields and gives a usage context. The only minor omission is the absence of a remark about what happens when the schema or table is invalid, but this is not critical for the intended use.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema describes both parameters (table and schema) with examples and 100% coverage. The description adds no parameter-specific meaning beyond what the schema already provides, so the baseline of 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states a specific verb and resource: it returns the structure (columns, types, length, scale, nullability) of an SAP B1 table. This intrinsically separates it from execute_query and list_tables, though it does not explicitly name a sibling as the differentiator.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase 'Útil antes de escribir consultas' gives clear context for when to invoke the tool: before forming SQL queries against a table. It does not state exclusions or explicitly discuss alternatives such as list_tables or execute_query.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_schemasA
Lista los esquemas (company databases de SAP B1) de la instancia HANA, con filtro opcional por patrón de nombre.
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | No | Patrón parcial del nombre del esquema (ej. PRUEBAS). |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description bears the responsibility. It correctly conveys that the tool lists schemas and that filtering is optional, which is adequate for a simple read-only tool, but it does not disclose return format, pagination, or failure behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single sentence that front-loads the action and resource within the instance, adds the meaningful 'company databases' clarification, and closes with the optional filter. No wasted words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with one optional parameter and no output schema, the description plus the schema provide most of what an agent needs to invoke correctly. A short note on the expected return type would be slight improvement, but the intent is clear.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema already documents 'pattern' with a clear description and says schema coverage every parameter, so the description Lisa does not need to add. It only repeats the idea of an optional pattern filter without adding new semantics.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb ('Lista') and resource ('esquemas (company databases de SAP B1) de la instancia HANA'), making the tool's purpose unambiguous. The parenthetical clarification of what the schemas represent adds useful context without confusing the reader.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description clearly implies when to use the tool: to list schemas with an optional name-pattern filter. It does not explicitly name alternatives like list_tables, but the resource difference (schemas vs tables) makes the usage evident.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| schema | Yes | Nombre del esquema (ej. MI_EMPRESA). | |
| pattern | No | Patrón parcial del nombre de tabla (ej. OITM u OIT%). |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden of behavioral disclosure. It transparently communicates that the call is read-only ('Lista') and that the pattern supports wildcards via the 'OIT%' example. What is missing is how results are returned (a list of table names?), whether errors are thrown for nonexistent schemas, or any pagination/limit behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single front-loaded sentence: verb and object first, optional filter and examples second, nothing that could be removed. It is compact, readable, and the example table codes earn their place by tying the tool to a SAP B1 context.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple 2-parameter tool with full schema coverage, this is mostly complete: the description covers what the tool does and the optional filter behavior. The remaining gaps, the lack of mention of the return format and of clear guidance among the sibling list tools, are real but do not prevent an agent from calling it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents both parameters. The description adds reinforcement with concrete SAP B1 table examples but largely repeats the pattern concept already present in the pattern property ('OITM u OIT%'), providing no additional format, validation, or usage detail.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Lista') and a concrete resource ('las tablas de un esquema de SAP B1'), with real SAP B1 table identifiers (OITM, OCRD, OINV) as examples. This clearly differentiates it from siblings like list_schemas (schemas) and get_table_schema (structure of one table), because the scope is explicitly 'tables within a schema'.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The intended use is clear but implied: the agent calls this to enumerate tables of a schema, and the optional pattern filter is stated. However, there is no explicit guidance about when not to use it or which sibling to prefer, e.g., 'use list_schemas for schemas' or 'use get_table_schema for a single table'.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
5 tool updates
v1.0.0- First observed
check_connection - First observed
execute_query - First observed
get_table_schema - First observed
list_schemas - First observed
list_tables
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.
Maintenance
Related MCP Connectors
- RumboOAuthcom.rumboar
Securely query and analyze business data, dashboards, projections, alerts, and knowledge.
1 Generate, fix, explain and run read-only SQL on PostgreSQL, MySQL and SQL Server
BETA — Run SuiteQL, read/write NetSuite records, query SuiteAnalytics, and run saved bookmarks.
Ask questions in plain language, get answers from your business database. No SQL required.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI clients to query live data from SAP HANA and SQL databases through read-only SELECT queries with CSV-formatted results.MIT
- FlicenseNot gradedqualityDmaintenanceProvides secure, read-only access to Microsoft SQL Server with multi-layer protection, enabling safe query execution, schema discovery, and SQL script analysis through natural language.1-
- AlicenseNot gradedqualityDmaintenanceEnables safe, read-only querying and schema exploration for Microsoft SQL Server databases with preconfigured Diamond Inventory support, multiple database management, and optional HTTP API.MIT
- FlicenseNot gradedqualityBmaintenanceProvides read-only analytics and metadata exploration for Dynamics NAV 2015 databases, enabling user details, permissions, table schemas, and autonomous SQL queries.-