@akiojin/unity-mcp-server 2.14.16 → 2.14.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akiojin/unity-mcp-server",
3
- "version": "2.14.16",
3
+ "version": "2.14.17",
4
4
  "description": "MCP server and Unity Editor bridge — enables AI assistants to control Unity for AI-assisted workflows",
5
5
  "type": "module",
6
6
  "main": "src/core/server.js",
@@ -4,11 +4,81 @@
4
4
  */
5
5
  import { logger } from '../../core/config.js';
6
6
 
7
+ function cloneSchema(schema) {
8
+ if (!schema || typeof schema !== 'object') {
9
+ return schema;
10
+ }
11
+
12
+ if (typeof structuredClone === 'function') {
13
+ return structuredClone(schema);
14
+ }
15
+
16
+ try {
17
+ return JSON.parse(JSON.stringify(schema));
18
+ } catch {
19
+ return schema;
20
+ }
21
+ }
22
+
23
+ function sanitizeSchema(schema) {
24
+ if (!schema) {
25
+ return schema;
26
+ }
27
+
28
+ if (Array.isArray(schema)) {
29
+ schema.forEach(item => sanitizeSchema(item));
30
+ return schema;
31
+ }
32
+
33
+ if (typeof schema !== 'object') {
34
+ return schema;
35
+ }
36
+
37
+ if (Array.isArray(schema.required) && schema.required.length === 0) {
38
+ delete schema.required;
39
+ }
40
+
41
+ if (schema.properties && typeof schema.properties === 'object') {
42
+ Object.values(schema.properties).forEach(value => sanitizeSchema(value));
43
+ }
44
+
45
+ if (schema.items) {
46
+ sanitizeSchema(schema.items);
47
+ }
48
+
49
+ if (Array.isArray(schema.anyOf)) {
50
+ schema.anyOf.forEach(branch => sanitizeSchema(branch));
51
+ }
52
+
53
+ if (Array.isArray(schema.oneOf)) {
54
+ schema.oneOf.forEach(branch => sanitizeSchema(branch));
55
+ }
56
+
57
+ if (Array.isArray(schema.allOf)) {
58
+ schema.allOf.forEach(branch => sanitizeSchema(branch));
59
+ }
60
+
61
+ if (schema.then) {
62
+ sanitizeSchema(schema.then);
63
+ }
64
+
65
+ if (schema.else) {
66
+ sanitizeSchema(schema.else);
67
+ }
68
+
69
+ if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {
70
+ sanitizeSchema(schema.additionalProperties);
71
+ }
72
+
73
+ return schema;
74
+ }
75
+
7
76
  export class BaseToolHandler {
8
77
  constructor(name, description, inputSchema = {}) {
9
78
  this.name = name;
10
79
  this.description = description;
11
- this.inputSchema = inputSchema;
80
+ const clonedSchema = cloneSchema(inputSchema) || {};
81
+ this.inputSchema = sanitizeSchema(clonedSchema);
12
82
  }
13
83
 
14
84
  /**
@@ -13,7 +13,15 @@ export class SetUIElementValueToolHandler extends BaseToolHandler {
13
13
  description: 'Full hierarchy path to the UI element'
14
14
  },
15
15
  value: {
16
- description: 'New value to set (type depends on element type)'
16
+ anyOf: [
17
+ { type: 'string' },
18
+ { type: 'number' },
19
+ { type: 'boolean' },
20
+ { type: 'object' },
21
+ { type: 'array' },
22
+ { type: 'null' }
23
+ ],
24
+ description: 'New value to set. Supports string, number, boolean, object, array, or null depending on the UI element type.'
17
25
  },
18
26
  triggerEvents: {
19
27
  type: 'boolean',
@@ -46,4 +54,4 @@ export class SetUIElementValueToolHandler extends BaseToolHandler {
46
54
 
47
55
  return result;
48
56
  }
49
- }
57
+ }