@akiojin/unity-mcp-server 5.3.1 → 5.3.2

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": "5.3.1",
3
+ "version": "5.3.2",
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,29 +4,45 @@ import { CSharpLspUtils } from './CSharpLspUtils.js';
4
4
 
5
5
  const sharedState = {
6
6
  proc: null,
7
- starting: null
7
+ starting: null,
8
+ version: null
8
9
  };
9
10
 
10
11
  export class LspProcessManager {
11
12
  constructor(options = {}) {
12
13
  const useShared = options.shared !== false;
13
- this.state = useShared ? sharedState : { proc: null, starting: null };
14
+ this.state = useShared ? sharedState : { proc: null, starting: null, version: null };
14
15
  this.utils = new CSharpLspUtils();
15
16
  }
16
17
 
17
18
  async ensureStarted() {
18
- if (this.state.proc && !this.state.proc.killed) return this.state.proc;
19
+ const rid = this.utils.detectRid();
20
+ const desired = this.utils.getDesiredVersion();
21
+ if (this.state.proc && !this.state.proc.killed) {
22
+ const local = this.utils.readLocalVersion(rid);
23
+ const procVersion = this.state.version;
24
+ const desiredVersion = desired || local || null;
25
+ if (procVersion && desiredVersion && procVersion !== desiredVersion) {
26
+ logger.warning(
27
+ `[unity-mcp-server:lsp] version changed (proc=${procVersion}, desired=${desiredVersion}), restarting`
28
+ );
29
+ await this.stop();
30
+ } else {
31
+ return this.state.proc;
32
+ }
33
+ }
19
34
  if (this.state.starting) return this.state.starting;
20
35
  this.state.starting = (async () => {
21
36
  try {
22
- const rid = this.utils.detectRid();
23
37
  const bin = await this.utils.ensureLocal(rid);
38
+ const resolvedVersion = this.utils.readLocalVersion(rid) || desired || null;
24
39
  const proc = spawn(bin, { stdio: ['pipe', 'pipe', 'pipe'] });
25
40
  proc.on('error', e => logger.error(`[unity-mcp-server:lsp] process error: ${e.message}`));
26
41
  proc.on('close', (code, sig) => {
27
42
  logger.warning(`[unity-mcp-server:lsp] exited code=${code} signal=${sig || ''}`);
28
43
  if (this.state.proc === proc) {
29
44
  this.state.proc = null;
45
+ this.state.version = null;
30
46
  }
31
47
  });
32
48
  proc.stderr.on('data', d => {
@@ -34,6 +50,7 @@ export class LspProcessManager {
34
50
  if (s) logger.debug(`[unity-mcp-server:lsp] ${s}`);
35
51
  });
36
52
  this.state.proc = proc;
53
+ this.state.version = resolvedVersion;
37
54
  logger.info(`[unity-mcp-server:lsp] started (pid=${proc.pid})`);
38
55
  return proc;
39
56
  } catch (e) {
@@ -52,6 +69,7 @@ export class LspProcessManager {
52
69
  if (!this.state.proc || this.state.proc.killed) return;
53
70
  const p = this.state.proc;
54
71
  this.state.proc = null;
72
+ this.state.version = null;
55
73
 
56
74
  // Remove all listeners to prevent memory leaks
57
75
  try {