mcp-for-i 0.1.13 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/config/store.js +229 -109
- package/dist/controlplane/auth.js +128 -0
- package/dist/controlplane/clientIntegrationService.js +83 -4
- package/dist/controlplane/commands.js +14 -9
- package/dist/controlplane/connectionService.js +110 -5
- package/dist/controlplane/connectionTest.js +329 -0
- package/dist/controlplane/errors.js +12 -0
- package/dist/controlplane/runtimeService.js +98 -26
- package/dist/controlplane/server.js +122 -11
- package/dist/controlplane/serverShared.js +25 -6
- package/dist/controlplane/serviceManager.js +113 -100
- package/dist/controlplane/ui.js +1742 -920
- package/dist/ibmi/CompileTools.js +29 -1
- package/dist/ibmi/IBMiContent.js +435 -63
- package/dist/ibmi/IbmDocs.js +685 -0
- package/dist/ibmi/LocalLanguageActions.js +129 -3
- package/dist/ibmi/Search.js +158 -52
- package/dist/ibmi/Tools.js +7 -10
- package/dist/ibmi/client.js +220 -31
- package/dist/ibmi/evfevent.js +256 -0
- package/dist/ibmi/knownHosts.js +190 -0
- package/dist/ibmi/libraryList.js +93 -0
- package/dist/ibmi/sourceInspect.js +815 -0
- package/dist/ibmi/sqlJob.js +888 -0
- package/dist/ibmi/sqlParse.js +317 -0
- package/dist/ibmi/tn5250/certTrust.js +59 -0
- package/dist/ibmi/tn5250/client.js +310 -0
- package/dist/ibmi/tn5250/datastream.js +109 -0
- package/dist/ibmi/tn5250/ebcdic.js +74 -0
- package/dist/ibmi/tn5250/index.js +6 -0
- package/dist/ibmi/tn5250/screen.js +827 -0
- package/dist/ibmi/tn5250/telnet.js +186 -0
- package/dist/ibmi/variables.js +18 -7
- package/dist/index.js +43 -22
- package/dist/mcp/annotations.js +155 -0
- package/dist/mcp/audit.js +490 -133
- package/dist/mcp/confirm.js +48 -0
- package/dist/mcp/context.js +43 -5
- package/dist/mcp/deployMethods.js +192 -0
- package/dist/mcp/logger.js +5 -10
- package/dist/mcp/modules/bulkMembers.js +476 -0
- package/dist/mcp/modules/changedLines.js +189 -0
- package/dist/mcp/modules/compare.js +198 -0
- package/dist/mcp/modules/compile.js +515 -0
- package/dist/mcp/modules/ifsOps.js +123 -0
- package/dist/mcp/modules/index.js +38 -0
- package/dist/mcp/modules/inspect.js +811 -0
- package/dist/mcp/modules/libl.js +246 -0
- package/dist/mcp/modules/members.js +171 -0
- package/dist/mcp/modules/objects.js +339 -0
- package/dist/mcp/modules/system.js +266 -0
- package/dist/mcp/modules/tn5250.js +515 -0
- package/dist/mcp/policy.js +412 -0
- package/dist/mcp/tools.js +1700 -698
- package/dist/security/credentialStore.js +62 -13
- package/dist/security/localPaths.js +138 -0
- package/dist/security/redact.js +79 -0
- package/dist/util/atomicWrite.js +101 -0
- package/dist/util/fileLock.js +206 -0
- package/docs/capabilities.md +50 -7
- package/docs/configuration.md +189 -60
- package/docs/examples.md +109 -73
- package/docs/overview.md +15 -15
- package/docs/security.md +101 -16
- package/docs/tools.md +363 -188
- package/package.json +56 -53
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 5250 data stream constants and GDS record framing (RFC 1205, RFC 2877).
|
|
3
|
+
*
|
|
4
|
+
* Every 5250 record starts with a 10-byte header:
|
|
5
|
+
* length(2) | record type 0x12A0 (2) | reserved(2) | var header length 0x04 (1)
|
|
6
|
+
* | flags(2) | opcode(1)
|
|
7
|
+
* followed by commands, each introduced by ESC (0x04).
|
|
8
|
+
*/
|
|
9
|
+
export const GDS_RECORD_TYPE = 0x12a0;
|
|
10
|
+
export const ESC = 0x04;
|
|
11
|
+
// Header opcodes
|
|
12
|
+
export const OP_NO_OP = 0x00;
|
|
13
|
+
export const OP_INVITE = 0x01;
|
|
14
|
+
export const OP_OUTPUT_ONLY = 0x02;
|
|
15
|
+
export const OP_PUT_GET = 0x03;
|
|
16
|
+
export const OP_SAVE_SCREEN = 0x04;
|
|
17
|
+
export const OP_RESTORE_SCREEN = 0x05;
|
|
18
|
+
export const OP_READ_IMMEDIATE = 0x06;
|
|
19
|
+
export const OP_READ_SCREEN = 0x08;
|
|
20
|
+
export const OP_CANCEL_INVITE = 0x0a;
|
|
21
|
+
export const OP_MESSAGE_LIGHT_ON = 0x0b;
|
|
22
|
+
export const OP_MESSAGE_LIGHT_OFF = 0x0c;
|
|
23
|
+
// Header flag bits (first flag byte)
|
|
24
|
+
export const FLAG_ERR = 0x80;
|
|
25
|
+
export const FLAG_ATN = 0x40;
|
|
26
|
+
export const FLAG_SRQ = 0x04;
|
|
27
|
+
export const FLAG_TRQ = 0x02;
|
|
28
|
+
// Second flag byte
|
|
29
|
+
export const FLAG_HLP = 0x80;
|
|
30
|
+
// Commands (after ESC)
|
|
31
|
+
export const CMD_SAVE_SCREEN = 0x02;
|
|
32
|
+
export const CMD_SAVE_PARTIAL_SCREEN = 0x03;
|
|
33
|
+
export const CMD_WRITE_TO_DISPLAY = 0x11;
|
|
34
|
+
export const CMD_RESTORE_SCREEN = 0x12;
|
|
35
|
+
export const CMD_RESTORE_PARTIAL_SCREEN = 0x13;
|
|
36
|
+
export const CMD_CLEAR_UNIT_ALTERNATE = 0x20;
|
|
37
|
+
export const CMD_WRITE_ERROR_CODE = 0x21;
|
|
38
|
+
export const CMD_WRITE_ERROR_CODE_TO_WINDOW = 0x22;
|
|
39
|
+
export const CMD_ROLL = 0x23;
|
|
40
|
+
export const CMD_CLEAR_UNIT = 0x40;
|
|
41
|
+
export const CMD_READ_INPUT_FIELDS = 0x42;
|
|
42
|
+
export const CMD_CLEAR_FORMAT_TABLE = 0x50;
|
|
43
|
+
export const CMD_READ_MDT_FIELDS = 0x52;
|
|
44
|
+
export const CMD_READ_SCREEN_IMMEDIATE = 0x62;
|
|
45
|
+
export const CMD_READ_IMMEDIATE = 0x72;
|
|
46
|
+
export const CMD_READ_MDT_ALTERNATE = 0x82;
|
|
47
|
+
export const CMD_READ_MDT_IMMEDIATE_ALTERNATE = 0x83;
|
|
48
|
+
export const CMD_WRITE_STRUCTURED_FIELD = 0xf3;
|
|
49
|
+
// Orders inside Write To Display
|
|
50
|
+
export const ORD_SOH = 0x01;
|
|
51
|
+
export const ORD_RA = 0x02;
|
|
52
|
+
export const ORD_EA = 0x03;
|
|
53
|
+
export const ORD_TD = 0x10;
|
|
54
|
+
export const ORD_SBA = 0x11;
|
|
55
|
+
export const ORD_WEA = 0x12;
|
|
56
|
+
export const ORD_IC = 0x13;
|
|
57
|
+
export const ORD_MC = 0x14;
|
|
58
|
+
export const ORD_WDSF = 0x15;
|
|
59
|
+
export const ORD_SF = 0x1d;
|
|
60
|
+
// AID codes
|
|
61
|
+
export const AID = {
|
|
62
|
+
ENTER: 0xf1,
|
|
63
|
+
HELP: 0xf3,
|
|
64
|
+
ROLLDOWN: 0xf4,
|
|
65
|
+
ROLLUP: 0xf5,
|
|
66
|
+
PRINT: 0xf6,
|
|
67
|
+
RECORD_BACKSPACE: 0xf8,
|
|
68
|
+
CLEAR: 0xbd,
|
|
69
|
+
INBOUND_WSF: 0x88,
|
|
70
|
+
F1: 0x31, F2: 0x32, F3: 0x33, F4: 0x34, F5: 0x35, F6: 0x36,
|
|
71
|
+
F7: 0x37, F8: 0x38, F9: 0x39, F10: 0x3a, F11: 0x3b, F12: 0x3c,
|
|
72
|
+
F13: 0xb1, F14: 0xb2, F15: 0xb3, F16: 0xb4, F17: 0xb5, F18: 0xb6,
|
|
73
|
+
F19: 0xb7, F20: 0xb8, F21: 0xb9, F22: 0xba, F23: 0xbb, F24: 0xbc
|
|
74
|
+
};
|
|
75
|
+
/** AID keys whose response carries no field data. */
|
|
76
|
+
export const AID_WITHOUT_DATA = new Set([AID.CLEAR, AID.HELP, AID.PRINT, AID.RECORD_BACKSPACE]);
|
|
77
|
+
export function parseGdsRecord(record) {
|
|
78
|
+
if (record.length < 10)
|
|
79
|
+
throw new Error(`5250 record too short (${record.length} bytes)`);
|
|
80
|
+
const recordType = record.readUInt16BE(2);
|
|
81
|
+
if (recordType !== GDS_RECORD_TYPE) {
|
|
82
|
+
throw new Error(`Unexpected 5250 record type 0x${recordType.toString(16)}`);
|
|
83
|
+
}
|
|
84
|
+
const varLength = record[6];
|
|
85
|
+
const headerEnd = 6 + varLength;
|
|
86
|
+
if (varLength < 4 || headerEnd > record.length)
|
|
87
|
+
throw new Error("Invalid 5250 record header");
|
|
88
|
+
const declared = record.readUInt16BE(0);
|
|
89
|
+
const end = declared >= headerEnd && declared <= record.length ? declared : record.length;
|
|
90
|
+
return {
|
|
91
|
+
flags: record[7],
|
|
92
|
+
flags2: record[8],
|
|
93
|
+
opcode: record[9],
|
|
94
|
+
data: record.subarray(headerEnd, end)
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export function buildGdsRecord(opcode, data = new Uint8Array(0), flags = 0, flags2 = 0) {
|
|
98
|
+
const length = 10 + data.length;
|
|
99
|
+
const out = Buffer.alloc(length);
|
|
100
|
+
out.writeUInt16BE(length, 0);
|
|
101
|
+
out.writeUInt16BE(GDS_RECORD_TYPE, 2);
|
|
102
|
+
out.writeUInt16BE(0, 4);
|
|
103
|
+
out[6] = 0x04;
|
|
104
|
+
out[7] = flags;
|
|
105
|
+
out[8] = flags2;
|
|
106
|
+
out[9] = opcode;
|
|
107
|
+
Buffer.from(data).copy(out, 10);
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EBCDIC conversion for the 5250 data stream.
|
|
3
|
+
*
|
|
4
|
+
* Only CCSID 37 (US/Canada) is built in. The table maps every byte from
|
|
5
|
+
* 0x40 to 0xFE to its Unicode character; bytes below 0x40 are controls,
|
|
6
|
+
* attributes and orders in the 5250 data stream and render as blanks.
|
|
7
|
+
*/
|
|
8
|
+
export const SUPPORTED_CCSIDS = [37];
|
|
9
|
+
// Unicode code points for EBCDIC 0x40..0xFE, 16 per row.
|
|
10
|
+
const CCSID37_FROM_40 = [
|
|
11
|
+
/* 0x40 */ 0x0020, 0x00A0, 0x00E2, 0x00E4, 0x00E0, 0x00E1, 0x00E3, 0x00E5, 0x00E7, 0x00F1, 0x00A2, 0x002E, 0x003C, 0x0028, 0x002B, 0x007C,
|
|
12
|
+
/* 0x50 */ 0x0026, 0x00E9, 0x00EA, 0x00EB, 0x00E8, 0x00ED, 0x00EE, 0x00EF, 0x00EC, 0x00DF, 0x0021, 0x0024, 0x002A, 0x0029, 0x003B, 0x00AC,
|
|
13
|
+
/* 0x60 */ 0x002D, 0x002F, 0x00C2, 0x00C4, 0x00C0, 0x00C1, 0x00C3, 0x00C5, 0x00C7, 0x00D1, 0x00A6, 0x002C, 0x0025, 0x005F, 0x003E, 0x003F,
|
|
14
|
+
/* 0x70 */ 0x00F8, 0x00C9, 0x00CA, 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x0060, 0x003A, 0x0023, 0x0040, 0x0027, 0x003D, 0x0022,
|
|
15
|
+
/* 0x80 */ 0x00D8, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x00AB, 0x00BB, 0x00F0, 0x00FD, 0x00FE, 0x00B1,
|
|
16
|
+
/* 0x90 */ 0x00B0, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070, 0x0071, 0x0072, 0x00AA, 0x00BA, 0x00E6, 0x00B8, 0x00C6, 0x00A4,
|
|
17
|
+
/* 0xA0 */ 0x00B5, 0x007E, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x00A1, 0x00BF, 0x00D0, 0x00DD, 0x00DE, 0x00AE,
|
|
18
|
+
/* 0xB0 */ 0x005E, 0x00A3, 0x00A5, 0x00B7, 0x00A9, 0x00A7, 0x00B6, 0x00BC, 0x00BD, 0x00BE, 0x005B, 0x005D, 0x00AF, 0x00A8, 0x00B4, 0x00D7,
|
|
19
|
+
/* 0xC0 */ 0x007B, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x00AD, 0x00F4, 0x00F6, 0x00F2, 0x00F3, 0x00F5,
|
|
20
|
+
/* 0xD0 */ 0x007D, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x00B9, 0x00FB, 0x00FC, 0x00F9, 0x00FA, 0x00FF,
|
|
21
|
+
/* 0xE0 */ 0x005C, 0x00F7, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x00B2, 0x00D4, 0x00D6, 0x00D2, 0x00D3, 0x00D5,
|
|
22
|
+
/* 0xF0 */ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x00B3, 0x00DB, 0x00DC, 0x00D9, 0x00DA
|
|
23
|
+
];
|
|
24
|
+
const tables = new Map();
|
|
25
|
+
function buildTable(ccsid) {
|
|
26
|
+
if (ccsid !== 37)
|
|
27
|
+
throw new Error(`CCSID ${ccsid} is not supported for TN5250 (supported: ${SUPPORTED_CCSIDS.join(", ")})`);
|
|
28
|
+
const toChar = new Array(256).fill(" ");
|
|
29
|
+
const fromChar = new Map();
|
|
30
|
+
for (let i = 0; i < CCSID37_FROM_40.length; i += 1) {
|
|
31
|
+
const ch = String.fromCodePoint(CCSID37_FROM_40[i]);
|
|
32
|
+
toChar[0x40 + i] = ch;
|
|
33
|
+
if (!fromChar.has(ch))
|
|
34
|
+
fromChar.set(ch, 0x40 + i);
|
|
35
|
+
}
|
|
36
|
+
return { toChar, fromChar };
|
|
37
|
+
}
|
|
38
|
+
function table(ccsid) {
|
|
39
|
+
let t = tables.get(ccsid);
|
|
40
|
+
if (!t) {
|
|
41
|
+
t = buildTable(ccsid);
|
|
42
|
+
tables.set(ccsid, t);
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
}
|
|
46
|
+
/** Character for one EBCDIC byte. Controls, nulls and attributes become a blank. */
|
|
47
|
+
export function ebcdicToChar(byte, ccsid = 37) {
|
|
48
|
+
if (byte < 0x40 || byte > 0xfe)
|
|
49
|
+
return " ";
|
|
50
|
+
return table(ccsid).toChar[byte];
|
|
51
|
+
}
|
|
52
|
+
export function ebcdicToString(bytes, ccsid = 37) {
|
|
53
|
+
let out = "";
|
|
54
|
+
for (let i = 0; i < bytes.length; i += 1)
|
|
55
|
+
out += ebcdicToChar(bytes[i], ccsid);
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
/** EBCDIC byte for one character, or undefined when the CCSID cannot represent it. */
|
|
59
|
+
export function charToEbcdic(ch, ccsid = 37) {
|
|
60
|
+
return table(ccsid).fromChar.get(ch);
|
|
61
|
+
}
|
|
62
|
+
/** Encode text, throwing on characters the CCSID cannot represent. */
|
|
63
|
+
export function stringToEbcdic(text, ccsid = 37) {
|
|
64
|
+
const chars = Array.from(text);
|
|
65
|
+
const out = new Uint8Array(chars.length);
|
|
66
|
+
chars.forEach((ch, i) => {
|
|
67
|
+
const byte = charToEbcdic(ch, ccsid);
|
|
68
|
+
if (byte === undefined) {
|
|
69
|
+
throw new Error(`Character ${JSON.stringify(ch)} cannot be represented in CCSID ${ccsid}`);
|
|
70
|
+
}
|
|
71
|
+
out[i] = byte;
|
|
72
|
+
});
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./client.js";
|
|
2
|
+
export * from "./screen.js";
|
|
3
|
+
export * from "./certTrust.js";
|
|
4
|
+
export * as datastream from "./datastream.js";
|
|
5
|
+
export * as telnet from "./telnet.js";
|
|
6
|
+
export { ebcdicToString, stringToEbcdic, charToEbcdic, ebcdicToChar, SUPPORTED_CCSIDS } from "./ebcdic.js";
|