@nataliapc/mcp-openmsx 1.1.8 → 1.1.13
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 +3 -2
- package/dist/openmsx.js +9 -0
- package/dist/server.js +401 -313
- package/package.json +1 -1
- package/resources/bios/toc.json +2 -2
- package/resources/msx-dos/toc.json +2 -2
- package/resources/processors/toc.json +2 -2
- package/resources/system/toc.json +2 -2
package/README.md
CHANGED
|
@@ -44,13 +44,13 @@ The MCP server translates high-level commands from your Copilot AI into `TCL` co
|
|
|
44
44
|
|
|
45
45
|
### Emulator Control Tools
|
|
46
46
|
- `emu_control`: Controls an openMSX emulator: _`launch`, `close`, `powerOn`, `powerOff`, `reset`, `getEmulatorSpeed`, `setEmulatorSpeed`, `machineList`, `extensionList`, `wait`_.
|
|
47
|
-
- `emu_replay`: Controls emulation timeline: _`start`, `stop`, `status`, `goBack`, `absoluteGoto`, `truncate`, `saveReplay`, `loadReplay`_.
|
|
47
|
+
- `emu_replay`: Controls emulation timeline: _`start`, `stop`, `status`, `goBack`, `absoluteGoto`, `advanceFrame`, `reverseFrame`, `truncate`, `saveReplay`, `loadReplay`_.
|
|
48
48
|
- `emu_info`: Obtain informacion about the current emulated machine: _`getStatus`, `getSlotsMap`, `getIOPortsMap`_.
|
|
49
49
|
- `emu_media`: Manage ROM, disk, and tape media: _`tapeInsert`, `tapeRewind`, `tapeEject`, `romInsert`, `romEject`, `diskInsert`, `diskInsertFolder`, `diskEject`_.
|
|
50
50
|
- `emu_vdp`: Manage VDP (Video Display Processor): _`getPalette`, `getRegisters`, `getRegisterValue`, `setRegisterValue`, `screenGetMode`, `screenGetFullText`_.
|
|
51
51
|
|
|
52
52
|
### Programming Tools
|
|
53
|
-
- `basic_programming`: BASIC tools: _`newProgram`, `runProgram`, `setProgram`, `getFullProgram`, `getFullProgramAdvanced`, `listProgramLines`, `deleteProgramLines`_.
|
|
53
|
+
- `basic_programming`: BASIC tools: _`isBasicAvailable`, `newProgram`, `runProgram`, `setProgram`, `getFullProgram`, `getFullProgramAdvanced`, `listProgramLines`, `deleteProgramLines`_.
|
|
54
54
|
|
|
55
55
|
### Debugging Tools
|
|
56
56
|
- `debug_run`: Control execution: _`break`, `isBreaked`, `continue`, `stepIn`, `stepOut`, `stepOver`, `stepBack`, `runTo`_.
|
|
@@ -83,6 +83,7 @@ There are more than 60 resources available, some included directly in the MCP an
|
|
|
83
83
|
- `Programming` (ASM, BASIC, ...)
|
|
84
84
|
- `MSX-DOS`
|
|
85
85
|
- `MSX-UNAPI`
|
|
86
|
+
- `MSX BASIC`
|
|
86
87
|
|
|
87
88
|
And two books:
|
|
88
89
|
|
package/dist/openmsx.js
CHANGED
|
@@ -212,6 +212,15 @@ export class OpenMSX {
|
|
|
212
212
|
return `Error: Failed to get machine status - ${error instanceof Error ? error.message : 'Unknown error'}`;
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
+
async emu_isInBasic() {
|
|
216
|
+
try {
|
|
217
|
+
const response = await this.sendCommand('slotselect');
|
|
218
|
+
return response.includes('0000: slot 0') && response.includes('4000: slot 0');
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
215
224
|
/**
|
|
216
225
|
* Get the list of machines available in the openMSX emulator
|
|
217
226
|
* @returns Promise<object> - object with machine names and descriptions or error message
|
package/dist/server.js
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* through TCL commands via stdio.
|
|
7
7
|
*
|
|
8
8
|
* @package @nataliapc/mcp-openmsx
|
|
9
|
-
* @version 1.1.
|
|
9
|
+
* @version 1.1.13
|
|
10
10
|
* @author Natalia Pujol Cremades (@nataliapc)
|
|
11
11
|
* @license GPL2
|
|
12
12
|
*/
|
|
13
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
13
|
+
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
14
14
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
15
15
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
16
16
|
import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
|
|
@@ -23,7 +23,7 @@ import path from "path";
|
|
|
23
23
|
import { openMSXInstance } from "./openmsx.js";
|
|
24
24
|
import { encodeTypeText, isErrorResponse, getResponseContent } from "./utils.js";
|
|
25
25
|
// Version info for CLI
|
|
26
|
-
const PACKAGE_VERSION = "1.1.
|
|
26
|
+
const PACKAGE_VERSION = "1.1.13";
|
|
27
27
|
const resourcesDir = path.join(path.dirname(new URL(import.meta.url).pathname), "../resources");
|
|
28
28
|
// Defaults for openMSX paths
|
|
29
29
|
var OPENMSX_EXECUTABLE = 'openmsx';
|
|
@@ -38,30 +38,31 @@ var EXTENSIONS_DIR = `${OPENMSX_SHARE_DIR}/extensions`;
|
|
|
38
38
|
// https://modelcontextprotocol.io/docs/concepts/tools#tool-definition-structure
|
|
39
39
|
//
|
|
40
40
|
async function registerAllTools(server) {
|
|
41
|
-
server.
|
|
41
|
+
server.registerTool(
|
|
42
42
|
// Name of the tool (used to call it)
|
|
43
|
-
"emu_control",
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
43
|
+
"emu_control", {
|
|
44
|
+
title: "Emulator control tools",
|
|
45
|
+
// Description of the tool (what it does)
|
|
46
|
+
description: "Tools to control an openMSX emulator.",
|
|
47
|
+
// Schema for the tool (input validation)
|
|
48
|
+
inputSchema: {
|
|
49
|
+
command: z.enum(["launch", "close", "powerOn", "powerOff", "reset", "getEmulatorSpeed", "setEmulatorSpeed", "machineList", "extensionList", "wait"]).describe(`Available commands:
|
|
50
|
+
'launch [machine] [extensions]': opens a powered-on openMSX emulator; you must wait some time waiting the machine is fully booted; machine and extensions parameters can be specified so use 'machineList' and 'extensionList' commands to obtain valid values. " +
|
|
51
|
+
'close': closes the openMSX emulator.
|
|
52
|
+
'powerOn': powers on the openMSX emulator.
|
|
53
|
+
'powerOff': powers off the openMSX emulator.
|
|
54
|
+
'reset': resets the current machine.
|
|
55
|
+
'getEmulatorSpeed': gets the current emulator speed as a percentage, default is 100.
|
|
56
|
+
'setEmulatorSpeed <emuspeed>': sets the emulator speed as a percentage, valid values are 1-10000, default is 100.
|
|
57
|
+
'machineList': gets a list of all available MSX machines that can be emulated with openMSX.
|
|
58
|
+
'extensionList': gets a list of all available MSX extensions that can be used with openMSX.
|
|
59
|
+
'wait <seconds>': performs a wait for the specified number of seconds, default is 3.
|
|
60
|
+
`),
|
|
61
|
+
machine: z.string().min(1).max(100).optional().describe("Machine name to launch; valid names can be obtained using [machineList]. Used by [launch]."),
|
|
62
|
+
extensions: z.array(z.string().min(1).max(100)).optional().describe("List of extensions to use; valid extensions can be obtained using [extensionList]. Used by [launch]."),
|
|
63
|
+
emuspeed: z.number().min(1).max(10000).optional().default(100).describe("Emulator speed as a percentage (1-10000); default is 100. Used by [setEmulatorSpeed]."),
|
|
64
|
+
seconds: z.number().min(1).max(10).optional().default(3).describe("Number of seconds to wait; default is 3. Used by [wait]."),
|
|
65
|
+
},
|
|
65
66
|
},
|
|
66
67
|
// Handler for the tool (function to be executed when the tool is called)
|
|
67
68
|
async ({ command, machine, extensions, emuspeed, seconds }) => {
|
|
@@ -112,28 +113,29 @@ async function registerAllTools(server) {
|
|
|
112
113
|
result
|
|
113
114
|
]);
|
|
114
115
|
});
|
|
115
|
-
server.
|
|
116
|
+
server.registerTool(
|
|
116
117
|
// Name of the tool (used to call it)
|
|
117
|
-
"emu_media",
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
118
|
+
"emu_media", {
|
|
119
|
+
title: "Emulator media tools",
|
|
120
|
+
// Description of the tool (what it does)
|
|
121
|
+
description: "Manage tapes, rom cartridges, and floppy disks.",
|
|
122
|
+
// Schema for the tool (input validation)
|
|
123
|
+
inputSchema: {
|
|
124
|
+
command: z.enum(["tapeInsert", "tapeRewind", "tapeEject", "romInsert", "romEject", "diskInsert", "diskInsertFolder", "diskEject"]).describe(`Available commands:
|
|
125
|
+
'tapeInsert <tapefile>': insert a valid tape file (*.cas, *.wav, *.tsx).
|
|
126
|
+
'tapeRewind': rewind the current tape.
|
|
127
|
+
'tapeEject': remove tape from virtual cassette player.
|
|
128
|
+
'romInsert <romfile>': insert a valid ROM cartridge file (*.rom) at cartridge slot A.
|
|
129
|
+
'romEject': remove the current ROM cartridge from cartridge slot A.
|
|
130
|
+
'diskInsert <diskfile>': insert a valid disk file (*.dsk) in floppy disk A.
|
|
131
|
+
'diskInsertFolder <diskfolder>': use a host folder as a floppy disk A root directory.
|
|
132
|
+
'diskEject': remove the current disk from floppy disk A.
|
|
133
|
+
`),
|
|
134
|
+
tapefile: z.string().min(1).max(200).optional().describe("Absolute Tape filename to insert. Used by [tapeInsert]"),
|
|
135
|
+
romfile: z.string().min(1).max(200).optional().describe("Absolute ROM filename to insert. Used by [romInsert]"),
|
|
136
|
+
diskfile: z.string().min(1).max(200).optional().describe("Absolute Disk filename to insert. Used by [diskInsert]"),
|
|
137
|
+
diskfolder: z.string().min(1).max(200).optional().describe("Absolute Disk folder filename to insert. Used by [diskInsertFolder]"),
|
|
138
|
+
},
|
|
137
139
|
},
|
|
138
140
|
// Handler for the tool (function to be executed when the tool is called)
|
|
139
141
|
async ({ command, tapefile, romfile, diskfile, diskfolder }) => {
|
|
@@ -174,19 +176,20 @@ async function registerAllTools(server) {
|
|
|
174
176
|
response
|
|
175
177
|
]);
|
|
176
178
|
});
|
|
177
|
-
server.
|
|
179
|
+
server.registerTool(
|
|
178
180
|
// Name of the tool (used to call it)
|
|
179
|
-
"emu_info",
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
181
|
+
"emu_info", {
|
|
182
|
+
title: "Emulator info tools",
|
|
183
|
+
// Description of the tool (what it does)
|
|
184
|
+
description: "Obtain informacion about the current emulated machine.",
|
|
185
|
+
// Schema for the tool (input validation)
|
|
186
|
+
inputSchema: {
|
|
187
|
+
command: z.enum(["getStatus", "getSlotsMap", "getIOPortsMap"]).describe(`Available commands:
|
|
188
|
+
'getStatus': returns the status of the openMSX emulator.
|
|
189
|
+
'getSlotsMap': shows what devices/ROM/RAM are inserted into which slots.
|
|
190
|
+
'getIOPortsMap': shows an overview about the I/O mapped devices.
|
|
191
|
+
`),
|
|
192
|
+
},
|
|
190
193
|
},
|
|
191
194
|
// Handler for the tool (function to be executed when the tool is called)
|
|
192
195
|
async ({ command }) => {
|
|
@@ -212,24 +215,25 @@ async function registerAllTools(server) {
|
|
|
212
215
|
response
|
|
213
216
|
]);
|
|
214
217
|
});
|
|
215
|
-
server.
|
|
218
|
+
server.registerTool(
|
|
216
219
|
// Name of the tool (used to call it)
|
|
217
|
-
"emu_vdp",
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
220
|
+
"emu_vdp", {
|
|
221
|
+
title: "VDP tools",
|
|
222
|
+
// Description of the tool (what it does)
|
|
223
|
+
description: "Manage the VDP (Video Display Processor).",
|
|
224
|
+
// Schema for the tool (input validation)
|
|
225
|
+
inputSchema: {
|
|
226
|
+
command: z.enum(["getPalette", "getRegisters", "getRegisterValue", "setRegisterValue", "screenGetMode", "screenGetFullText"]).describe(`Available commands:
|
|
227
|
+
'getPalette': returns the current V9938/V9958 color palette in RGB333 format.
|
|
228
|
+
'getRegisters': returns all VDP register values.
|
|
229
|
+
'getRegisterValue <register>': returns the value of a specific VDP register (0-31) in decimal format.
|
|
230
|
+
'setRegisterValue <register> <value>': sets a hexadecimal value to a specific VDP register (0-31).
|
|
231
|
+
'screenGetMode': returns the current screen mode (0-12) as a number, which matches the BASIC SCREEN command.
|
|
232
|
+
'screenGetFullText': returns the full content of an MSX text screen (screen 0 or 1) as a string; PRIORITIZE this command to view screen content in text modes.
|
|
233
|
+
`),
|
|
234
|
+
register: z.number().min(0).max(31).optional().describe("VDP register number (0-31) to read/write. Used by [getRegisterValue, setRegisterValue]"),
|
|
235
|
+
value: z.string().regex(/^0x[0-9a-fA-F]{2}$/).optional().describe("2 hexadecimal digits for a VDP register value (e.g. 0x1f). Used by [setRegisterValue]"),
|
|
236
|
+
},
|
|
233
237
|
},
|
|
234
238
|
// Handler for the tool (function to be executed when the tool is called)
|
|
235
239
|
async ({ command, register, value }) => {
|
|
@@ -265,26 +269,27 @@ async function registerAllTools(server) {
|
|
|
265
269
|
response
|
|
266
270
|
]);
|
|
267
271
|
});
|
|
268
|
-
server.
|
|
272
|
+
server.registerTool(
|
|
269
273
|
// Name of the tool (used to call it)
|
|
270
|
-
"debug_run",
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
274
|
+
"debug_run", {
|
|
275
|
+
title: "CPU Runtime Debugger tools",
|
|
276
|
+
// Description of the tool (what it does)
|
|
277
|
+
description: "Control execution (break, continue, step).",
|
|
278
|
+
// Schema for the tool (input validation)
|
|
279
|
+
inputSchema: {
|
|
280
|
+
command: z.enum(["break", "isBreaked", "continue", "stepIn", "stepOut", "stepOver", "stepBack", "runTo"]).describe(`Available commands:
|
|
281
|
+
'break': to break CPU (pause emulation) at current execution position.
|
|
282
|
+
'isBreaked': to check if the CPU is currently in break state (1) or not (0).
|
|
283
|
+
'continue': to continue execution after break.
|
|
284
|
+
'stepIn': to execute one CPU instruction, go into subroutines.
|
|
285
|
+
'stepOver': to execute one CPU instruction, but don't go into subroutines.
|
|
286
|
+
'stepOut': to step out of the current subroutine.
|
|
287
|
+
'stepBack': to step one instruction back in time.
|
|
288
|
+
'runTo <address>': to run the CPU until it reaches the specified address.
|
|
289
|
+
**Important Note**: Addresses and values are in hexadecimal format (e.g. 0x0000).
|
|
290
|
+
`),
|
|
291
|
+
address: z.string().regex(/^0x[0-9a-fA-F]{4}$/).optional().describe("4 hexadecimal digits for a memory address (e.g. 0x4af3). Used by [runTo]"),
|
|
292
|
+
},
|
|
288
293
|
},
|
|
289
294
|
// Handler for the tool (function to be executed when the tool is called)
|
|
290
295
|
async ({ command, address }) => {
|
|
@@ -324,27 +329,29 @@ async function registerAllTools(server) {
|
|
|
324
329
|
response
|
|
325
330
|
]);
|
|
326
331
|
});
|
|
327
|
-
server.
|
|
332
|
+
server.registerTool(
|
|
328
333
|
// Name of the tool (used to call it)
|
|
329
|
-
"debug_cpu",
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
334
|
+
"debug_cpu", {
|
|
335
|
+
title: "CPU tools",
|
|
336
|
+
// Description of the tool (what it does)
|
|
337
|
+
description: "Read/write CPU registers, CPU info, Stack pile, and Disassemble code from memory.",
|
|
338
|
+
// Schema for the tool (input validation)
|
|
339
|
+
inputSchema: {
|
|
340
|
+
command: z.enum(["getCpuRegisters", "getRegister", "setRegister", "getStackPile", "disassemble", "getActiveCpu"]).describe(`Available commands:
|
|
341
|
+
'getCpuRegisters': to get an overview of all the CPU registers.
|
|
342
|
+
'getRegister <register>': to get the decimal value of a specific CPU register (pc, sp, ix, iy, af, bc, de, hl, ixh, ixl, iyh, iyl, a, f, b, c, d, e, h, l, i, r, im, iff).
|
|
343
|
+
'setRegister <register> <value>': to set the value of a specific CPU register (pc, sp, ix, iy, af, bc, de, hl, ixh, ixl, iyh, iyl, a, f, b, c, d, e, h, l, i, r, im, iff).
|
|
344
|
+
'getStackPile': to get an overview of the CPU stack.
|
|
345
|
+
'disassemble [address] [size]': to print disassembled instructions at the address parameter location or PC register if empty.
|
|
346
|
+
'getActiveCpu': to return the active cpu: z80 or r800.
|
|
347
|
+
"**Important Note**: Addresses and values are in hexadecimal format (e.g. 0xd2 0x3af2)."
|
|
348
|
+
`),
|
|
349
|
+
register: z.enum(["pc", "sp", "ix", "iy", "af", "bc", "de", "hl", "ixh", "ixl", "iyh", "iyl", "a", "f", "b", "c", "d", "e", "h", "l", "i", "r", "im", "iff"]).optional()
|
|
350
|
+
.describe("CPU register to read/write. Used by [getRegister, setRegister]"),
|
|
351
|
+
address: z.string().regex(/^0x[0-9a-fA-F]{4}$/).optional().describe("4 hexadecimal digits for a memory address (e.g. 0x4af3). Used by [disassemble]"),
|
|
352
|
+
value: z.string().regex(/^0x[0-9a-fA-F]{2,4}$/).optional().describe("2-4 hexadecimal digits for a byte value (e.g. 0xa5 or 0xa5b1). Used by [setRegister]"),
|
|
353
|
+
size: z.number().min(8).max(50).optional().describe("Number of bytes to disassemble. Used by [disassemble]"),
|
|
354
|
+
},
|
|
348
355
|
},
|
|
349
356
|
// Handler for the tool (function to be executed when the tool is called)
|
|
350
357
|
async ({ command, address, register, value, size }) => {
|
|
@@ -378,27 +385,28 @@ async function registerAllTools(server) {
|
|
|
378
385
|
response
|
|
379
386
|
]);
|
|
380
387
|
});
|
|
381
|
-
server.
|
|
388
|
+
server.registerTool(
|
|
382
389
|
// Name of the tool (used to call it)
|
|
383
|
-
"debug_memory",
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
390
|
+
"debug_memory", {
|
|
391
|
+
title: "Memory tools",
|
|
392
|
+
// Description of the tool (what it does)
|
|
393
|
+
description: "Slots info, and Read/write from/to memory in the openMSX emulator.",
|
|
394
|
+
// Schema for the tool (input validation)
|
|
395
|
+
inputSchema: {
|
|
396
|
+
command: z.enum(["selectedSlots", "getBlock", "readByte", "readWord", "writeByte", "writeWord"]).describe(`Available commands:
|
|
397
|
+
'selectedSlots': to get a list of the currently selected memory slots.
|
|
398
|
+
'getBlock <address> [lines]': to read a block of memory from the specified address.
|
|
399
|
+
'readByte <address>': to read a BYTE from the specified address.
|
|
400
|
+
'readWord <address>': to read a WORD from the specified address.
|
|
401
|
+
'writeByte <address> <value8>': to write a BYTE to the specified address.
|
|
402
|
+
'writeWord <address> <value16>': to write a WORD to the specified address.
|
|
403
|
+
**Important Note**: Addresses and values are in hexadecimal format (e.g. 0x0000).
|
|
404
|
+
`),
|
|
405
|
+
address: z.string().regex(/^0x[0-9a-fA-F]{4}$/).optional().describe("4 hexadecimal digits for a memory address (e.g. 0x4af3). Used by [getBlock, readByte, writeByte, readWord, writeWord]"),
|
|
406
|
+
lines: z.number().min(1).max(50).optional().default(8).describe("Number of lines to obtain. Used by [getBlock]"),
|
|
407
|
+
value8: z.string().regex(/^0x[0-9a-fA-F]{2}$/).optional().describe("2 hexadecimal digits for a byte value (e.g. 0xa5). Used by [writeByte]"),
|
|
408
|
+
value16: z.string().regex(/^0x[0-9a-fA-F]{4}$/).optional().describe("4 hexadecimal digits for a word value (e.g. 0xa5b1). Used by [writeWord]"),
|
|
409
|
+
},
|
|
402
410
|
},
|
|
403
411
|
// Handler for the tool (function to be executed when the tool is called)
|
|
404
412
|
async ({ command, address, lines, value8, value16 }) => {
|
|
@@ -432,23 +440,24 @@ async function registerAllTools(server) {
|
|
|
432
440
|
response
|
|
433
441
|
]);
|
|
434
442
|
});
|
|
435
|
-
server.
|
|
443
|
+
server.registerTool(
|
|
436
444
|
// Name of the tool (used to call it)
|
|
437
|
-
"debug_vram",
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
445
|
+
"debug_vram", {
|
|
446
|
+
title: "VRAM tools",
|
|
447
|
+
// Description of the tool (what it does)
|
|
448
|
+
description: "Read or write from/to VRAM video memory from the openMSX emulator.",
|
|
449
|
+
// Schema for the tool (input validation)
|
|
450
|
+
inputSchema: {
|
|
451
|
+
command: z.enum(["getBlock", "readByte", "writeByte"]).describe(`Available commands:
|
|
452
|
+
'getBlock <address> [lines]': to read a block of VRAM memory from the specified address.
|
|
453
|
+
'readByte <address>': to read a BYTE from the specified VRAM address.
|
|
454
|
+
'writeByte <address> <value8>': to write a BYTE to the specified VRAM address.
|
|
455
|
+
**Important Note**: Addresses and values are in hexadecimal format (e.g. 0x0000).
|
|
456
|
+
`),
|
|
457
|
+
address: z.string().regex(/^0x[0-9a-fA-F]{5}$/).optional().describe("5 hexadecimal digits for a VRAM address (e.g. 0x04af3). Used by [getBlock, readByte, writeByte]"),
|
|
458
|
+
lines: z.number().min(1).max(50).optional().default(8).describe("Number of lines to obtain. Used by [getBlock]"),
|
|
459
|
+
value8: z.string().regex(/^0x[0-9a-fA-F]{2}$/).optional().describe("2 hexadecimal digits for a byte value (e.g. 0xa5). Used by [writeByte]"),
|
|
460
|
+
},
|
|
452
461
|
},
|
|
453
462
|
// Handler for the tool (function to be executed when the tool is called)
|
|
454
463
|
async ({ command, address, lines, value8 }) => {
|
|
@@ -473,23 +482,24 @@ async function registerAllTools(server) {
|
|
|
473
482
|
response
|
|
474
483
|
]);
|
|
475
484
|
});
|
|
476
|
-
server.
|
|
485
|
+
server.registerTool(
|
|
477
486
|
// Name of the tool (used to call it)
|
|
478
|
-
"debug_breakpoints",
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
487
|
+
"debug_breakpoints", {
|
|
488
|
+
title: "Breakpoints tools",
|
|
489
|
+
// Description of the tool (what it does)
|
|
490
|
+
description: "Create, remove, and list breakpoints.",
|
|
491
|
+
// Schema for the tool (input validation)
|
|
492
|
+
inputSchema: {
|
|
493
|
+
command: z.enum(["create", "remove", "list"]).describe(`Available commands:
|
|
494
|
+
'create <address>': create a breakpoint at a specified address, and returns its name.
|
|
495
|
+
'remove <bpname>': remove a breakpoint by name (e.g. bp#1).
|
|
496
|
+
'list': enumerate the active breakpoints.
|
|
497
|
+
"**Important Note**: Addresses and values are in hexadecimal format (e.g. 0x4af3).
|
|
498
|
+
"**Important Note**: The memory addresses of functions and variables can be previously obtained from *.sym or *.map files.
|
|
499
|
+
`),
|
|
500
|
+
address: z.string().regex(/^0x[0-9a-fA-F]{4}$/).optional().describe("4 hexadecimal digits for a memory address (e.g. 0x4af3). Used by [create]"),
|
|
501
|
+
bpname: z.string().min(3).max(10).optional().describe("Breakpoint name (e.g. bp#1). Used by [remove]"),
|
|
502
|
+
},
|
|
493
503
|
},
|
|
494
504
|
// Handler for the tool (function to be executed when the tool is called)
|
|
495
505
|
async ({ command, address, bpname }) => {
|
|
@@ -514,21 +524,22 @@ async function registerAllTools(server) {
|
|
|
514
524
|
response
|
|
515
525
|
]);
|
|
516
526
|
});
|
|
517
|
-
server.
|
|
527
|
+
server.registerTool(
|
|
518
528
|
// Name of the tool (used to call it)
|
|
519
|
-
"emu_savestates",
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
529
|
+
"emu_savestates", {
|
|
530
|
+
title: "Save states tools",
|
|
531
|
+
// Description of the tool (what it does)
|
|
532
|
+
description: "Load, save, and list savestates.",
|
|
533
|
+
// Schema for the tool (input validation)
|
|
534
|
+
inputSchema: {
|
|
535
|
+
command: z.enum(["load", "save", "list"]).describe(`Available commands:
|
|
536
|
+
'load <name>': restores a previously created savestate.
|
|
537
|
+
'save <name>': creates a snapshot of the currently emulated MSX machine specifying a name for the savestate.
|
|
538
|
+
'list': returns the names of all previously created savestates, separated by spaces.
|
|
539
|
+
**Important Note**: names with spaces are enclosed in {}.
|
|
540
|
+
`),
|
|
541
|
+
name: z.string().min(1).max(20).optional().describe("Name of the savestate to load/save. Used by [load, save]"),
|
|
542
|
+
},
|
|
532
543
|
},
|
|
533
544
|
// Handler for the tool (function to be executed when the tool is called)
|
|
534
545
|
async ({ command, name }) => {
|
|
@@ -558,32 +569,35 @@ async function registerAllTools(server) {
|
|
|
558
569
|
response
|
|
559
570
|
]);
|
|
560
571
|
});
|
|
561
|
-
server.
|
|
572
|
+
server.registerTool(
|
|
562
573
|
// Name of the tool (used to call it)
|
|
563
|
-
"emu_replay",
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
574
|
+
"emu_replay", {
|
|
575
|
+
title: "Replay tools",
|
|
576
|
+
// Description of the tool (what it does)
|
|
577
|
+
description: "When replay is enabled (the default) the emulator collect data while emulating, which enables you to go back and forward in the emulated MSX time.",
|
|
578
|
+
// Schema for the tool (input validation)
|
|
579
|
+
inputSchema: {
|
|
580
|
+
command: z.enum(["start", "stop", "status", "goBack", "absoluteGoto", "truncate", "advanceFrame", "reverseFrame", "saveReplay", "loadReplay"]).describe(`Available commands:
|
|
581
|
+
'start': starts the replay mode (enabled by default when emulator is launched).
|
|
582
|
+
'stop': stops the replay mode.
|
|
583
|
+
'status': gives information about the replay feature and the data that is collected.
|
|
584
|
+
'goBack <seconds>': go back specified seconds (1-60) in the timeline, you cannot go back to a time before the time the replay started.
|
|
585
|
+
'absoluteGoto <time>': go to the indicated absolute time in seconds in the MSX timeline, if time is before replay started it will jump to the time when is started.
|
|
586
|
+
'truncate': stop replaying and wipe all the future replay data after now.
|
|
587
|
+
'advanceFrame' [frames]: advances a number of frames in the replay timeline, useful to advance the timeline while debugging.
|
|
588
|
+
'reverseFrame' [frames]: reverses a number of frames in the replay timeline, useful to reverse the timeline while debugging.
|
|
589
|
+
'saveReplay [filename]': saves the current replay data to a file (extension .omr), filename is returned in the response.
|
|
590
|
+
'loadReplay <filename>': loads a previously saved replay file (extension .omr), starts replaying from the begin, and starts replay mode.
|
|
591
|
+
**Important Note**: consider do a #debug_run 'break' to maintain the timeline before a 'goBack' or 'absoluteGoto'.
|
|
592
|
+
`),
|
|
593
|
+
seconds: z.number().min(1).max(60).optional().describe("Seconds to go back. Used by [goBack]"),
|
|
594
|
+
time: z.string().regex(/^\d+$/).optional().describe("Absolute time in seconds to go to. Used by [absoluteGoto]"),
|
|
595
|
+
frames: z.number().min(1).max(1000).optional().default(1).describe("Number of frames to advance/reverse. Used by [advanceFrame, reverseFrame]"),
|
|
596
|
+
filename: z.string().min(1).max(200).optional().describe("Filename to save/load replay. Used by [saveReplay, loadReplay]"),
|
|
597
|
+
},
|
|
584
598
|
},
|
|
585
599
|
// Handler for the tool (function to be executed when the tool is called)
|
|
586
|
-
async ({ command, seconds, time, filename }) => {
|
|
600
|
+
async ({ command, seconds, time, frames, filename }) => {
|
|
587
601
|
let tclCommand;
|
|
588
602
|
switch (command) {
|
|
589
603
|
case "start":
|
|
@@ -604,6 +618,12 @@ async function registerAllTools(server) {
|
|
|
604
618
|
case "truncate":
|
|
605
619
|
tclCommand = "reverse truncatereplay";
|
|
606
620
|
break;
|
|
621
|
+
case "advanceFrame":
|
|
622
|
+
tclCommand = `advance_frame ${frames}`;
|
|
623
|
+
break;
|
|
624
|
+
case "reverseFrame":
|
|
625
|
+
tclCommand = `reverse_frame ${frames}`;
|
|
626
|
+
break;
|
|
607
627
|
case "saveReplay":
|
|
608
628
|
if (filename)
|
|
609
629
|
filename = `"${OPENMSX_REPLAYS_DIR}${filename}"`;
|
|
@@ -624,20 +644,21 @@ async function registerAllTools(server) {
|
|
|
624
644
|
response
|
|
625
645
|
]);
|
|
626
646
|
});
|
|
627
|
-
server.
|
|
647
|
+
server.registerTool(
|
|
628
648
|
// Name of the tool (used to call it)
|
|
629
|
-
"emu_keyboard",
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
649
|
+
"emu_keyboard", {
|
|
650
|
+
title: "Keyboard tools",
|
|
651
|
+
// Description of the tool (what it does)
|
|
652
|
+
description: "Send a text to the openMSX emulator.",
|
|
653
|
+
// Schema for the tool (input validation)
|
|
654
|
+
inputSchema: {
|
|
655
|
+
command: z.enum(["sendText"]).describe(`Available commands:
|
|
656
|
+
'sendText <text>': type a string in the emulated MSX, this command automatically press and release keys in the MSX keyboard matrix.
|
|
657
|
+
**Important Note**: each 'text' sent is limited to 200 characters, and the 'text' is sent as if it was typed in the MSX keyboard.
|
|
658
|
+
**Important Note**: escape keys that needs it as Return key (use \\r), double quotes (use \\\"), etc...
|
|
659
|
+
`),
|
|
660
|
+
text: z.string().min(1).max(200).optional().default('').describe("Text to send to the emulator via emulated keyboard"),
|
|
661
|
+
},
|
|
641
662
|
},
|
|
642
663
|
// Handler for the tool (function to be executed when the tool is called)
|
|
643
664
|
async ({ command, text }) => {
|
|
@@ -656,18 +677,19 @@ async function registerAllTools(server) {
|
|
|
656
677
|
response
|
|
657
678
|
]);
|
|
658
679
|
});
|
|
659
|
-
server.
|
|
680
|
+
server.registerTool(
|
|
660
681
|
// Name of the tool (used to call it)
|
|
661
|
-
"screen_shot",
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
682
|
+
"screen_shot", {
|
|
683
|
+
title: "Screenshot tools",
|
|
684
|
+
// Description of the tool (what it does)
|
|
685
|
+
description: "Take a screenshot of the openMSX emulator screen.",
|
|
686
|
+
// Schema for the tool (input validation)
|
|
687
|
+
inputSchema: {
|
|
688
|
+
command: z.enum(["as_image", "to_file"]).describe(`Available commands:
|
|
689
|
+
'as_image': take a screenshot and the image is returned in the response.
|
|
690
|
+
'to_file': take a screenshot and save it to a file, the file name is returned in the response.
|
|
691
|
+
`),
|
|
692
|
+
},
|
|
671
693
|
},
|
|
672
694
|
// Handler for the tool (function to be executed when the tool is called)
|
|
673
695
|
async ({ command }) => {
|
|
@@ -712,16 +734,18 @@ async function registerAllTools(server) {
|
|
|
712
734
|
`Error: Unknown screen_shot command "${command}".`
|
|
713
735
|
]);
|
|
714
736
|
});
|
|
715
|
-
server.
|
|
737
|
+
server.registerTool(
|
|
716
738
|
// Name of the tool (used to call it)
|
|
717
|
-
"screen_dump",
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
739
|
+
"screen_dump", {
|
|
740
|
+
title: "Screen dump tools",
|
|
741
|
+
// Description of the tool (what it does)
|
|
742
|
+
description: `Take a screendump of the openMSX emulator screen as SC?.
|
|
743
|
+
The parameter scrbasename is the name of the filename (without path) to save the screendump, default is 'screendump'.
|
|
744
|
+
`,
|
|
745
|
+
// Schema for the tool (input validation)
|
|
746
|
+
inputSchema: {
|
|
747
|
+
scrbasename: z.string().min(1).max(100).default("screendump").describe("Screendump filename (without path or extension) to save the screendump; default is 'screendump'"),
|
|
748
|
+
},
|
|
725
749
|
},
|
|
726
750
|
// Handler for the tool (function to be executed when the tool is called)
|
|
727
751
|
async ({ scrbasename }) => {
|
|
@@ -732,94 +756,105 @@ async function registerAllTools(server) {
|
|
|
732
756
|
response
|
|
733
757
|
]);
|
|
734
758
|
});
|
|
735
|
-
server.
|
|
759
|
+
server.registerTool(
|
|
736
760
|
// Name of the tool (used to call it)
|
|
737
|
-
"basic_programming",
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
761
|
+
"basic_programming", {
|
|
762
|
+
title: "BASIC programming tools",
|
|
763
|
+
// Description of the tool (what it does)
|
|
764
|
+
description: "Helper tool for developing BASIC programs.",
|
|
765
|
+
// Schema for the tool (input validation)
|
|
766
|
+
inputSchema: {
|
|
767
|
+
command: z.enum(["isBasicAvailable", "newProgram", "runProgram", "setProgram", "getFullProgram", "getFullProgramAdvanced", "listProgramLines", "deleteProgramLines"]).describe(`Available commands:
|
|
768
|
+
'isBasicAvailable': checks if the current machine is ready to manage BASIC programs (true), or not (false).
|
|
769
|
+
'newProgram': clears the current BASIC program.
|
|
770
|
+
'setProgram <program>': sets a full BASIC program or updates part of the current BASIC program with the specified string.
|
|
771
|
+
'runProgram': runs the current BASIC program.
|
|
772
|
+
'getFullProgram': retrieves the current BASIC program as plain text; very useful in text screen modes.
|
|
773
|
+
'getFullProgramAdvanced': retrieves the current BASIC program along with the RAM address where each line is stored.
|
|
774
|
+
'listProgramLines <startLine> [endLine]': lists the selected range of lines from the current BASIC program on the emulator screen.
|
|
775
|
+
'deleteProgramLines <startLine> [endLine]': deletes a specific range of lines from the current BASIC program; if endLine is not specified, only the startLine is deleted.
|
|
776
|
+
**Important Note**: if error 'not in BASIC mode' then use the command 'isBasicAvailable' to wait for a ready state.
|
|
777
|
+
**Important Note**: prioritize these tools for developing BASIC programs, as they are more efficient than using the 'sendText' tool.
|
|
778
|
+
**Important Note**: all program lines must end with a carriage return (\\r) to be processed correctly, including the last line.
|
|
779
|
+
**Important Note**: if you have questions about MSX BASIC, use the resources provided by this MCP server.
|
|
780
|
+
`),
|
|
781
|
+
program: z.string().min(1).max(10000).optional().describe("Basic program to set; use only \\r for line endings, even the last one. Used by [setProgram]"),
|
|
782
|
+
startLine: z.number().min(0).max(9999).optional().describe("Start line number to list/delete BASIC program lines. Used by [listProgramLines, deleteProgramLines]"),
|
|
783
|
+
endLine: z.number().min(0).max(9999).optional().describe("End line number to list/delete BASIC program lines. Used by [listProgramLines, deleteProgramLines]"),
|
|
784
|
+
},
|
|
758
785
|
},
|
|
759
786
|
// Handler for the tool (function to be executed when the tool is called)
|
|
760
787
|
async ({ command, program, startLine, endLine }) => {
|
|
761
788
|
const CTRL_L_TEMPLATE = 'keymatrixdown 6 2 ; keymatrixdown 4 2 ; after time 0.1 { keymatrixup 6 2 ; keymatrixup 4 2 ; type_via_keybuf "%s" }';
|
|
762
789
|
let tclCommand = undefined;
|
|
763
790
|
let response = undefined;
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
if (response.startsWith('after#'))
|
|
773
|
-
response = '';
|
|
774
|
-
break;
|
|
775
|
-
case "deleteProgramLines":
|
|
776
|
-
if (startLine === undefined) {
|
|
777
|
-
response = 'Error: No startLine number provided to delete BASIC program lines.';
|
|
791
|
+
const inBasic = await openMSXInstance.emu_isInBasic();
|
|
792
|
+
if (command !== "isBasicAvailable" && !inBasic) {
|
|
793
|
+
response = 'Error: The current MSX machine is not in BASIC mode.';
|
|
794
|
+
}
|
|
795
|
+
else
|
|
796
|
+
switch (command) {
|
|
797
|
+
case "isBasicAvailable":
|
|
798
|
+
response = inBasic.toString();
|
|
778
799
|
break;
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
if (!program) {
|
|
784
|
-
response = 'Error: No BASIC program provided to set.';
|
|
800
|
+
case "newProgram":
|
|
801
|
+
response = await openMSXInstance.sendCommand(CTRL_L_TEMPLATE.replace('%s', encodeTypeText('new\r')));
|
|
802
|
+
if (response.startsWith('after#'))
|
|
803
|
+
response = '';
|
|
785
804
|
break;
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
response = speed;
|
|
805
|
+
case "runProgram":
|
|
806
|
+
response = await openMSXInstance.sendCommand(CTRL_L_TEMPLATE.replace('%s', encodeTypeText('run\r')));
|
|
807
|
+
if (response.startsWith('after#'))
|
|
808
|
+
response = '';
|
|
791
809
|
break;
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
810
|
+
case "deleteProgramLines":
|
|
811
|
+
if (startLine === undefined) {
|
|
812
|
+
response = 'Error: No startLine number provided to delete BASIC program lines.';
|
|
813
|
+
break;
|
|
814
|
+
}
|
|
815
|
+
response = await openMSXInstance.sendCommand(CTRL_L_TEMPLATE.replace('%s', encodeTypeText(`delete ${startLine}-${endLine || startLine}\r`)));
|
|
795
816
|
break;
|
|
796
|
-
|
|
797
|
-
|
|
817
|
+
case "setProgram":
|
|
818
|
+
if (!program) {
|
|
819
|
+
response = 'Error: no BASIC program provided to set.';
|
|
820
|
+
break;
|
|
821
|
+
}
|
|
822
|
+
if (program.includes('\n') || program.includes('\\n')) {
|
|
823
|
+
response = 'Error: you cannot use \\n for line endings, use only \\r instead.';
|
|
824
|
+
break;
|
|
825
|
+
}
|
|
826
|
+
// Escape '$' characters if '(' is the next character and is not escaped yet (openMSX variable substitutions)
|
|
827
|
+
program = program.replace(/([^\\])(\$\()/g, '$1\\$2');
|
|
828
|
+
// Get current speed to restore it later
|
|
829
|
+
let speed = '100';
|
|
830
|
+
if (isErrorResponse(speed = await openMSXInstance.sendCommand('set speed'))) {
|
|
831
|
+
response = speed;
|
|
832
|
+
break;
|
|
833
|
+
}
|
|
834
|
+
// Set speed to fast, type de program, wait to end, and restore speed
|
|
835
|
+
if (isErrorResponse(response = await openMSXInstance.sendCommand(`set speed 10000 ; type_via_keybuf "${encodeTypeText(program)}" ; after idle 20 { set speed ${speed} }`)))
|
|
836
|
+
break;
|
|
837
|
+
// Success response
|
|
838
|
+
response = '';
|
|
798
839
|
break;
|
|
799
|
-
|
|
800
|
-
|
|
840
|
+
case "getFullProgram":
|
|
841
|
+
// Source: https://www.msx.org/forum/msx-talk/openmsx/export-basic-listing#comment-407392
|
|
842
|
+
tclCommand = 'regsub -all -line {^[0-9a-f]x[0-9a-f]{4} > } [ listing ] ""';
|
|
801
843
|
break;
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
break;
|
|
805
|
-
case "getFullProgram":
|
|
806
|
-
// Source: https://www.msx.org/forum/msx-talk/openmsx/export-basic-listing#comment-407392
|
|
807
|
-
tclCommand = 'regsub -all -line {^[0-9a-f]x[0-9a-f]{4} > } [ listing ] ""';
|
|
808
|
-
break;
|
|
809
|
-
case "getFullProgramAdvanced":
|
|
810
|
-
tclCommand = "listing";
|
|
811
|
-
break;
|
|
812
|
-
case "listProgramLines":
|
|
813
|
-
if (startLine === undefined) {
|
|
814
|
-
response = 'Error: No start line provided to list BASIC program lines.';
|
|
844
|
+
case "getFullProgramAdvanced":
|
|
845
|
+
tclCommand = "listing";
|
|
815
846
|
break;
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
847
|
+
case "listProgramLines":
|
|
848
|
+
if (startLine === undefined) {
|
|
849
|
+
response = 'Error: No start line provided to list BASIC program lines.';
|
|
850
|
+
break;
|
|
851
|
+
}
|
|
852
|
+
tclCommand = `type_via_keybuf \"${encodeTypeText(`list ${startLine}-${endLine || startLine}\r`)}\"`;
|
|
853
|
+
break;
|
|
854
|
+
default:
|
|
855
|
+
response = `Error: Unknown command "${command}".`;
|
|
856
|
+
break;
|
|
857
|
+
}
|
|
823
858
|
if (response === undefined && tclCommand) {
|
|
824
859
|
response = await openMSXInstance.sendCommand(tclCommand);
|
|
825
860
|
}
|
|
@@ -836,7 +871,7 @@ async function registerAllTools(server) {
|
|
|
836
871
|
const tocContent = JSON.parse(await fs.readFile(tocFile, 'utf8'));
|
|
837
872
|
tocContent.toc.forEach((item, itemIndex) => {
|
|
838
873
|
const itemName = item.uri.split('/').pop() || '';
|
|
839
|
-
server.
|
|
874
|
+
server.registerResource(
|
|
840
875
|
// Name of the resource (used to call it)
|
|
841
876
|
`msxdocs_${sectionName}_${itemName}`,
|
|
842
877
|
// Resource URI template
|
|
@@ -887,6 +922,53 @@ async function registerAllTools(server) {
|
|
|
887
922
|
});
|
|
888
923
|
}
|
|
889
924
|
;
|
|
925
|
+
server.resource("msxdocs_msxorg_wiki", new ResourceTemplate("msxdocs://msxorg_wiki/{section}", {
|
|
926
|
+
list: undefined,
|
|
927
|
+
complete: {
|
|
928
|
+
section: (value) => [
|
|
929
|
+
"ABS()", "AND", "ASC()", "ATN()", "AUTO", "BASE()", "BEEP", "BIN$()", "BLOAD", "BSAVE", "CALL", "CALL ADJUST", "CALL PAUSE", "CALL PCMPLAY", "CALL PCMREC",
|
|
930
|
+
"CDBL()", "CHR$()", "CINT()", "CIRCLE", "CLEAR", "CLOAD", "CLOAD?", "CLOSE", "CLS", "COLOR", "COLOR=", "COLOR", "COLOR", "CONT", "COPY", "COPY", "COS()", "CSAVE",
|
|
931
|
+
"CSNG()", "CSRLIN", "DATA", "DEFDBL", "DEF FN", "DEFINT", "DEFSNG", "DEFSTR", "DEF USR", "DELETE", "DIM", "DRAW", "ELSE", "END", "EOF()", "EQV", "ERASE", "ERL", "ERR",
|
|
932
|
+
"ERROR", "EXP()", "FIX()", "FN MSX1", "FOR...NEXT", "FRE()", "GET DATE", "GET TIME", "GOSUB", "GOTO", "HEX$()", "IF...GOTO...ELSE", "IF...THEN...ELSE",
|
|
933
|
+
"IMP", "INKEY$", "INP()", "INPUT", "INPUT$()", "INSTR()", "INT()", "INTERVAL", "KEY", "KEY()", "LEFT$()", "LEN()", "LET", "LINE", "LINE INPUT", "LIST",
|
|
934
|
+
"LLIST", "LOAD", "LOCATE", "LOG()", "LPOS()", "LPRINT", "MAXFILES", "MERGE", "MID$()", "MOD", "MOTOR", "NEW", "NOT", "OCT$()", "ON...GOSUB", "ON...GOTO",
|
|
935
|
+
"ON ERROR GOTO", "ON INTERVAL GOSUB", "ON KEY GOSUB", "ON SPRITE GOSUB", "ON STOP GOSUB", "ON STRIG GOSUB", "OPEN", "OR", "OUT", "PAD()", "PAINT", "PDL()",
|
|
936
|
+
"PEEK()", "PLAY", "PLAY()", "POINT", "POKE", "POS()", "PRESET", "PRINT", "PSET", "PUT KANJI", "PUT SPRITE", "READ", "REM", "RENUM", "RESTORE", "RESUME",
|
|
937
|
+
"RETURN", "RIGHT$()", "RND()", "RUN", "SAVE", "SCREEN", "SET ADJUST", "SET BEEP", "SET DATE", "SET PAGE", "SET PASSWORD", "SET PROMPT", "SET SCREEN",
|
|
938
|
+
"SET SCROLL", "SET TIME", "SET TITLE", "SET VIDEO", "SGN()", "SIN()", "SOUND", "SPACE$()", "SPC()", "SPRITE", "SPRITE$()", "SQR()", "STICK()", "STOP",
|
|
939
|
+
"STR$()", "STRIG()", "STRING$()", "SWAP", "TAB()", "TAN()", "TIME", "TROFF", "TRON", "USR()", "VAL()", "VARPTR()", "VDP()", "VPEEK()", "VPOKE", "WAIT",
|
|
940
|
+
"WIDTH", "XOR"
|
|
941
|
+
],
|
|
942
|
+
},
|
|
943
|
+
}), {
|
|
944
|
+
title: "BASIC MSX Documentation",
|
|
945
|
+
description: "Documentation about all the standard MSX-BASIC instructions.",
|
|
946
|
+
mimeType: "text/html",
|
|
947
|
+
}, async (uri, variables) => {
|
|
948
|
+
const section = variables.section.replace(/ /g, '_').replace(/\?/g, '%3F').replace(/=/g, '%3D');
|
|
949
|
+
const url = `https://www.msx.org/wiki/${section}`;
|
|
950
|
+
let resourceContent;
|
|
951
|
+
let mimeType;
|
|
952
|
+
try {
|
|
953
|
+
resourceContent = await fetch(url).then(response => {
|
|
954
|
+
mimeType = response.headers.get('content-type') || 'text/plain';
|
|
955
|
+
return response.text();
|
|
956
|
+
}) || 'Error downloading resource content';
|
|
957
|
+
// Remove script, style, and link tags from the content
|
|
958
|
+
resourceContent = resourceContent.replace(/<script\b[^>]*>[\s\S]*?<\/script>|<style\b[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\/?>/gi, '');
|
|
959
|
+
}
|
|
960
|
+
catch (error) {
|
|
961
|
+
// Throw exception (MCP protocol requirement)
|
|
962
|
+
throw new Error(`Error fetching resource "${uri}" from "${url}": ${error instanceof Error ? error.message : String(error)}`);
|
|
963
|
+
}
|
|
964
|
+
return {
|
|
965
|
+
contents: [{
|
|
966
|
+
uri: uri.href,
|
|
967
|
+
text: resourceContent,
|
|
968
|
+
mimeType: mimeType || 'text/plain',
|
|
969
|
+
}],
|
|
970
|
+
};
|
|
971
|
+
});
|
|
890
972
|
}
|
|
891
973
|
async function addFileExtension(filePath) {
|
|
892
974
|
// Get directory and filename
|
|
@@ -1055,7 +1137,13 @@ async function createServerInstance() {
|
|
|
1055
1137
|
version: PACKAGE_VERSION,
|
|
1056
1138
|
});
|
|
1057
1139
|
// Re-register all tools (you might want to extract this to a separate function)
|
|
1058
|
-
|
|
1140
|
+
try {
|
|
1141
|
+
await registerAllTools(newServer);
|
|
1142
|
+
}
|
|
1143
|
+
catch (error) {
|
|
1144
|
+
console.error("Error registering tools/resources:", error);
|
|
1145
|
+
throw error;
|
|
1146
|
+
}
|
|
1059
1147
|
return newServer;
|
|
1060
1148
|
}
|
|
1061
1149
|
// ============================================================================
|
package/package.json
CHANGED
package/resources/bios/toc.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"title": "
|
|
3
|
-
"description": "MSX Technical Info from
|
|
2
|
+
"title": "MSX Technical about BIOS",
|
|
3
|
+
"description": "MSX Technical Info about BIOS calls, including references for MSX BIOS, MSX2 SUBROM BIOS, and how to call BIOS from MSX-DOS.",
|
|
4
4
|
"toc": [
|
|
5
5
|
{
|
|
6
6
|
"title": "MSX BIOS calls reference",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"title": "
|
|
3
|
-
"description": "MSX Technical Info
|
|
2
|
+
"title": "MSX-DOS Technical Info",
|
|
3
|
+
"description": "MSX-DOS Technical Info including MSX-DOS 2 Program Interface Specification and MSX-DOS 2 Function Specifications.",
|
|
4
4
|
"toc": [
|
|
5
5
|
{
|
|
6
6
|
"title": "MSX-DOS 2 Program Interface Specification",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"title": "
|
|
3
|
-
"description": "
|
|
2
|
+
"title": "CPU Technical Info",
|
|
3
|
+
"description": "Technical Info about the Z80, R800, and others processors, including detailed instruction sets, undocumented instructions, and timing information.",
|
|
4
4
|
"toc": [
|
|
5
5
|
{
|
|
6
6
|
"title": "Z80 Detailed Instruction Set (Z80 Heaven)",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"title": "
|
|
3
|
-
"description": "MSX Technical Info
|
|
2
|
+
"title": "MSX System Technical Info",
|
|
3
|
+
"description": "MSX System Technical Info including I/O ports, system variables, and hardware interfacing.",
|
|
4
4
|
"toc": [
|
|
5
5
|
{
|
|
6
6
|
"title": "MSX I/O ports overview",
|