mcp-unity: Failed to create client (Missing UNITY_PORT)

I installed the plugin, and made it configure cursor, but there’s an error in the MCP window:

Image

In cursor’s MCP output I have:

2025-05-09 15:05:44.463 [info] nity: Handling ReloadClient action
2025-05-09 15:05:44.464 [info] nity: Starting new stdio process with command: node /Users/user/dev/game/client/Library/PackageCache/com.gamelovers.mcp-unity@fe27f2b49103/Server/build/index.js
2025-05-09 15:05:44.547 [info] nity: Client closed for command
2025-05-09 15:05:44.547 [error] nity: Error in MCP: Client closed
2025-05-09 15:05:44.548 [error] nity: Failed to reload client: MCP error -32000: Connection closed
2025-05-09 15:05:44.550 [info] nity: Handling ListOfferings action
2025-05-09 15:05:44.550 [error] nity: No server info found

So I tried running node /Users/user/dev/game/client/Library/PackageCache/com.gamelovers.mcp-unity@fe27f2b49103/Server/build/index.js



node:internal/errors:983
  const err = new Error(message);
              ^

Error: Command failed: printenv UNITY_PORT
    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at checkExecSyncError (node:child_process:882:11)
    at execSync (node:child_process:954:15)
    at McpUnity.getUnityPortFromUnixRegistry (file:///Users/user/dev/game/client/Library/PackageCache/com.gamelovers.mcp-unity@fe27f2b49103/Server/build/unity/mcpUnity.js:249:16)
    at new McpUnity (file:///Users/user/dev/game/client/Library/PackageCache/com.gamelovers.mcp-unity@fe27f2b49103/Server/build/unity/mcpUnity.js:18:20)
    at file:///Users/user/dev/game/client/Library/PackageCache/com.gamelovers.mcp-unity@fe27f2b49103/Server/build/index.js:38:18
    at ModuleJob.run (node:internal/modules/esm/module_job:274:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:644:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:98:5) {
  status: 1,
  signal: null,
  output: [ null, Buffer(0) [Uint8Array] [], null ],
  pid: 12668,
  stdout: Buffer(0) [Uint8Array] [],
  stderr: null
}

Node.js v23.11.0

So I figured I’d try adding the port to the MCP config in Cursor:

"mcp-unity": {
      "command": "node",
      "args": [
        "/Users/user/dev/game/client/Library/PackageCache/com.gamelovers.mcp-unity@fe27f2b49103/Server/build/index.js"
      ],
      "env": {
        "UNITY_PORT": "8090"
      }
    }

And that seems to work:

2025-05-09 15:08:49.764 [info] nity: Handling ReloadClient action
2025-05-09 15:08:49.764 [info] nity: Cleaning up
2025-05-09 15:08:49.764 [info] nity: Starting new stdio process with command: node /Users/user/dev/game/client/Library/PackageCache/com.gamelovers.mcp-unity@fe27f2b49103/Server/build/index.js
2025-05-09 15:08:49.845 [info] nity: Successfully connected to stdio server
2025-05-09 15:08:49.845 [info] nity: Storing stdio client
2025-05-09 15:08:49.845 [info] nity: Successfully reloaded client
2025-05-09 15:08:49.845 [info] nity: Handling ListOfferings action
2025-05-09 15:08:49.845 [info] nity: Listing offerings
2025-05-09 15:08:49.845 [info] nity: Connected to stdio server, fetching offerings
2025-05-09 15:08:49.847 [info] listOfferings: Found 7 tools
2025-05-09 15:08:49.847 [info] nity: Found 7 tools, 0 resources, and 0 resource templates

But this UNITY_PORT is neither documented nor created by the tool so I’m wondering if this is an appropriate fix, or if there’s something wrong that could cause other side effects.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

yeah, baby! thanks for the update.

1.1.0 still gets me the same error in Cursor on Windows, even with the optional port set in Cursor config. (Claude connects fine)

Yes, I’m on a Mac.

This is indeed documented, but it looks like it’s optional, so not “troubleshooting”, and it’s not straightforward to understand where the error comes from (I had to run the command manually, many users won’t do that).

And like you said, it should work out of the bat, I imagine it’s not too hard to add (although it would need to be kept in sync, perhaps it’s ok to ask users to re-generate the config when they change the port, like you already tell them to reload the MCP server)