@akiojin/unity-mcp-server 4.2.1 → 5.0.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/package.json
CHANGED
package/src/core/config.js
CHANGED
|
@@ -649,10 +649,9 @@ function wrapUnityConnectError(error, host, port) {
|
|
|
649
649
|
}
|
|
650
650
|
|
|
651
651
|
function buildUnityConnectionHint(_host, _port) {
|
|
652
|
-
const configPath = config.__configPath || '.unity/config.json';
|
|
653
652
|
return (
|
|
654
653
|
`Start Unity Editor and ensure the Unity MCP package is running (TCP listener). ` +
|
|
655
|
-
`Check
|
|
656
|
-
`If using WSL2/Docker → Windows Unity, set
|
|
654
|
+
`Check UNITY_MCP_MCP_HOST / UNITY_MCP_PORT and Unity Project Settings (Host/Port). ` +
|
|
655
|
+
`If using WSL2/Docker → Windows Unity, set UNITY_MCP_MCP_HOST=host.docker.internal.`
|
|
657
656
|
);
|
|
658
657
|
}
|
|
@@ -30,6 +30,11 @@ export class ScriptEditSnippetToolHandler extends BaseToolHandler {
|
|
|
30
30
|
description:
|
|
31
31
|
'If true, run validation and return preview text without writing to disk. Default=false.'
|
|
32
32
|
},
|
|
33
|
+
skipValidation: {
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
description:
|
|
36
|
+
'If true, skip LSP validation for faster execution. Lightweight syntax checks (brace balance) are still performed. Use for simple edits on large files. Default=false.'
|
|
37
|
+
},
|
|
33
38
|
instructions: {
|
|
34
39
|
type: 'array',
|
|
35
40
|
minItems: 1,
|
|
@@ -114,6 +119,7 @@ export class ScriptEditSnippetToolHandler extends BaseToolHandler {
|
|
|
114
119
|
const info = await this.projectInfo.get();
|
|
115
120
|
const { relative, absolute } = this.#resolvePaths(info, params.path);
|
|
116
121
|
const preview = params.preview === true;
|
|
122
|
+
const skipValidation = params.skipValidation === true;
|
|
117
123
|
const instructions = params.instructions;
|
|
118
124
|
|
|
119
125
|
let original;
|
|
@@ -142,7 +148,13 @@ export class ScriptEditSnippetToolHandler extends BaseToolHandler {
|
|
|
142
148
|
}
|
|
143
149
|
|
|
144
150
|
if (working === original) {
|
|
145
|
-
return this.#buildResponse({
|
|
151
|
+
return this.#buildResponse({
|
|
152
|
+
preview,
|
|
153
|
+
results,
|
|
154
|
+
original,
|
|
155
|
+
updated: working,
|
|
156
|
+
validationSkipped: skipValidation
|
|
157
|
+
});
|
|
146
158
|
}
|
|
147
159
|
|
|
148
160
|
// Pre-syntax check on edited content before LSP validation
|
|
@@ -154,19 +166,30 @@ export class ScriptEditSnippetToolHandler extends BaseToolHandler {
|
|
|
154
166
|
);
|
|
155
167
|
}
|
|
156
168
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
const
|
|
162
|
-
|
|
169
|
+
// LSP validation (skip if skipValidation=true for large files)
|
|
170
|
+
let diagnostics = [];
|
|
171
|
+
if (!skipValidation) {
|
|
172
|
+
diagnostics = await this.#validateWithLsp(info, relative, working);
|
|
173
|
+
const hasErrors = diagnostics.some(d => this.#severityIsError(d.severity));
|
|
174
|
+
if (hasErrors) {
|
|
175
|
+
const first = diagnostics.find(d => this.#severityIsError(d.severity));
|
|
176
|
+
const msg = first?.message || 'syntax error';
|
|
177
|
+
throw new Error(`syntax_error: ${msg}`);
|
|
178
|
+
}
|
|
163
179
|
}
|
|
164
180
|
|
|
165
181
|
if (!preview) {
|
|
166
182
|
await fs.writeFile(absolute, working, 'utf8');
|
|
167
183
|
}
|
|
168
184
|
|
|
169
|
-
return this.#buildResponse({
|
|
185
|
+
return this.#buildResponse({
|
|
186
|
+
preview,
|
|
187
|
+
results,
|
|
188
|
+
original,
|
|
189
|
+
updated: working,
|
|
190
|
+
diagnostics,
|
|
191
|
+
validationSkipped: skipValidation
|
|
192
|
+
});
|
|
170
193
|
}
|
|
171
194
|
|
|
172
195
|
#resolvePaths(info, rawPath) {
|
|
@@ -279,12 +302,20 @@ export class ScriptEditSnippetToolHandler extends BaseToolHandler {
|
|
|
279
302
|
return await this.lsp.validateText(relative, updatedText);
|
|
280
303
|
}
|
|
281
304
|
|
|
282
|
-
#buildResponse({
|
|
305
|
+
#buildResponse({
|
|
306
|
+
preview,
|
|
307
|
+
results,
|
|
308
|
+
original,
|
|
309
|
+
updated,
|
|
310
|
+
diagnostics = [],
|
|
311
|
+
validationSkipped = false
|
|
312
|
+
}) {
|
|
283
313
|
const out = {
|
|
284
314
|
success: true,
|
|
285
315
|
applied: !preview,
|
|
286
316
|
results,
|
|
287
317
|
diagnostics,
|
|
318
|
+
validationSkipped,
|
|
288
319
|
beforeHash: this.#hash(original),
|
|
289
320
|
afterHash: this.#hash(updated)
|
|
290
321
|
};
|