SAP MCP Server

SAP MCP Server

Enables AI clients to query live data from SAP HANA and SQL databases through read-only SELECT queries with CSV-formatted results.

Category
访问服务器

README

SAP MCP Server (Python)

A Python-based Model Context Protocol (MCP) Server for SAP HANA and SQL databases. This allows AI clients like Claude Desktop to query live data from SAP systems.

Features

  • SAP HANA support via hdbcli (SAP's official Python client)
  • Generic SQL support via ODBC for other databases
  • Read-only access - Only SELECT queries are allowed
  • CSV output - Results formatted for easy AI consumption
  • Simple YAML configuration

Prerequisites

  • Python 3.10 or higher
  • SAP HANA client libraries (for HANA connections)
  • ODBC drivers (for ODBC connections)

Installation

1. Clone or download this project

cd D:\_projects\sap-mcp-server-python

2. Install the package

For SAP HANA:

pip install -e ".[hana]"

For ODBC connections:

pip install -e ".[odbc]"

For both:

pip install -e ".[all]"

3. Install SAP HANA Client (for HANA connections)

The hdbcli package requires the SAP HANA Client to be installed:

  1. Download from SAP Development Tools
  2. Install the SAP HANA Client
  3. The hdbcli package will be available

Alternatively, install directly via pip (if available):

pip install hdbcli

Configuration

1. Create a configuration file

Copy the example configuration:

cp config.example.yaml config.yaml

2. Edit the configuration

For SAP HANA:

server:
  name: sap-hana
  prefix: sap_hana
  version: "1.0"

connector:
  type: hana
  host: your-hana-server.example.com
  port: 30015
  user: SYSTEM
  password: your-password

tables: []

For SAP HANA Cloud:

server:
  name: hana-cloud
  prefix: hana_cloud
  version: "1.0"

connector:
  type: hana
  host: your-instance.hana.ondemand.com
  port: 443
  user: DBADMIN
  password: your-password
  encrypt: true
  sslValidateCertificate: true

tables: []

For ODBC (SQL Server, etc.):

server:
  name: sql-server
  prefix: sql
  version: "1.0"

connector:
  type: odbc
  connection_string: "Driver={ODBC Driver 17 for SQL Server};Server=localhost;Database=mydb;UID=user;PWD=password"

tables: []

Running the Server

Standalone test

python -m sap_mcp config.yaml

If the configuration is correct, the server will start and wait for MCP requests via stdin.

With Claude Desktop

  1. Edit Claude Desktop's configuration file:

    Windows: %APPDATA%\Claude\claude_desktop_config.json

    Mac: ~/Library/Application Support/Claude/claude_desktop_config.json

  2. Add the MCP server configuration:

{
  "mcpServers": {
    "sap-hana": {
      "command": "python",
      "args": [
        "-m",
        "sap_mcp",
        "D:\\_projects\\sap-mcp-server-python\\config.yaml"
      ]
    }
  }
}
  1. Restart Claude Desktop (fully quit and reopen)

  2. Look for the MCP tools icon (hammer) in Claude Desktop

Available Tools

Once configured, the AI client will have access to these tools:

Tool Description
{prefix}_get_tables List all tables/views in the database
{prefix}_get_columns List columns for a specific table
{prefix}_run_query Execute a SQL SELECT statement

Example Usage

Ask Claude:

  • "What tables are available in SAP HANA?"
  • "Show me the columns in the CUSTOMERS table"
  • "Get the top 10 orders by value"

Configuration Reference

Field Required Description
server.name Yes Name of the MCP server
server.prefix Yes Prefix for tool names (e.g., sap_hana)
server.version No Server version (default: "1.0")
connector.type Yes Connector type: hana or odbc
connector.host HANA HANA server hostname
connector.port HANA HANA server port (default: 30015)
connector.user HANA Database username
connector.password HANA Database password
connector.encrypt No Enable SSL encryption (default: false)
connector.sslValidateCertificate No Validate SSL cert (default: true)
connector.connection_string ODBC ODBC connection string
tables No List of tables to expose (empty = all)
log_file No Path to debug log file

Troubleshooting

Server won't start

  1. Check that Python 3.10+ is installed: python --version
  2. Verify the package is installed: pip show sap-mcp-server
  3. Check configuration file syntax: python -c "import yaml; yaml.safe_load(open('config.yaml'))"

Connection fails

  1. Test connectivity to your SAP HANA server
  2. Verify credentials are correct
  3. For HANA Cloud, ensure encrypt: true is set
  4. Check firewall rules allow the port

Tools not showing in Claude Desktop

  1. Fully quit Claude Desktop (check Task Manager / Activity Monitor)
  2. Verify the config path in claude_desktop_config.json
  3. Check for typos in the JSON configuration
  4. Look at Claude Desktop logs for errors

Debug logging

Enable logging in your config:

log_file: /path/to/debug.log

Then check the log file for detailed information.

Project Structure

sap-mcp-server-python/
├── pyproject.toml          # Package configuration
├── config.example.yaml     # Example configuration
├── README.md               # This file
└── src/sap_mcp/
    ├── __init__.py
    ├── __main__.py         # Entry point
    ├── server.py           # MCP server setup
    ├── config.py           # Configuration loader
    ├── csv_utils.py        # CSV formatting
    ├── connectors/
    │   ├── base.py         # Abstract connector
    │   ├── hana.py         # SAP HANA connector
    │   └── odbc.py         # ODBC connector
    └── tools/
        ├── get_tables.py   # List tables tool
        ├── get_columns.py  # List columns tool
        └── run_query.py    # SQL query tool

License

MIT License - See LICENSE file for details.

Credits

Based on the CData MCP Server for SAP Business One.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选