Skip to main content
Glama
leonardows1

sap-b1-hana-mcp

by leonardows1

sap-b1-hana-mcp

MCP (Model Context Protocol) サーバーで、SAP公式ドライバー (@sap/hana-client) 経由の直接SQLで SAP B1 HANA を照会します。

インストール不要: このGitHubリポジトリから直接 npx で実行できます。環境変数を定義するだけです。

使用方法

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. 環境変数

Variable

必須

説明

例

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