IBM i源代码管理服务器

一个支持AI助手与IBM i AS/400系统交互的源代码管理服务器,提供源代码管理、编译和开发工作流集成功能。

  • by FanMnz
  • TypeScript
  • 本地部署
  • 7 星标
  • 更新于
在 GitHub 查看 FanMnz/ibmi-mcp-server

使用说明

IBM i MCP服务器

一种模型上下文协议(MCP)服务器,使AI助手能够与IBM i AS/400源成员进行交互,为源代码管理、编译和开发工作流提供无缝集成。

🚀 特性

  • 🔗 IBM i集成:连接到IBM i AS/400系统
  • 📂 源成员管理:读取、写入、列出和管理源成员
  • 🔧 编译支持:编译RPG、DDS和其他源代码类型
  • 🏷️ 自动源标记:将源标记“5719A”应用于所有修改
  • 🌐 MCP协议:完全符合模型上下文协议
  • 🎯 AI助手就绪:与ChatGPT、Claude和其他人工智能工具直接集成

📋 目录

⚡ 快速开始

1.安装依赖项

git clone https://github.com/[your-username]/ibmi-mcp-server.git
cd ibmi-mcp-server
npm install

2.构建服务器

npm run build

3.测试安装

npm test

4.配置MCP客户端

添加到MCP客户端配置中:

{
  "mcpServers": {
    "ibmi-mcp-server": {
      "command": "node",
      "args": ["path/to/ibmi-mcp-server/build/index.js"]
    }
  }
}

5.开始使用

连接到您的IBM i系统,并通过您的AI助手开始管理源成员!

🛠 安装

先决条件

  • Node.js 18.0.0或更高
  • npm (附带Node.js)
  • 访问IBM i AS/400系统
  • MCP兼容的AI助手或客户端

地方发展设置

# Clone the repository
git clone https://github.com/[your-username]/ibmi-mcp-server.git
cd ibmi-mcp-server

# Install dependencies
npm install

# Build the project
npm run build

# Run tests
npm test

# Start development mode (with auto-reload)
npm run dev

生产部署

# Install production dependencies only
npm ci --production

# Build for production
npm run build

# Start the server
npm start

⚙️ 配置

环境变量

创建一个 .env 项目根目录中的文件:

# Default IBM i connection settings
DEFAULT_IBMI_HOST=your-ibmi-system.com
DEFAULT_IBMI_USER=your-username
DEFAULT_LIBRARY=QGPL
DEFAULT_SOURCE_FILE=QRPGLESRC

# Development settings
NODE_ENV=development
DEBUG=false

MCP客户端集成

用于带MCP扩展的VS代码

添加到您的VS代码设置或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系统主机名或IP
  • user (字符串,必填):用户配置文件名称
  • 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 code here...",
  "sourceType": "RPGLE",
  "description": "Updated by AI assistant"
}

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/MYPROG
  • ibmi://source/TESTLIB/QDDSSRC/MYDSPF
  • ibmi://source/PRODLIB/QCPYSRC/MYCPY

💡 例子

示例1:连接并列出成员

// Connect to IBM i
await callTool("connect_ibmi", {
  host: "ibmi-system.company.com",
  user: "DEVELOPER",
  library: "MYLIB"
});

// List RPG source members
const members = await callTool("list_source_members", {
  type: "RPGLE"
});

示例2:读取和修改源代码

// Read existing source member
const source = await callTool("read_source_member", {
  member: "MYPROG"
});

// Modify the source (add your changes)
const updatedSource = source.content + "\n// Added by AI assistant";

// Write back with automatic source marking
await callTool("write_source_member", {
  member: "MYPROG", 
  content: updatedSource,
  sourceType: "RPGLE",
  description: "Enhanced by AI"
});

示例3:编译和检查结果

// Compile the source member
const compileResult = await callTool("compile_source_member", {
  member: "MYPROG",
  sourceType: "RPGLE"
});

console.log("Compilation:", compileResult.success ? "SUCCESS" : "FAILED");

示例4:使用资源

// Access source member as a resource
const resource = await readResource("ibmi://source/MYLIB/QRPGLESRC/MYPROG");
console.log("Source content:", resource.contents[0].text);

🏗 发展

开发脚本

# Start development mode with auto-reload
npm run dev

# Build the project
npm run build

# Run the server
npm start

# Run tests
npm test

# Lint code
npm run lint

# Open MCP Inspector (if installed)
npm run inspector

添加新工具

  1. 在中定义工具 src/index.ts:
server.registerTool(
  "my_new_tool",
  {
    description: "Description of what the tool does",
    inputSchema: {
      parameter1: z.string().describe("Parameter description"),
      parameter2: z.number().optional().describe("Optional parameter"),
    },
  },
  async ({ parameter1, parameter2 }) => {
    // Tool implementation
    return {
      content: [
        {
          type: "text",
          text: `Result: ${parameter1}`,
        },
      ],
    };
  }
);
  1. 构建和测试:
npm run build
npm test

VS代码开发

该项目包括用于调试的VS代码配置:

  1. 在VS Code中打开项目
  2. 在源代码中设置断点
  3. 按F5开始调试
  4. 使用调试控制台与服务器交互

🔒 安全考虑

  • 从不提交凭据 到版本控制
  • 使用环境变量 用于敏感配置
  • 实施正确的IBM i用户权限
  • 验证所有输入参数
  • 使用安全连接方法 用于IBM i访问

📄 源标记

所有源代码修改都会自动接收 “5719A” 源标记:

  • RPG来源:标记应用于位置75+
  • DDS源:标记应用于位置81+
  • 其他来源:根据源类型在适当位置应用标记

这确保了符合源标记标准,并跟踪人工智能辅助的修改。

🐛 故障排除

常见问题

构建失败,出现模块错误:

npm install
npm run build

服务器无法连接到IBM i:

  • 检查主机/端口设置
  • 验证用户凭据
  • 确保网络连接

源标记问题:

  • 源标记“5719A”自动应用
  • 检查源类型的行长度限制

MCP客户端连接问题:

  • 验证build/index.js的正确路径
  • 检查Node.js版本(需要18.0.0+)
  • 确保服务器成功构建

调试模式

运行详细日志记录:

DEBUG=* npm start

获取帮助

🤝 贡献

我们欢迎捐款!请查看我们的 贡献指南 了解详情。

快速贡献步骤

  1. 分叉存储库
  2. 创建要素分支: git checkout -b feature/amazing-feature
  3. 进行更改
  4. 如果适用,添加测试
  5. 运行质量检查: npm run lint && npm test
  6. 提交更改: git commit -m "Add amazing feature"
  7. 推送到分支: git push origin feature/amazing-feature
  8. 打开拉取请求

📜 许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。

🙏 致谢

  • 模型上下文协议 优秀SDK团队
  • IBM i社区 灵感和要求
  • VS代码 和 TypeScript 拥有出色开发工具的团队

🌟 明星历史

如果这个项目对你有帮助,请考虑给它一颗星! ⭐


内置于❤️ 面向IBM i社区

使您的AI助手能够直接与IBM i AS/400源代码成员合作,同时保持专业的源代码标记标准。