npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@qwe8652591/abap-mcp

v1.0.8

Published

ABAP MCP Server - 提供 ABAP 相关功能的 MCP 服务器

Readme

ABAP MCP Server

ABAP MCP Server 是一个实现了 Model Context Protocol (MCP) 的服务器,为 Cursor 等 AI 工具提供 ABAP 相关的工具和资源访问能力。

功能特性

  • 🔧 工具(Tools):提供 ABAP 解析、分析等功能
  • 📦 资源(Resources):访问 ABAP 代码库和元数据
  • 💬 提示(Prompts):预定义的 ABAP 相关提示模板

快速开始

1. 安装依赖

npm install

2. 配置环境变量

复制 env.example 文件为 .env

cp env.example .env

编辑 .env 文件,配置相关参数:

# 启用本地复制模式(用于模拟下载)
ABAP_LOCAL_COPY_MODE=false

# 本地项目路径(如果启用本地复制模式)
ABAP_LOCAL_COPY_PATH=/path/to/your/abap-projects

环境变量说明:

  • ABAP_LOCAL_COPY_MODE: 设置为 true 启用本地复制模式,从本地项目复制代码而非下载
  • ABAP_LOCAL_COPY_PATH: 本地 ABAP 项目的基础路径,默认为 <workspace>/abap-projects

详细配置说明请查看 ENV_CONFIG.md

3. 构建项目

npm run build

4. 运行服务器

npm start

使用 MCP Inspector 测试

MCP Inspector 是一个可视化工具,用于测试和调试 MCP 服务器。

方法 1: 使用 npm 脚本(推荐)

npm run inspector

方法 2: 使用测试脚本

./test-inspector.sh

方法 3: 直接运行

npx @modelcontextprotocol/inspector node dist/index.js

详细的测试指南请查看 TEST_GUIDE.md

环境变量配置

本项目支持通过 .env 文件配置运行参数。

本地复制模式

当您没有真实的 SAP 系统连接时,可以启用本地复制模式来模拟下载过程:

配置步骤:

  1. 确保您有本地 ABAP 项目(包含 source 目录)
  2. 编辑 .env 文件:
    ABAP_LOCAL_COPY_MODE=true
    ABAP_LOCAL_COPY_PATH=/Volumes/work/workspace/reverse-engineering/abap-projects

工作原理:

  • 系统会在 ABAP_LOCAL_COPY_PATH 目录下搜索匹配的项目
  • 支持精确匹配和模糊匹配(不区分大小写)
  • 如果找到匹配项目,复制其 source 目录
  • 如果未找到,自动回退到下载模式

匹配示例:

假设本地有项目 abap-projects/RM_MEPO_GUI/

  • 输入 RM_MEPO_GUI → ✅ 精确匹配
  • 输入 MEPO → ✅ 包含匹配
  • 输入 mepo → ✅ 包含匹配(不区分大小写)

详细说明请参考 ENV_CONFIG.md

在 Cursor 中配置

  1. 打开 Cursor 设置
  2. 进入 MCP 服务器配置
  3. 添加新的服务器配置:
{
  "mcpServers": {
    "abap-mcp": {
      "command": "node",
      "args": ["/path/to/packages/abap-mcp/dist/index.js"]
    }
  }
}

可用工具

analyze_abap(核心功能)

下载 ABAP 代码,解析屏幕信息,并生成 Excel 报告。

参数:

  • downloadType (string): 下载类型 - program, tcode, class, function
  • name (string): 对象名称(如程序名 SAPLMEGUI)
  • filters (object, 可选): 过滤选项
    • includeControls (boolean): 是否包含控件
    • includePBO (boolean): 是否包含 PBO 模块
    • includePAI (boolean): 是否包含 PAI 模块
    • screenNumbers (string[]): 指定屏幕编号
    • controlTypes (string[]): 指定控件类型
  • outputFileName (string, 可选): 输出文件名

示例:

{
  "downloadType": "program",
  "name": "SAPLMEGUI",
  "filters": {
    "includeControls": true,
    "screenNumbers": ["0014", "0015"]
  },
  "outputFileName": "megui-analysis.xlsx"
}

输出:

  • Excel 文件,包含 4 个工作表:
    1. 屏幕概览
    2. 控件详情
    3. PBO-PAI模块
    4. 统计信息

详细使用说明请查看 USAGE_EXAMPLE.md

list_abap_parsers

列出可用的 ABAP 解析能力。

参数:

hello_abap

测试工具,返回问候语。

参数:

  • name (string): 要问候的名字

开发

项目结构

packages/abap-mcp/
├── src/
│   └── index.ts          # 主服务器实现
├── dist/                 # 编译输出
├── package.json
├── tsconfig.json
└── README.md

添加新工具

使用 server.tool() 方法注册新工具:

import { z } from "zod";

server.tool(
  "tool_name",
  "Tool description",
  z.object({
    param: z.string().describe("Parameter description"),
  }),
  async (args) => {
    // 工具实现
    return {
      content: [
        {
          type: "text",
          text: "Result",
        },
      ],
    };
  }
);

添加资源

使用 server.resource() 方法注册资源:

server.resource(
  "resource-uri",
  "Resource description",
  async () => {
    return {
      contents: [
        {
          uri: "resource-uri",
          mimeType: "text/plain",
          text: "Resource content",
        },
      ],
    };
  }
);

技术栈

  • TypeScript: 类型安全的 JavaScript
  • @modelcontextprotocol/sdk: MCP 官方 SDK
  • Zod: Schema 验证和类型推断
  • stdio: 本地进程通信

许可证

MIT

相关资源