本MCP服务器借助SAP Passport认证和Playwright自动化技术,实现对SAP注释/知识库文章的搜索功能。它通过Cursor AI直接访问SAP注释和知识库文章,利用SAP Passport证书认证和Playwright浏览器自动化从SAP系统中获取实际的注释内容。
克隆仓库
git clone https://github.com/marianfoo/mcp-sap-notes
cd mcp-sap-notes
安装依赖
npm install
构建项目
npm run build
获取你的SAP Passport证书 - 仅适用于S用户
.pfx
证书文件创建证书目录
mkdir certs
复制你的SAP Passport证书
.pfx
证书文件放在certs/
目录下sap.pfx
(或者在配置中更新路径)配置环境
cp .env.example .env
编辑.env
文件并添加你的证书密码:
PFX_PATH=./certs/sap.pfx
PFX_PASSPHRASE=your_actual_passphrase
打开Cursor设置 (Cmd/Ctrl + ,
)
在settings.json
中添加MCP服务器配置:
{
"mcpServers": {
"sap-note-search": {
"command": "node",
"args": ["/full/path/to/sap-note-search-mcp/dist/mcp-server.js"]
}
}
}
⚠️ 重要提示
将
/full/path/to/sap-note-search-mcp
替换为你项目目录的实际完整路径。
重启Cursor - SAP注释工具将出现在你的AI助手界面中。
Find SAP Note 2744792
Search for SAP Notes about "OData gateway metadata error"
Get the full content of SAP Note 2744792
npm run test:auth
此命令用于测试SAP Passport认证流程并验证你的证书配置。
npm run test:api
此命令用于测试SAP注释API集成和内容提取功能。
npm run test:mcp
此命令用于模拟完整的MCP服务器工作流程。
npm run test
错误信息:"Certificate file not found"
settings.json
中使用完整的绝对路径错误信息:"Authentication failed"
HEADFUL=true
运行以查看浏览器认证过程错误信息:"Browser launch failed"
# 安装Playwright浏览器
npx playwright install
认证挂起或超时
HEADFUL=true npm run test:auth
工具未在Cursor中显示
settings.json
中的MCP服务器路径是否为绝对路径cwd
设置是否指向你的项目目录错误信息:"MCP server failed to start"
npm install
npm run build
启用调试模式以进行详细的故障排除:
# 设置调试环境变量
export HEADFUL=true
export LOG_LEVEL=debug
# 以可见浏览器模式运行测试
npm run test:auth
sap-note-search-mcp/
├── src/
│ ├── mcp-server.ts # 主MCP服务器
│ ├── auth.ts # SAP认证
│ ├── sap-notes-api.ts # SAP注释API客户端
│ ├── types.ts # TypeScript定义
│ └── logger.ts # 日志配置
├── test/
│ ├── test-auth.js # 认证测试
│ ├── test-sap-api.js # API测试
│ └── test-mcp-server.js # 完整服务器测试
├── dist/ # 编译后的JavaScript
├── certs/ # 证书目录
├── .env.example # 环境模板
└── README.md # 本文件
属性 | 详情 |
---|---|
PFX_PATH |
必需。SAP Passport证书(.pfx )的路径 |
PFX_PASSPHRASE |
必需。证书密码 |
MAX_JWT_AGE_H |
可选。默认值为12 。令牌缓存的生命周期(小时) |
HEADFUL |
可选。默认值为false 。浏览器可见性(用于调试) |
LOG_LEVEL |
可选。默认值为info 。日志级别(debug、info、warn、error) |
服务器会自动安装所需的Playwright依赖项。如需手动安装:
npx playwright install chromium
sap_note_search
通过注释ID或关键字搜索SAP注释和知识库文章。
参数:
q
(字符串,必需):查询字符串或注释IDlang
(字符串,可选):语言代码("EN" 或 "DE"),默认为 "EN"sap_note_get
检索特定SAP注释的完整内容和元数据。
参数:
id
(字符串,必需):SAP注释ID(6 - 8位数字)lang
(字符串,可选):语言代码("EN" 或 "DE"),默认为 "EN"git checkout -b feature/amazing-feature
git commit -m 'Add amazing feature'
git push origin feature/amazing-feature
本项目采用 Apache 2.0 许可证。