使用说明
ILE-RPG&DSPF Code Checker
An MCP server that checks compliance with ILE-RPG syntax and coding standards.
Overview
This MCP server analyzes ILE-RPG source code and detects issues such as:
- Specification order errors
- Column position rule violations
- Line continuation errors
- Naming convention violations
- Use of deprecated features
- Best practice violations
Features
Check Functions
-
Structure Check
- Specification order (H→F→D→P→I→C→O) with P-procedure section awareness
- Column position rules for each specification (H/F/D/P/C)
- D-spec advanced validation (name continuation
..., declaration type placement, trailing period detection) - Line length limit (maximum 100 columns)
- DBCS (Double-Byte Character Set) support with shift character consideration
-
Syntax Check
- Line continuation rule validation
- Prohibition of multiple statements on one line
- /FREE and /END-FREE correspondence
- Correct use of **FREE format
- Parentheses and string literal matching
-
Naming Convention Check
- Variable and procedure name conventions
- Special character usage restrictions
- Meaningful name recommendations
- Reserved word checking (strict level)
-
Best Practice Check
- Detection of 16 deprecated features (GOTO, TAG, MOVE, MOVEL, Z-ADD, Z-SUB, etc.)
- Warning for numbered indicators (*IN01-*IN99)
- Recommendation for fully free format
- Custom rule support
-
Common Error Detection
- F-spec space shortage
- D-spec column position errors (including column shift heuristics)
- Continuation line errors
Check Levels
- basic: Basic checks (specification order, critical syntax errors)
- standard: Standard checks (basic + column positions, line continuation, etc.)
- strict: Strict checks (standard + naming conventions, best practices)
Multi-language Support
- English (en): Default language
- Japanese (ja): Full Japanese support for all messages and reports
DBCS Support
When considerDBCS option is enabled, the checker accounts for shift-in (SI) and shift-out (SO) characters used in DBCS strings (Japanese, Chinese, Korean). This ensures accurate column position validation when DBCS characters are present.
Custom Rules
Users can define custom best practice rules in a JSON file. Rules support:
- Pattern-based matching (regex)
- Custom severity levels
- Enable/disable functionality
- Rule descriptions and suggestions
Installation
Prerequisites
- Node.js 18 or higher
- npm
Setup
- Install dependencies:
cd /path/to/ilerpg-code-checker
npm install
- Build:
npm run build
- Add to MCP configuration file:
For IBM Bob IDE
Add the following to c:\Users\user\AppData\Roaming\Bob-IDE\User\globalStorage\ibm.bob-code\settings\mcp_settings.json:
{
"mcpServers": {
"ilerpg-code-checker": {
"command": "node",
"args": ["<path-to-project>\\build\\index.js"],
"disabled": false,
"alwaysAllow": [],
"disabledTools": []
}
}
}
For Claude Desktop
Add to your Claude Desktop MCP settings file (typically ~/Library/Application Support/Claude/claude_desktop_config.json on macOS or %APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"ilerpg-code-checker": {
"command": "node",
"args": ["<path-to-project>/build/index.js"]
}
}
}
For Cline (VS Code Extension)
Add to your Cline MCP settings in VS Code:
{
"mcpServers": {
"ilerpg-code-checker": {
"command": "node",
"args": ["<path-to-project>/build/index.js"]
}
}
}
Note: Replace <path-to-project> with the actual absolute path to your ilerpg-code-checker directory.
Usage
MCP Tools
Note on Token Efficiency: When checking files, prefer using check_rpg_file over check_rpg_code. The check_rpg_file tool reads files directly on the server side, significantly reducing token usage compared to passing entire code content through check_rpg_code. This is especially important for large files or when checking multiple files.
1. check_rpg_code
Checks entire RPG source code. Note: For better token efficiency, consider using check_rpg_file when checking files.
use_mcp_tool({
server_name: "ilerpg-code-checker",
tool_name: "check_rpg_code",
arguments: {
code: "H DFTACTGRP(*NO)\n...",
checkLevel: "standard", // "basic" | "standard" | "strict"
language: "en", // "en" | "ja"
considerDBCS: false, // true to consider DBCS shift characters
customRulesPath: "./custom-rules.json" // Optional
}
})
Return value:
{
"valid": false,
"issues": [
{
"severity": "error",
"category": "structure",
"line": 10,
"column": 7,
"message": "Invalid specification order...",
"rule": "SPEC_ORDER",
"suggestion": "..."
}
],
"summary": {
"totalIssues": 5,
"errors": 2,
"warnings": 2,
"infos": 1,
"checkedLines": 100
}
}
2. check_specification_order
Checks specification order only.
use_mcp_tool({
server_name: "ilerpg-code-checker",
tool_name: "check_specification_order",
arguments: {
code: "H DFTACTGRP(*NO)\n...",
language: "en" // "en" | "ja"
}
})
3. check_column_positions
Checks column position rules.
use_mcp_tool({
server_name: "ilerpg-code-checker",
tool_name: "check_column_positions",
arguments: {
code: "H DFTACTGRP(*NO)\n...",
language: "en", // "en" | "ja"
considerDBCS: false // true to consider DBCS shift characters
}
})
4. check_naming_conventions
Checks naming conventions.
use_mcp_tool({
server_name: "ilerpg-code-checker",
tool_name: "check_naming_conventions",
arguments: {
code: "D MyVar S 10A\n...",
language: "en" // "en" | "ja"
}
})
5. check_best_practices
Checks best practices.
use_mcp_tool({
server_name: "ilerpg-code-checker",
tool_name: "check_best_practices",
arguments: {
code: "C GOTO Label\n...",
language: "en", // "en" | "ja"
customRulesPath: "./custom-rules.json" // Optional
}
})
6. check_rpg_file
Checks file by file. Recommended: This tool is more efficient than check_rpg_code as it reduces token usage by reading files directly on the server side.
use_mcp_tool({
server_name: "ilerpg-code-checker",
tool_name: "check_rpg_file",
arguments: {
filePath: "//your-server/path/to/your-file.rpg",
checkLevel: "standard",
language: "en", // "en" | "ja"
considerDBCS: false, // true to consider DBCS shift characters
customRulesPath: "./custom-rules.json" // Optional
}
})
Custom Rules
Create a JSON file to define custom best practice rules:
{
"rules": [
{
"id": "no-select-all",
"name": "Avoid SELECT *",
"description": "Using SELECT * is not recommended",
"pattern": "SELECT\\s+\\*",
"severity": "warning",
"suggestion": "Specify column names explicitly",
"enabled": true
},
{
"id": "require-error-handling",
"name": "Error handling required",
"description": "All file operations should have error handling",
"pattern": "CHAIN|READ|WRITE|UPDATE|DELETE",
"severity": "info",
"suggestion": "Add error handling with %ERROR or *IN99",
"enabled": true
}
]
}
Custom Rule Properties
id: Unique identifier for the rulename: Display namedescription: Detailed descriptionpattern: Regular expression pattern to matchseverity: "error" | "warning" | "info"suggestion: Recommendation for fixing the issueenabled: true | false
Examples of Detected Issues
Structure Errors
F-spec
H-spec ← Error: H-spec must be placed before F-spec
Column Position Errors
D MyVariable S 10A ← Error: Variable name is not in correct column position
Line Continuation Errors
D MyLongVariableName
D- S 10A ← Error: Continuation line spec type mismatch
Naming Convention Violations
D x S 10A ← Warning: Variable name is too short
D 1stVar S 10A ← Error: Variable name cannot start with a number
Deprecated Features
C GOTO Label ← Warning: GOTO is deprecated
C Label TAG
DBCS Example
When considerDBCS: true:
D MyVar S 10A INZ('日本語')
↑ Correctly accounts for shift characters in column position check
The checker also validates EBCDIC byte length once DBCS shift (SO/SI) bytes are counted:
- Comment lines (
*fixed-form or//free-form) over 80 EBCDIC bytes → warning (COMMENT_LINE_EBCDIC_OVERFLOW). Past 80 bytes the compile listing garbles; past 100 bytes the source is truncated byCPYFRMSTMF(reported asLINE_LENGTHerror). - Comment area (columns 81-100) over 20 EBCDIC bytes → warning (
COMMENT_DBCS_OVERFLOW).
Development
Project Structure
ilerpg-code-checker/
├── package.json
├── tsconfig.json
├── README.md # Documentation (English)
├── README.ja.md # Documentation (Japanese)
├── DESIGN.md # Architecture & design document
├── custom-rules.example.json # Custom rules example
├── src/
│ ├── index.ts # MCP server entry point
│ ├── orchestrator.ts # Check orchestration
│ ├── parser/
│ │ ├── rpg-parser.ts # RPG code parser
│ │ └── line-analyzer.ts # Line analysis
│ ├── checkers/
│ │ ├── structure-checker.ts # Spec order & column validation
│ │ ├── syntax-checker.ts # Syntax & format validation
│ │ ├── naming-checker.ts # Naming convention validation
│ │ ├── best-practice-checker.ts # Deprecated features & best practices
│ │ └── common-errors-checker.ts # Common error patterns
│ ├── i18n/
│ │ └── messages.ts # Multi-language messages (en/ja)
│ ├── config/
│ │ └── custom-rules.ts # Custom rules manager
│ ├── types/
│ │ └── index.ts # Type definitions
│ └── utils/
│ ├── file-reader.ts # File I/O operations
│ ├── reporter.ts # Report formatting
│ └── dbcs-helper.ts # DBCS support utilities
└── build/ # Compiled output
Build
npm run build
Development Mode (Auto-build)
npm run watch
Troubleshooting
MCP Server Won't Start
- Check Node.js version:
node --version(18 or higher required) - Verify build is complete: Check if
build/index.jsexists - Verify MCP configuration file path is correct
Check Results Not Displayed
- Check source code encoding (UTF-8 recommended)
- Verify file path is correct
- Check MCP server logs
License
MIT
Author
guricat
Version
0.0.17
Changelog
0.0.17 (2026-08-07)
- The server now reads its version from package.json at runtime
- The hardcoded version in
src/index.ts('0.0.15') was missed in the v0.0.16 release, so package.json (0.0.16) and the server's reported version (0.0.15) disagreed (reported by a consuming project). From now on only the package.json version needs updating
- The hardcoded version in
- Resolved dependency vulnerabilities (
npm audit: 8 → 0)- @modelcontextprotocol/sdk 1.25.3 → 1.30.0 (GHSA-345p-7cg4-v4c7: cross-client data leak via shared server/transport instance reuse), plus transitive dependency updates (hono / @hono/node-server / fast-uri / path-to-regexp / ajv / body-parser). All within semver-compatible ranges, so only package-lock.json changed
- No change to checker detection logic. All four regression suites pass; all five samples remain at 0 errors
0.0.16 (2026-06-16)
- Added detection of comment lines exceeding 80 EBCDIC bytes:
COMMENT_LINE_EBCDIC_OVERFLOW(warning, only when DBCS handling is enabled)- Comment lines with Japanese (DBCS) text reaching 80–100 EBCDIC bytes slipped through every length check (checkLineLength only errors past 100 bytes; checkCommentArea only covers the col81-100 area and skips comment lines. Real case: an 86-byte
//comment line) //free-form comments also evaded the isComment flag (col7 ≠'*'), so comment-line detection was extended to "col7 ='*'or the line starts with//"- Past 80 bytes the compile listing garbles; past 100 bytes CPYFRMSTMF truncates the source. Lines over 100 bytes are left to the existing LINE_LENGTH error to avoid double reporting
- Comment lines with Japanese (DBCS) text reaching 80–100 EBCDIC bytes slipped through every length check (checkLineLength only errors past 100 bytes; checkCommentArea only covers the col81-100 area and skips comment lines. Real case: an 86-byte
- Added regression test
tests/test-comment-ebcdic.mjs. All five samples remain at 0 errors
0.0.15 (2026-06-16)
- Repository housekeeping (no change to checker detection logic)
- Fixed the typo in the sample directory name (
saples/→samples/) - Consolidated the three test scripts (test-samples / test-dspec-overflow / test-dspf-overlap) under
tests/. Added a single-source verification helpertests/check-one.mjs <path>
- Fixed the typo in the sample directory name (
- Sanitized and compressed the sample sources (~4660 lines → ~1500 lines total)
- Neutralized to avoid evoking the original subject matter and renamed to
SAMPLE01–SAMPLE05. Algorithm bodies stubbed out, identifiers and comments genericized - Preserved the diversity of RPG constructs (the value for column-position checks) and kept all five files compile-clean (0 errors)
- Sanitized proprietary references in the bundled docs as well (generic RPG/EBCDIC knowledge retained)
- Neutralized to avoid evoking the original subject matter and renamed to
0.0.14 (2026-06-12)
- Added leading attribute byte collision detection to DSPF_FIELD_OVERLAP (real case: AITNTCFGD.dspf CTLWIN row 4 —
'状態:'(4,2)=7 bytes col2-8 and'テナント'(4,9) are adjacent without data overlap, yet CPD7866 was issued)- On 5250 displays, the position immediately preceding each field is occupied by its leading attribute byte, so at least one blank column is required between the end of one field's data and the start of the next. A gap of 0 (starting at end+1) places the attribute byte on the previous field's data and causes CPD7866. The check was extended from
next.col <= current.endColtonext.col <= current.endCol + 1, with a dedicated message for attribute-byte collisions - A gap of 1 (starting at end+2) is valid since the attribute byte fits in the blank column (no false positive)
- On 5250 displays, the position immediately preceding each field is occupied by its leading attribute byte, so at least one blank column is required between the end of one field's data and the start of the next. A gap of 0 (starting at end+1) places the attribute byte on the previous field's data and causes CPD7866. The check was extended from
- Fixed halfwidth katakana misclassification in DBCSHelper: U+FF00-FFEF was treated as DBCS wholesale, doubling the byte length of halfwidth katakana (U+FF61-FF9F, which is SBCS = 1 byte via code page 290 in EBCDIC 5026/5035). Surfaced as a false positive on
'日次トークン上限 (0=無制限):'(AIOPSD.dspf) once the attribute-byte check was added. Halfwidth forms (U+FF61-FFDC, U+FFE8-FFEE) are now SBCS - Added 5 regression test cases (DBCS-constant attribute-byte collision / gap-1 clean / field starting right after an SBCS constant / its fix / halfwidth-katakana constant). Verified 0 false positives across all 10 DSPF files in
E:/IBM_i_and_AI/src. During verification, the checker also caughtCWOPT(14,12) in the user's in-progress AITNTCFGD CTLWIN edit as a true positive (attribute byte colliding with>at col11 of'選択 ==>')
0.0.13 (2026-06-11)
- Fixed DSPF_FIELD_OVERLAP (CPD7866-equivalent) misses (real case: in AIADMND.dspf TENFTR, the overlap between the unconditioned constant
'F3/12=戻る F5=再表示'and the indicator-77 conditioned constant'F6=追加'went undetected)- Constants (literals) are now included in overlap detection: previously only named fields were checked, so constant-vs-constant and constant-vs-field overlaps (the typical CPD7866 pattern) all passed through. Display length is computed deterministically as the post-EBCDIC byte length (n DBCS characters = 2n+2 bytes including SO/SI). Constant continuation lines (
'+'= continue from the first non-blank of the next line,'-'= continue from column 45 of the next line) are supported - Indicator exclusion narrowed to "both sides conditioned" only: previously any indicator on either side skipped the check, but CPD7866 means an overlap with a field without conditioning. Only mutually exclusive pairs like 77/N77 (CPD7865-equivalent, intentional) are excluded; an overlap with an unconditioned side is reported
- Constants (literals) are now included in overlap detection: previously only named fields were checked, so constant-vs-constant and constant-vs-field overlaps (the typical CPD7866 pattern) all passed through. Display length is computed deterministically as the post-EBCDIC byte length (n DBCS characters = 2n+2 bytes including SO/SI). Constant continuation lines (
- Added CJK Symbols and Punctuation (U+3000-303F: ideographic space, 「」, 。, ・ etc.) to DBCSHelper as DBCS (byte length was previously underestimated)
- Added regression test
test-dspf-overlap.mjs(pre-fix AIADMND overlap detected / post-fix clean / exclusive-indicator pairs not reported / continued-literal length). Verified 0 false positives across all 10 DSPF files inE:/IBM_i_and_AI/srcand no change in results for all RPG sources
0.0.12 (2026-06-11)
- Resolved the column-22
Eambiguity using context, closing most of the v0.0.11 blind spot where an overflowing name happened to end withEat column 22- PR/PI parameter lines: D lines with a blank definition type following a PR/PI declaration are now tracked as parameters. Since column 22 must be blank in parameter definitions even when it is
E(RNF3780),Eis reported as name overflow (D_SPEC_NAME_OVERFLOW) or an invalid value (D_SPEC_EXT_DESC_INVALID) with certainty - Externally described DS lines:
E+ no EXTNAME + a name of 11+ characters cannot compile under either interpretation (without EXTNAME the name field is used as the file name, max 10 characters) → new ruleD_SPEC_EXTNAME_REQUIRED(error) Eon subfield lines outside PR/PI blocks (externally described subfields) remains out of scope, as it is indistinguishable from valid code
- PR/PI parameter lines: D lines with a blank definition type following a PR/PI declaration are now tracked as parameters. Since column 22 must be blank in parameter definitions even when it is
- Expanded the regression test to 20 cases (added multi-line PR/PI block context cases); verified 0 false positives across all
E:/IBM_i_and_AI/srcsources
0.0.11 (2026-06-11)
- Added D-spec name overflow detection:
D_SPEC_NAME_OVERFLOW(error)- Detects names that overflow the name field (columns 7-21) into column 22 and beyond (e.g. a 14-character name starting at column 9). Previously undetectable when the remaining fields stayed at their correct columns (real case:
P_DBC_CONSUMEDin AIMONR.sqlrpgle caused RNF3780 severity 20) - Provides a Before/After correction using the
...name-continuation syntax
- Detects names that overflow the name field (columns 7-21) into column 22 and beyond (e.g. a 14-character name starting at column 9). Previously undetectable when the remaining fields stayed at their correct columns (real case:
- Added value validation for column 22 (External Description) and column 23 (Type of Data Structure):
D_SPEC_EXT_DESC_INVALID/D_SPEC_DS_TYPE_INVALID(error)- Per the IBM ILE RPG Reference, column 22 allows only
E/blank and column 23 allows onlyS(PSDS) /U(data-area DS) / blank; non-blank values outside a DS definition cause RNF3780, so these are reported as errors - Also detects
S/Uin column 23 when columns 24-25 are notDS
- Per the IBM ILE RPG Reference, column 22 allows only
- D_SPEC_DECL_TYPE_MISPLACED no longer fires when column 21 (the last name-field column) is occupied (reported as name overflow instead)
- Verified 0 false positives across all known-good
E:/IBM_i_and_AI/srcsources; added regression testtest-dspec-overflow.mjs
0.0.10 (2026-06-07)
- Removed the erroneous F_SPEC_SPACING check (false positives on valid code)
- Column 17 of an F-spec is the File Type field (I/O/U/C), not a required space; a 10-character file name (e.g.
AICHATHSTD) is followed directly by the File Type letter, which is valid and compiles
- Column 17 of an F-spec is the File Type field (I/O/U/C), not a required space; a 10-character file name (e.g.
- Downgraded D_SPEC_NAME_POSITION from
warningtoinfo- The column-7/column-8 start convention is a style recommendation, not a compile requirement; a name placed anywhere within columns 7-21 compiles cleanly
- Verified against the known-good
E:/IBM_i_and_AI/srcsources (*.sqlrpgle / *.dspf): 0 errors / 0 warnings at standard and strict levels
0.0.9 (2026-06-06)
- Fixed INDICATOR_USAGE (numbered indicator) false positives
- Excluded F-spec
OFLIND(*INxx)(PRINTER overflow indicator), since*INxxis mandatory by language spec and cannot be a named indicator - Excluded
*INxxstrings inside comment lines (col 7 =*, e.g.F*/C*/D*)
- Excluded F-spec
0.0.8 (2026-06-06)
- Renamed display name to "ILE-RPG&DSPF Code Checker" (internal identifier unchanged)
- Fixed DSPF/DDS A-spec false positives by aligning column parsing with the IBM DDS layout (name 19-28, length 30-34, line 39-41, position 42-44)
- Scoped field-overlap detection to within each record format (R)
- Excluded A-spec from quote/parenthesis matching (DDS uses different continuation rules)
- Distinguished WINDOW definition vs reference; detect standalone OVERLAY (no parentheses)
- Limited the DBCS position-shift warning to the fixed-column area (cols 1-44)
- Excluded CNTFLD (continued fields) from line-overflow checks
0.0.7 (2026-02-12)
- Fixed false positives for WCA4i test cases
- Improved parser robustness for continuation lines
- Fixed SPEC_ORDER false positives inside P-procedure sections
0.0.6 (2026-02-12)
- Added Phase 9 compile findings for D-spec validation
- Name continuation syntax (
...) handling - Declaration type misplacement detection (col 22-23 vs col 24-25)
- Trailing period detection in field names (RNF0622/RNF0623)
- Column shift heuristics for keyword detection in size field
0.0.5 (2026-02-12)
- Enhanced D-spec column position validation
- More robust column position checking across specifications
- Improved error messages and suggestions
0.0.4 (2026-01-25)
- Fully free-format (**FREE) detection
- Token efficiency improvements in tool descriptions
- Fixed **FREE detection before line length validation
0.0.3 (2026-01-25)
- Added fully free-format detection support
- Tool description improvements for token efficiency
- Renamed to "ILE RPG Code Checker"
- Added version number to startup message
0.0.2 (2026-01-25)
- Updated documentation
- Changed title from "ILE-RPG Coding Standards Checker" to "ILE-RPG Code Checker"
- Updated description to include "syntax and coding standards"
- Masked sensitive information in examples
- Fixed DBCS example to use INZ instead of Japanese variable names
0.0.1 (2026-01-25)
- Initial release
- Basic check functionality implementation
- 6 MCP tools provided
- Multi-language support (English/Japanese)
- DBCS character support
- Custom rules functionality
References
- IBM i Information Center - ILE RPG Reference
Support
For issues or questions, please report to the project's Issue tracker.
