@nataliapc/mcp-openmsx 1.1.3 → 1.1.4

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/dist/openmsx.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * @license GPL2
6
6
  */
7
7
  import fs from "fs/promises";
8
- import { extractDescriptionFromXML, decodeHtmlEntities } from "./utils.js";
8
+ import { extractDescriptionFromXML, decodeHtmlEntities, encodeHtmlEntities } from "./utils.js";
9
9
  import { spawn } from 'child_process';
10
10
  import path from 'path';
11
11
  /**
@@ -265,7 +265,7 @@ export class OpenMSX {
265
265
  async sendCommand(command) {
266
266
  try {
267
267
  // Send command
268
- this.writeData(`<command>${command}</command>\n`);
268
+ this.writeData(`<command>${encodeHtmlEntities(command)}</command>\n`);
269
269
  // Read response using readData()
270
270
  const output = (await this.readData()).trim();
271
271
  // Look for reply tags in the output
package/dist/server.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * through TCL commands via stdio.
7
7
  *
8
8
  * @package @nataliapc/mcp-openmsx
9
- * @version 1.1.3
9
+ * @version 1.1.4
10
10
  * @author Natalia Pujol Cremades (@nataliapc)
11
11
  * @license GPL2
12
12
  */
@@ -21,7 +21,7 @@ import fs from "fs/promises";
21
21
  import path from "path";
22
22
  import { openMSXInstance } from "./openmsx.js";
23
23
  // Version info for CLI
24
- const PACKAGE_VERSION = "1.1.3";
24
+ const PACKAGE_VERSION = "1.1.4";
25
25
  // Defaults for openMSX paths
26
26
  var OPENMSX_EXECUTABLE = 'openmsx';
27
27
  var OPENMSX_SHARE_DIR = '/usr/share/openmsx';
package/dist/utils.js CHANGED
@@ -32,16 +32,16 @@ export function decodeHtmlEntities(text) {
32
32
  '&gt;': '>',
33
33
  '&amp;': '&',
34
34
  '&quot;': '"',
35
+ '&nbsp;': ' ',
35
36
  '&#x27;': "'",
36
37
  '&#x2F;': '/',
37
38
  '&#x60;': '`',
38
39
  '&#x3D;': '=',
40
+ '&apos;': "'",
39
41
  '&#39;': "'",
40
42
  '&#47;': '/',
41
43
  '&#96;': '`',
42
44
  '&#61;': '=',
43
- '&apos;': "'",
44
- '&nbsp;': ' ',
45
45
  '&#x0a;': '\n',
46
46
  '&#x0A;': '\n',
47
47
  '&#10;': '\n',
@@ -52,3 +52,29 @@ export function decodeHtmlEntities(text) {
52
52
  return htmlEntities[entity] || entity;
53
53
  });
54
54
  }
55
+ /**
56
+ * Encode a plain text to HTML entities, also escaping characters with ASCII >= 127
57
+ * @param text - String to encode
58
+ * @returns string - String with HTML entities encoded
59
+ */
60
+ export function encodeHtmlEntities(text) {
61
+ const htmlEntities = {
62
+ '<': '&lt;',
63
+ '>': '&gt;',
64
+ '&': '&amp;',
65
+ '"': '&quot;',
66
+ "'": '&apos;',
67
+ '=': '&#61;',
68
+ '/': '&#47;',
69
+ };
70
+ return text.replace(/[\u00A0-\uFFFF<>&"'`=\/]/g, (char) => {
71
+ if (htmlEntities[char]) {
72
+ return htmlEntities[char];
73
+ }
74
+ const code = char.charCodeAt(0);
75
+ if (code >= 127) {
76
+ return `&#${code};`;
77
+ }
78
+ return char;
79
+ });
80
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nataliapc/mcp-openmsx",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Model context protocol server for openMSX automation and control",
5
5
  "main": "dist/server.js",
6
6
  "type": "module",