A

ABAP开发工具

@mario-andreschak/mcp-abap-adt
2 Stars 919 次浏览 mario-andreschak 更新于 2026-08-23

一座桥接模型上下文协议(MCP)与SAP ABAP系统的服务器,允许像Cline这样的工具获取ABAP源代码、表结构和其他开发工件。

该服务暂未提供标准配置,请参考 README 手动接入

可用工具 (13 个)

该服务在 MCP 协议中暴露的工具,AI 可按需调用

GetProgram 1 个参数 需填 1 项

Retrieve ABAP program source code

必填参数:program_name

GetClass 1 个参数 需填 1 项

Retrieve ABAP class source code

必填参数:class_name

GetFunctionGroup 1 个参数 需填 1 项

Retrieve ABAP Function Group source code

必填参数:function_group

GetFunction 2 个参数 需填 2 项

Retrieve ABAP Function Module source code

必填参数:function_name、function_group

GetStructure 1 个参数 需填 1 项

Retrieve ABAP Structure

必填参数:structure_name

GetTable 1 个参数 需填 1 项

Retrieve ABAP table structure

必填参数:table_name

GetTableContents 2 个参数 需填 1 项

Retrieve contents of an ABAP table

必填参数:table_name

GetPackage 1 个参数 需填 1 项

Retrieve ABAP package details

必填参数:package_name

GetTypeInfo 1 个参数 需填 1 项

Retrieve ABAP type information

必填参数:type_name

GetInclude 1 个参数 需填 1 项

Retrieve ABAP Include Source Code

必填参数:include_name

SearchObject 2 个参数 需填 1 项

Search for ABAP objects using quick search

必填参数:query

GetTransaction 1 个参数 需填 1 项

Retrieve ABAP transaction details

必填参数:transaction_name

GetInterface 1 个参数 需填 1 项

Retrieve ABAP interface source code

必填参数:interface_name

服务介绍

mcp-abap-adt: 通往 ABAP 开发工具 (ADT) 的门户

smithery 徽章

此项目提供了一个服务器,允许您使用 Model Context Protocol (MCP) 与 SAP ABAP 系统进行交互。可以把它想象成一座桥梁,让像 Cline(一个 VS Code 扩展)这样的工具能够与您的 ABAP 系统通信,并检索源代码、表结构等信息。这就像是拥有了一个 ABAP 开发环境的遥控器!

本指南专为初学者设计,我们将一步步地介绍所有内容。我们将涵盖:

  1. 先决条件: 开始前需要准备的内容。
  2. 安装和设置: 让一切顺利运行。
  3. 运行服务器: 在不同模式下启动服务器。
  4. 与 Cline 集成: 将此服务器连接到 Cline VS Code 扩展。
  5. 故障排除: 常见问题及解决方案。
  6. 可用工具: 可用命令列表。

1. 先决条件

