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. 환경 변수

변수

필수 여부

설명

예시

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