Skip to main content
Glama
leonardows1

sap-b1-hana-mcp

by leonardows1

sap-b1-hana-mcp

MCP-сервер (Model Context Protocol) для запросов к SAP B1 HANA с помощью прямого SQL через официальный драйвер SAP (@sap/hana-client).

Без установки: запускается с помощью npx напрямую из этого репозитория GitHub. Нужно только задать переменные окружения.

Использование

1. Требования

  • Node.js 20+ (только на машине, где выполняется агент; ничего из MCP не устанавливается).

2. Регистрация в opencode (или другом MCP-клиенте)

Добавьте этот блок в свою конфигурацию opencode (например, ~/.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
    }
  }
}

Примечание: первый запуск npx загружает и устанавливает пакет и может занять более 5 секунд. Если MCP-клиент сообщает о тайм-ауте при запуске, увеличьте "timeout": 60000 в этом блоке.

3. Переменные окружения

Переменная

Обязательная

Описание

Пример

HANA_HOST

Да

Хост сервера HANA

192.168.1.100

HANA_PORT

Нет (по умолчанию 30015)

Порт HANA (тенант)

30013

HANA_USER

Да

Пользователь HANA

USUARIO_HANA

HANA_PASSWORD

Да

Пароль

...

HANA_DATABASE

Нет

Тенант HANA (MDC)

MI_TENANT

HANA_SCHEMA

Нет

Схема (база данных компании SAP B1)

MI_EMPRESA

HANA_READONLY

Нет (по умалчанию true)

true = только запросы на чтение; false = разрешает INSERT/UPDATE/DELETE/DDL

true

HANA_SSL

Нет (по умолчанию false)

true = зашифрованное подключение (без проверки сертификата)

false

Related MCP server: SQL Server MCP Server (Diamond Inventory)

Инструменты MCP

Инструмент

Описание

execute_query

Выполняет SQL и возвращает строки в JSON (columns, rows, rowCount, truncated).

check_connection

Проверяет подключение: база данных, версия и текущая схема.

list_schemas

Перечисляет схемы экземпляра (необязательный фильтр по шаблону).

list_tables

Перечисляет таблицы схемы (необязательный фильтр по шаблону).

get_table_schema

Структура таблицы: столбцы, типы, длина, масштаб, допустимость NULL.

Важно об SQL и SAP B1

Таблицы и столбцы SAP B1 используют смешанный регистр и чувствительны к регистру: имена столбцов должны быть в двойных кавычках:

SELECT "ItemCode", "ItemName", "OnHand" FROM OITM WHERE "OnHand" > 0 ORDER BY "OnHand" DESC

Без кавычек HANA преобразует всё в верхний регистр, и запрос завершается ошибкой invalid column name.

Режим только чтения

При HANA_READONLY=true (по умолчанию) сервер отклоняет любое выражение, не являющееся SELECT, WITH, EXPLAIN, SHOW или DESCRIBE. Чтобы разрешить запись, используйте HANA_READONLY=false — под вашу ответственность.

Разработка

npm install
npm run build      # compila TypeScript a dist/
npm test           # tests unitarios (vitest)

Папка dist/ компилируется и версионируется: именно её запускает npx github:... без необходимости сборки на машине пользователя.

Архитектура

Слои с ручным внедрением зависимостей и принципами SOLID:

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 MCP

Лицензии

  • Этот проект: MIT.

  • Драйвер @sap/hana-client: SAP Developer License Agreement (распространяется как зависимость npm и не версионируется в этом репозитории). См. node_modules/@sap/hana-client/developer-license-3_2.txt.

Available Tools

5 tools
check_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.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.3/5.0
Behavior3/5

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.

Conciseness5/5

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.

Completeness5/5

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.

Parameters4/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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).

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYesSentencia SQL a ejecutar (SELECT, WITH o EXPLAIN).
limitNoMáximo de filas a devolver (por defecto 100).

TDQS

A4.7/5.0
Behavior5/5

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.

Conciseness5/5

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.

Completeness5/5

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.

Parameters4/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
tableYesNombre de la tabla (ej. OITM).
schemaYesNombre del esquema (ej. MI_EMPRESA).

TDQS

A3.8/5.0
Behavior3/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose4/5

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.

Usage Guidelines4/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
patternNoPatrón parcial del nombre del esquema (ej. PRUEBAS).

TDQS

A4/5.0
Behavior3/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
schemaYesNombre del esquema (ej. MI_EMPRESA).
patternNoPatrón parcial del nombre de tabla (ej. OITM u OIT%).

TDQS

A3.8/5.0
Behavior3/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines3/5

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.

  1. 5 tool updatesv1.0.0
    • First observedcheck_connection
    • First observedexecute_query
    • First observedget_table_schema
    • First observedlist_schemas
    • First observedlist_tables

TDQS

A4.3/5.0

Scored across 5 tools

Disambiguation5/5

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.

Naming Consistency5/5

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.

Tool Count5/5

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.

Completeness5/5

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

ActivitySlowing
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI clients to query live data from SAP HANA and SQL databases through read-only SELECT queries with CSV-formatted results.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables 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
  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides read-only analytics and metadata exploration for Dynamics NAV 2015 databases, enabling user details, permissions, table schemas, and autonomous SQL queries.
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables read-only analysis of Soft1 ERP databases through guarded T-SQL queries, schema discovery, knowledge search, and CSV/XLSX exports.
    -