一个模型上下文协议(MCP)服务器,使AI助手能够与IBM i AS/400源成员进行交互,提供无缝集成以管理源代码、编译和开发工作流程。
git clone https://github.com/[your-username]/ibmi-mcp-server.git
cd ibmi-mcp-server
npm install
npm run build
npm test
在您的MCP客户端配置中添加以下内容:
{
"mcpServers": {
"ibmi-mcp-server": {
"command": "node",
"args": ["path/to/ibmi-mcp-server/build/index.js"]
}
}
}
连接到您的IBM i系统并通过您的AI助手开始管理源成员!
# 克隆仓库
git clone https://github.com/[your-username]/ibmi-mcp-server.git
cd ibmi-mcp-server
# 安装依赖
npm install
# 构建项目
npm run build
# 运行测试
npm test
# 启动开发模式(自动重载)
npm run dev
# 安装生产依赖
npm ci --production
# 构建生产环境
npm run build
# 启动服务器
npm start
在项目根目录创建一个.env文件:
# 默认IBM i连接设置
DEFAULT_IBMI_HOST=your-ibmi-system.com
DEFAULT_IBMI_USER=your-username
DEFAULT_LIBRARY=QGPL
DEFAULT_SOURCE_FILE=QRPGLESRC
# 开发设置
NODE_ENV=development
DEBUG=false
在您的VS Code设置或MCP配置文件中添加以下内容:
{
"mcpServers": {
"ibmi-mcp-server": {
"command": "node",
"args": ["C:\\path\\to\\ibmi-mcp-server\\build\\index.js"],
"env": {
"NODE_ENV": "production"
}
}
}
}
在claude_desktop_config.json中添加以下内容:
{
“mcpServers”: {
“ibmi”: {
“command”: “node”,
“args”: [“path/to/ibmi-mcp-server/build/index.js”]
}
}
}
connect_ibmi连接到IBM i AS/400系统。
参数:
host (字符串,必需): IBM i系统主机名或IPuser (字符串,必需): 用户配置文件名password (字符串,可选): 密码port (数字,默认值: 23): 连接端口library (字符串,默认值: "QGPL"): 默认库sourceFile (字符串,默认值: "QRPGLESRC"): 默认源文件示例:
{
"host": "ibmi-system.company.com",
"user": "DEVELOPER",
"library": "MYLIB",
"sourceFile": "QRPGLESRC"
}
list_source_members列出源成员,可选过滤。
参数:
library (字符串,可选): 库名sourceFile (字符串,可选): 源物理文件名member (字符串,可选): 成员名模式type (字符串,可选): 源类型过滤器(RPGLE, DSPF等)示例:
{
"library": "MYLIB",
"sourceFile": "QRPGLESRC",
"type": "RPGLE"
}
read_source_member读取源成员内容,可选行范围。
参数:
member (字符串,必需): 源成员名library (字符串,可选): 库名sourceFile (字符串,可选): 源文件名startLine (数字,可选): 起始行号endLine (数字,可选): 结束行号示例:
{
"member": "MYPROG",
"startLine": 1,
"endLine": 100
}
write_source_member写入或更新源成员,并自动应用“5719A”源标记。
参数:
member (字符串,必需): 源成员名content (字符串,必需): 源成员内容library (字符串,可选): 库名sourceFile (字符串,可选): 源文件名sourceType (字符串,可选): 源类型(RPGLE, DSPF等)description (字符串,可选): 成员描述示例:
{
"member": "MYPROG",
"content": "// RPG代码在这里...",
"sourceType": "RPGLE",
"description": "由AI助手更新"
}
compile_source_member编译源成员。
参数:
member (字符串,必需): 源成员名library (字符串,可选): 库名sourceFile (字符串,可选): 源文件名sourceType (字符串,可选): 源类型options (字符串,可选): 编译选项示例:
{
"member": "MYPROG",
"sourceType": "RPGLE",
"options": "OPTION(*EVENTF)"
}
通过URI模板访问IBM i源成员作为MCP资源:
URI模式: ibmi://source/{library}/{sourceFile}/{member}
示例:
ibmi://source/MYLIB/QRPGLESRC/MYPROGibmi://source/TESTLIB/QDDSSRC/MYDSPFibmi://source/PRODLIB/QCPYSRC/MYCPY// 连接到IBM i
await callTool("connect_ibmi", {
host: "ibmi-system.company.com",
user: "DEVELOPER",
library: "MYLIB"
});
// 列出RPG源成员
const members = await callTool("list_source_members", {
type: "RPGLE"
});
// 读取现有源成员
const source = await callTool("read_source_member", {
member: "MYPROG"
});
// 修改源(添加您的更改)
const updatedSource = source.content + "\n// 由AI助手添加";
// 写回并自动应用源标记
await callTool("write_source_member", {
member: "MYPROG",
content: updatedSource,
sourceType: "RPGLE",
description: "由AI增强"
});
// 编译源成员
const compileResult = await callTool("compile_source_member", {
member: "MYPROG",
sourceType: "RPGLE"
});
console.log("编译:", compileResult.success ? "成功" : "失败");
// 将源成员作为资源访问
const resource = await readResource("ibmi://source/MYLIB/QRPGLESRC/MYPROG");
console.log("源内容:", resource.contents[0].text);
# 启动开发模式(自动重载)
npm run dev
# 构建项目
npm run build
# 启动服务器
npm start
# 运行测试
npm test
# 代码检查
npm run lint
# 打开MCP检查器(如果已安装)
npm run inspector
src/index.ts中定义工具:server.registerTool(
"my_new_tool",
{
description: "描述该工具的功能",
inputSchema: {
parameter1: z.string().describe("参数描述"),
parameter2: z.number().optional().describe("可选参数"),
},
},
async ({ parameter1, parameter2 }) => {
// 工具实现
return {
content: [
{
type: "text",
text: `结果: ${parameter1}`,
},
],
};
}
);
npm run build
npm test
该项目包括用于调试的VS Code配置:
所有源修改都会自动接收“5719A”源标记:
这确保了符合源标记标准并跟踪AI辅助修改。
构建失败,出现模块错误:
npm install
npm run build
服务器无法连接到IBM i:
源标记问题:
MCP客户端连接问题:
使用详细日志运行:
DEBUG=* npm start
我们欢迎贡献!请参阅我们的贡献指南了解详情。
git checkout -b feature/amazing-featurenpm run lint && npm testgit commit -m "添加精彩功能"git push origin feature/amazing-feature此项目采用MIT许可 - 详见LICENSE文件。
如果这个项目对您有帮助,请考虑给它一个星标!⭐
为IBM i社区打造,充满爱心
让您的AI助手直接与IBM i AS/400源成员交互,同时保持专业源标记标准。