Content
# 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
1. **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
2. **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
3. **Naming Convention Check**
- Variable and procedure name conventions
- Special character usage restrictions
- Meaningful name recommendations
- Reserved word checking (strict level)
4. **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
5. **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
1. Install dependencies:
```bash
cd /path/to/ilerpg-code-checker
npm install
```
2. Build:
```bash
npm run build
```
3. 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`:
```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):
```json
{
"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:
```json
{
"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.
```typescript
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:**
```json
{
"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.
```typescript
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.
```typescript
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.
```typescript
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.
```typescript
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.
```typescript
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:
```json
{
"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 rule
- `name`: Display name
- `description`: Detailed description
- `pattern`: Regular expression pattern to match
- `severity`: "error" | "warning" | "info"
- `suggestion`: Recommendation for fixing the issue
- `enabled`: true | false
## Examples of Detected Issues
### Structure Errors
```text
F-spec
H-spec ← Error: H-spec must be placed before F-spec
```
### Column Position Errors
```text
D MyVariable S 10A ← Error: Variable name is not in correct column position
```
### Line Continuation Errors
```text
D MyLongVariableName
D- S 10A ← Error: Continuation line spec type mismatch
```
### Naming Convention Violations
```text
D x S 10A ← Warning: Variable name is too short
D 1stVar S 10A ← Error: Variable name cannot start with a number
```
### Deprecated Features
```text
C GOTO Label ← Warning: GOTO is deprecated
C Label TAG
```
### DBCS Example
When `considerDBCS: true`:
```text
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 by `CPYFRMSTMF` (reported as `LINE_LENGTH` error).
- **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
```bash
npm run build
```
### Development Mode (Auto-build)
```bash
npm run watch
```
## Troubleshooting
### MCP Server Won't Start
1. Check Node.js version: `node --version` (18 or higher required)
2. Verify build is complete: Check if `build/index.js` exists
3. Verify MCP configuration file path is correct
### Check Results Not Displayed
1. Check source code encoding (UTF-8 recommended)
2. Verify file path is correct
3. Check MCP server logs
## License
MIT
## Author
guricat
## Version
0.0.15
## Changelog
### 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 helper `tests/check-one.mjs <path>`
- 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)
### 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.endCol` to `next.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)
- 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 caught `CWOPT`(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
- 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 in `E:/IBM_i_and_AI/src` and no change in results for all RPG sources
### 0.0.12 (2026-06-11)
- Resolved the column-22 `E` ambiguity using context, closing most of the v0.0.11 blind spot where an overflowing name happened to end with `E` at 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), `E` is 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 rule `D_SPEC_EXTNAME_REQUIRED` (error)
- `E` on subfield lines outside PR/PI blocks (externally described subfields) remains out of scope, as it is indistinguishable from valid code
- 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/src` sources
### 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_CONSUMED` in AIMONR.sqlrpgle caused RNF3780 severity 20)
- Provides a Before/After correction using the `...` name-continuation syntax
- 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 only `S` (PSDS) / `U` (data-area DS) / blank; non-blank values outside a DS definition cause RNF3780, so these are reported as errors
- Also detects `S`/`U` in column 23 when columns 24-25 are not `DS`
- 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/src` sources; added regression test `test-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
- Downgraded D_SPEC_NAME_POSITION from `warning` to `info`
- 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/src` sources (*.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 `*INxx` is mandatory by language spec and cannot be a named indicator
- Excluded `*INxx` strings inside comment lines (col 7 = `*`, e.g. `F*`/`C*`/`D*`)
### 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.
MCP Config
Below is the configuration for this MCP Server. You can copy it directly to Cursor or other MCP clients.
mcp.json
Connection Info
You Might Also Like
No recommendations available