sap-b1-hana-mcp
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 服务器主机 |
|
| 否(默认 | HANA(租户)端口 |
|
| 是 | HANA 用户 |
|
| 是 | 密码 |
|
| 否 | HANA 租户(MDC) |
|
| 否 | 架构(SAP B1 公司数据库) |
|
| 否(默认 |
|
|
| 否(默认 |
|
|
Related MCP server: SAP MCP Server
MCP 工具
Tool | Descripción |
| 执行 SQL 并将行以 JSON 格式返回( |
| 验证连接:数据库、版本和当前架构。 |
| 列出实例中的架构(可选按模式过滤)。 |
| 列出某个架构中的表(可选按模式过滤)。 |
| 表的结构:列、类型、长度、小数位数、可空性。 |
关于 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 MCPMaintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides database interaction and business intelligence capabilities, enabling users to run SQL queries, analyze business data, and automatically generate business insight memos for Microsoft SQL Server databases.39MIT
- 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 gradedqualityCmaintenanceEnables 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
Related MCP Connectors
Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…
Run SOQL queries to explore and retrieve Salesforce data. Access accounts, contacts, opportunities…
Run SOQL queries to explore and retrieve Salesforce data. Inspect records, fields, and relationshi…
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/leonardows1/sap-b1-hana-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server