abap-adt-mcp
Enables AI assistants like Claude Code to directly connect to SAP ABAP systems via the ADT REST API with read/write capabilities, featuring AI-friendly high-level tools and built-in safety measures such as read-only mode, prefix whitelisting, and automatic locking.
README
abap-adt-mcp
讓 Claude Code / Codex 直接連接 SAP ABAP ADT(ABAP Development Tools)REST API 的獨立 MCP server —— 不需要 VS Code、不需要 Eclipse,且具備完整讀寫能力。
Claude Code ◄── stdio (MCP) ──► abap-adt-mcp ◄── HTTPS (ADT REST) ──► SAP 系統
為什麼做這個?
vscode_abap_remote_fs 是很棒的專案,但它的 MCP 模式有兩個限制:必須開著 VS Code 作為橋接層,而且 MCP 工具是唯讀的。市面上其他 standalone 方案則多半把 ADT API 一對一薄包裝,把 lock/unlock 等底層步驟直接丟給 AI 操作,容易出錯並留下殘留鎖定。
本專案的設計理念:封裝成「AI 友善」的高階工作流程工具。
write_source一個工具內部自動完成:讀取現況 → 並行衝突檢查 → 語法檢查 → lock → 寫入 → unlock(try/finally 保證釋放)- 錯誤訊息經過翻譯,附帶可行動的建議(例如「請檢查 SICF 節點 /sap/bc/adt」),AI 能自行修正
- 安全優先:唯讀模式、prod 系統強制唯讀、Z*/Y* 前綴白名單、audit log
功能(MVP)
| 工具 | 說明 |
|---|---|
ping_system |
連線測試與診斷 |
search_objects |
萬用字元搜尋 ABAP 物件 |
browse_package |
瀏覽 package 內容 |
get_object_structure |
物件結構(methods / includes) |
read_source |
讀取原始碼(含行號、分段讀取、截斷保護) |
syntax_check |
語法檢查(免鎖定) |
list_transports |
查詢可用 transport requests |
write_source |
✏️ 寫入原始碼(自動鎖定編排 + 並行保護 + 可選啟用) |
activate_object |
✏️ 啟用物件 |
✏️ = 寫入工具,唯讀模式下不會註冊(AI 完全看不到)。
系統需求
- Node.js ≥ 20
- SAP 系統已啟用 ADT(SICF 節點
/sap/bc/adt)— 已在 S/4HANA 2022 / ABAP 7.56 上以此為目標開發 - SAP 使用者具備開發權限(S_DEVELOP)
快速開始(Claude Code)
# 1. 安裝
git clone https://github.com/<your-account>/abap-adt-mcp.git
cd abap-adt-mcp
npm install && npm run build
# 2. 註冊到 Claude Code(密碼建議用環境變數帶入,勿寫死)
claude mcp add abap \
--env SAP_URL=https://your-sap-host:44300 \
--env SAP_CLIENT=100 \
--env SAP_USER=DEVELOPER \
--env SAP_PASSWORD="$SAP_PASSWORD" \
--env ABAP_MCP_SYSTEM_ROLE=dev \
-- node /絕對路徑/abap-adt-mcp/dist/index.js
# 3. 在 Claude Code 中測試
# > 請用 ping_system 確認 SAP 連線
詳細設定(含 Codex、自簽憑證、唯讀模式)請見 docs/SETUP.md。
環境變數
| 變數 | 必填 | 預設 | 說明 |
|---|---|---|---|
SAP_URL |
✅ | — | 例如 https://host:44300 |
SAP_USER / SAP_PASSWORD |
✅ | — | SAP 帳密(僅從環境變數讀取) |
SAP_CLIENT |
'' |
例如 100 |
|
SAP_LANGUAGE |
EN |
登入語言 | |
ABAP_MCP_READONLY |
false |
true 時不註冊寫入工具 |
|
ABAP_MCP_SYSTEM_ROLE |
dev |
dev/qa/prod;prod 強制唯讀 |
|
ABAP_MCP_ALLOWED_PREFIXES |
Z,Y,$ |
可寫入的物件名稱前綴白名單 | |
ABAP_MCP_ALLOW_SELF_SIGNED |
false |
允許自簽憑證(限內網開發系統) | |
ABAP_MCP_AUDIT_LOG |
(停用) | 寫入操作稽核紀錄檔路徑 | |
ABAP_MCP_MAX_SOURCE_LINES |
5000 |
read_source 回傳行數上限 |
安全設計
AI 直接寫入 SAP 系統風險很高,本專案內建多層防護,詳見 docs/SECURITY.md:
- 唯讀模式 — 寫入工具不註冊,而非「註冊後拒絕」
- prod 強制唯讀 — 設定
ABAP_MCP_SYSTEM_ROLE=prod後無法以任何方式覆寫 - 前綴白名單 — 預設僅允許
Z*/Y*/$(本機物件),保護 SAP 標準物件 - 並行保護 — 寫入前比對先前讀取的版本,避免蓋掉他人變更
- 寫入前語法檢查 — 預設不讓語法錯誤的程式碼進系統
- Audit log — JSON Lines 紀錄所有寫入操作(不含憑證與原始碼內容)
- 鎖定保證釋放 — try/finally,不留殘留鎖定
開發
npm run build # tsc 編譯
npm test # vitest 單元測試(不需 SAP 系統)
Roadmap
- Phase 2:
create_object、ABAP Unit 測試、ATC、where-used - Phase 3:SQL 資料查詢(Data Preview)、ST22 dump 分析、DDIC 資訊
- Phase 4:BTP ABAP Environment(JWT / Service Key)
致謝
- abap-adt-api(Marcello Urbani, MIT)— 本專案的 ADT 存取底層
- vscode_abap_remote_fs — 架構與工具設計的重要參考
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.