RAP2 API 文档平台的 MCP (Model Context Protocol) 服务器,为 LLM 和 AI 代码编辑器提供 RAP2 接口文档访问能力。
- 接口查询:根据 ID 获取接口详情
- 仓库管理:获取仓库列表及接口列表
- 智能搜索:支持关键字和路径搜索接口
- 自动登录:支持 Cookie 或用户名密码认证,自动处理验证码
- 会话管理:自动维护登录状态,支持会话测试
- Java 8+
- Maven 3.6+
cd rap2-mcp-java
mvn clean package编译完成后,可执行 JAR 位于 target/rap2-mcp-java-0.0.1.jar
从浏览器获取 RAP2 的 Cookie 值:
{
"mcpServers": {
"rap2": {
"command": "java",
"args": ["-jar", "target/rap2-mcp-java-0.0.1.jar"],
"env": {
"RAP2_BASE_URL": "http://your-rap2-server:port",
"RAP2_SID": "your-session-id",
"RAP2_SID_SIG": "your-session-sig"
}
}
}
}{
"mcpServers": {
"rap2": {
"command": "java",
"args": ["-jar", "target/rap2-mcp-java-0.0.1.jar"],
"env": {
"RAP2_BASE_URL": "http://your-rap2-server:port",
"RAP2_EMAIL": "your-email@example.com",
"RAP2_PASSWORD": "your-password"
}
}
}
}| 变量名 | 说明 | 必填 |
|---|---|---|
RAP2_BASE_URL |
RAP2 服务器地址 | 是 |
RAP2_SID |
Session ID(Cookie 方式) | 二选一 |
RAP2_SID_SIG |
Session Signature(Cookie 方式) | 二选一 |
RAP2_EMAIL |
登录邮箱(密码方式) | 二选一 |
RAP2_PASSWORD |
登录密码(密码方式) | 二选一 |
| 工具名称 | 功能描述 |
|---|---|
rap2_test_connection |
测试连接并校验会话有效性 |
rap2_ensure_session |
使用环境参数登录并保存会话 |
rap2_debug_login_info |
调试当前登录环境配置 |
rap2_get_interface_by_id |
根据接口 ID 获取详情 |
rap2_get_repository_interfaces |
获取仓库下全部接口列表 |
rap2_search_interfaces_by_keyword |
按关键字搜索接口 |
rap2_search_interfaces_by_path |
按请求路径搜索接口 |
rap2_get_repository_list |
获取当前用户的所有仓库 |
在 AI 编辑器中,你可以这样使用:
测试 RAP2 连接是否正常
搜索用户相关的接口
获取仓库 ID 为 123 的所有接口
查询接口 ID 为 456 的详细信息
日志文件默认输出到 /tmp/rap-mcp.log,可在 application.yml 中修改:
logging:
file:
name: /your/path/to/rap-mcp.log- Spring Boot 2.7.0
- Jackson (JSON 处理)
- Logback (日志)
- MCP Protocol 2024-11-05
MIT License