在开始之前,您需要准备以下几项内容:

  • SAP ABAP 系统: 该服务器连接到现有的 ABAP 系统。你需要:

    • 系统的 URL(例如,https://my-sap-system.com:8000
    • 该系统的有效用户名和密码。
    • SAP 客户端编号(例如,100)。
    • 确保你的 SAP 系统允许通过 ADT(ABAP 开发工具)进行连接。这通常涉及确保在事务 SICF 中激活了必要的服务。你的基础管理员可以帮助你完成这项工作。具体来说,你需要以下服务处于活动状态:
      • /sap/bc/adt
    • 对于 GetTableContents 工具,你需要自定义服务 /z_mcp_abap_adt/z_tablecontent 的实现。你可以参考这个指南 这里
  • Git(或 GitHub Desktop): 我们将使用 Git 下载项目代码。你有两个选择:

    • Git: 命令行工具。下载 Git。选择适合你操作系统的版本(Windows、macOS、Linux)。按照安装说明进行安装。
    • GitHub Desktop: Git 的图形用户界面。对于初学者来说更容易上手!下载 GitHub Desktop。按照安装说明进行安装。
  • Node.js 和 npm: Node.js 是一个 JavaScript 运行时环境,它允许你在浏览器之外运行 JavaScript 代码。npm(Node 包管理器)随 Node.js 一起提供,用于安装包(代码库)。

    • 下载 Node.js。**请选择 LTS(长期支持)版本。**这是最稳定的版本。根据你的操作系统,按照安装说明进行安装。确保在安装过程中包含 npm(默认情况下通常是包含的)。
    • 验证安装: 安装完 Node.js 后,打开一个新的终端(Windows 上的命令提示符,macOS/Linux 上的 Terminal),然后输入:
      node -v
      npm -v
      
      你应该能看到 Node.js 和 npm 的版本号。如果看到错误,可能是因为 Node.js 没有正确安装,或者没有添加到系统的 PATH 中。(参见下面的故障排除)。

2. 安装与设置

现在,让我们获取项目代码并进行设置:

通过 Smithery 安装

要通过 Smithery 自动安装 MCP ABAP Development Tools Server for Cline:

npx -y @smithery/cli install @mario-andreschak/mcp-abap-adt --client cline

手动安装

  1. 克隆仓库:

    • 使用 Git(命令行):
      1. 打开终端(命令提示符或 Terminal)。
      2. 导航到你希望存储项目的目录。例如,如果你想把它放在桌面上:
        cd Desktop
        
      3. 克隆仓库:
        git clone https://github.com/mario-andreschak/mcp-abap-adt
        
      4. 进入项目目录:
        cd mcp-abap-adt  # 或者是其他文件夹名称
        
    • 使用 GitHub Desktop:
      1. 打开 GitHub Desktop。
      2. 点击 "File" -> "Clone Repository..."。
      3. 在 "URL" 标签页中,粘贴仓库 URL。
      4. 选择一个本地路径(你想在电脑上保存项目的位置)。
      5. 点击 "Clone"。
  2. 安装依赖项: 这会下载项目所需的所有必要的库。在终端中,进入根目录后运行:

    npm install
    

    这可能需要几分钟时间。

  3. 构建项目: 这会将代码编译成可执行格式。

    npm run build
    
  4. 创建 .env 文件: 这个文件存储敏感信息,如你的 SAP 凭据。非常重要的是要确保这个文件的安全。

    1. 在根目录下,创建一个名为 .env 的新文件(没有扩展名)。
    2. 使用文本编辑器(如记事本、VS Code 等)打开 .env 文件。
    3. 添加以下行,并用你的实际 SAP 系统信息替换占位符:
      重要提示:如果你的密码包含 # 字符,请确保将密码用引号括起来!
      SAP_URL=https://your-sap-system.com:8000  # 你的 SAP 系统 URL
      SAP_USERNAME=your_username              # 你的 SAP 用户名
      SAP_PASSWORD=your_password              # 你的 SAP 密码
      SAP_CLIENT=100                         # 你的 SAP 客户端
      
      重要提示: 永远不要与任何人分享你的 .env 文件,也永远不要将其提交到 Git 仓库!

3. 运行服务器

公平地说,你通常不会单独运行这个服务器。它应该被集成到像 Cline 或 Claude Desktop 这样的 MCP 客户端中。但你可以通过两种主要方式手动运行服务器:

  • 独立模式: 这种模式直接运行服务器,并且会将消息输出到终端。服务器将启动并等待客户端连接,因此除了检查是否启动外,这种模式可能没有什么用处。
  • 开发/调试模式: 这种模式使用 MCP Inspector 运行服务器。你可以在浏览器中打开它输出的 URL 并开始操作。

3.1 独立模式

要在独立模式下运行服务器,在终端中(从根目录)使用以下命令:

npm run start

你应该会在终端中看到消息,表明服务器正在运行。它将监听来自MCP客户端的连接。服务器会一直运行,直到你停止它(通常使用Ctrl+C)。

3.2 开发/调试模式(带Inspector)

此模式对于调试非常有用。

  1. 以调试模式启动服务器:
    npm run dev
    
    这将启动服务器并输出类似以下的消息:🔍 MCP Inspector 已在 http://localhost:5173 上运行 🚀
    这是您将在浏览器中打开MCP inspector时使用的URL。

4. 与Cline集成

Cline是一个VS Code扩展,它使用MCP服务器来提供语言支持。以下是将此ABAP服务器连接到Cline的方法:

  1. 安装Cline: 如果尚未安装,请在VS Code中安装“Cline”扩展。

  2. 打开Cline设置:

    • 打开VS Code设置(文件 -> 首选项 -> 设置,或按Ctrl+,)。
    • 搜索“Cline MCP 设置”。
    • 点击“在settings.json中编辑”。这将打开cline_mcp_settings.json文件。完整的路径通常是这样的:C:\Users\username\AppData\Roaming\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json(将username替换为您的Windows用户名)。
  3. 添加服务器配置: 您需要在cline_mcp_settings.json文件中的servers数组里添加一个条目。以下是一个示例:

    {
      "mcpServers": 
        {
          "mcp-abap-adt": {
            "command": "node",
            "args": [
              "C:/PATH_TO/mcp-abap-adt/dist/index.js"
            ],
            "disabled": true,
            "autoApprove": []
          }
        // ... 其他服务器配置 ...
        }
    }
    
  4. 测试连接:

    • Cline应该会自动连接到服务器。您将在“MCP Servers”面板中看到服务器出现(在Cline扩展中,顶部会有不同的按钮)。
    • 要求Cline获取程序的源代码,它应该会提到MCP服务器,并尝试使用相应的工具。

5. 故障排除

  • node -vnpm -v 出现错误:
    • 确保 Node.js 已正确安装。尝试重新安装。
    • 确保 Node.js 的安装目录已添加到系统的 PATH 环境变量中。在 Windows 上,可以通过系统属性(在开始菜单中搜索“环境变量”)来编辑环境变量。
  • npm install 失败:
    • 确保你有互联网连接。
    • 尝试删除 node_modules 文件夹并再次运行 npm install
    • 如果你在代理后面,可能需要配置 npm 使用代理。在线搜索“npm 代理设置”。
  • Cline 无法连接到服务器:
    • 检查 cline_mcp_settings.json 中的设置。它必须是 root-server 目录的正确绝对路径,并且在 Windows 上使用双反斜杠。
    • 确保服务器正在运行(使用 npm run start 检查)。
    • 重启 VS Code。
    • 或者:
    • 在你的资源管理器中导航到 mcp-abap-adt 的根文件夹,Shift+右键点击并选择“在此处打开 Powershell”。(或者打开一个 Powershell 并使用 cd C:/PATH_TO/mcp-abap-adt/ 导航到该文件夹)
    • 运行 "npm install"
    • 运行 "npm run build"
    • 运行 "npx @modelcontextprotocol/inspector node dist/index.js"
    • 在输出的 URL 上打开你的浏览器。点击左侧的“连接”。
    • 点击顶部的“工具”,然后点击“列出工具”
    • 点击 GetProgram 并在右侧输入“SAPMV45A”或任何其他报表名称作为程序名称
    • 测试并查看输出结果
  • SAP 连接错误:
    • .env 文件中验证你的 SAP 凭据。
    • 确保 SAP 系统正在运行并且可以从你的网络访问。
    • 确保你的 SAP 用户具有访问 ADT 服务所需的授权。
    • 检查交易 SICF 中是否激活了所需的 ADT 服务。
    • 如果你使用自签名证书或 SAP 系统的 http 配置有问题,请确保按照上述方法设置 TLS_REJECT_UNAUTHORIZED!

6. 可用工具

此服务器提供了以下工具,可以通过 Cline(或其他任何 MCP 客户端)使用:

Tool Name Description Input Parameters Example Usage (in Cline)
GetProgram Retrieve ABAP program source code. program_name (string): Name of the ABAP program. @tool GetProgram program_name=ZMY_PROGRAM
GetClass Retrieve ABAP class source code. class_name (string): Name of the ABAP class. @tool GetClass class_name=ZCL_MY_CLASS
GetFunctionGroup Retrieve ABAP Function Group source code. function_group (string): Name of the function group @tool GetFunctionGroup function_group=ZMY_FUNCTION_GROUP
GetFunction Retrieve ABAP Function Module source code. function_name (string), function_group (string) @tool GetFunction function_name=ZMY_FUNCTION function_group=ZFG
GetStructure Retrieve ABAP Structure. structure_name (string): Name of the DDIC Structure. @tool GetStructure structure_name=ZMY_STRUCT
GetTable Retrieve ABAP table structure. table_name (string): Name of the ABAP DB table. @tool GetTable table_name=ZMY_TABLE
GetTableContents Retrieve contents of an ABAP table. table_name (string), max_rows (number, optional, default 100) @tool GetTableContents table_name=ZMY_TABLE max_rows=50
GetPackage Retrieve ABAP package details. package_name (string): Name of the ABAP package. @tool GetPackage package_name=ZMY_PACKAGE
GetTypeInfo Retrieve ABAP type information. type_name (string): Name of the ABAP type. @tool GetTypeInfo type_name=ZMY_TYPE
GetInclude Retrieve ABAP include source code include_name (string): name of the ABAP include` @tool GetInclude include_name=ZMY_INCLUDE
SearchObject Search for ABAP objects using quick search. query (string), maxResults (number, optional, default 100) @tool SearchObject query=ZMY* maxResults=20
GetInterface Retrieve ABAP interface source code. interface_name (string): Name of the ABAP interface. @tool GetInterface interface_name=ZIF_MY_INTERFACE
GetTransaction Retrieve ABAP transaction details. transaction_name (string): Name of the ABAP transaction. @tool GetTransaction transaction_name=ZMY_TRANSACTION

相关 MCP 服务