@chrrxs/robloxstudio-mcp-inspector 3.4.3 → 3.4.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/index.js CHANGED
@@ -10122,6 +10122,24 @@ async function runManageMonetization(request, context) {
10122
10122
  }
10123
10123
  }
10124
10124
 
10125
+ // ../core/dist/tools/playtest-start-errors.js
10126
+ var TEST_IN_PROGRESS = /previous one is still in progress/i;
10127
+ function describePlaytestStartFailure(studioError, subject) {
10128
+ if (TEST_IN_PROGRESS.test(studioError)) {
10129
+ return {
10130
+ error: "studio_test_in_progress",
10131
+ message: `Studio refused to start the ${subject} because it still considers a previous test in progress.`,
10132
+ studioError,
10133
+ recoveryHint: "If a test is still starting or running, end it first (solo_playtest stop or multiplayer_playtest end). If none is running, Studio is stuck in this state and stop/end cannot clear it: reopen the place (or restart Studio), then start the test again."
10134
+ };
10135
+ }
10136
+ return {
10137
+ error: "studio_start_failed",
10138
+ message: `Studio refused to start the ${subject}: ${studioError}`,
10139
+ studioError
10140
+ };
10141
+ }
10142
+
10125
10143
  // ../core/dist/tools/definitions.js
10126
10144
  var OPERATION_ID_PROPERTY = {
10127
10145
  type: "string",
@@ -21134,7 +21152,7 @@ var RobloxStudioTools = class {
21134
21152
  const clientCount = this._clientRolesForScope(instanceId).length;
21135
21153
  return { ok: false, roles, timedOut: true, extraClients: clientCount > expectedClientCount, clientCount };
21136
21154
  }
21137
- async _waitForRuntimeRolesFresh(instanceId, connectedAfter, requiredRoles, timeoutSec = 60) {
21155
+ async _waitForRuntimeRolesFresh(instanceId, connectedAfter, requiredRoles, timeoutSec = 60, soloStart) {
21138
21156
  const deadline = Date.now() + timeoutSec * 1e3;
21139
21157
  while (Date.now() < deadline) {
21140
21158
  const refresh = this.bridge.refreshTopologyForRouting();
@@ -21146,6 +21164,12 @@ var RobloxStudioTools = class {
21146
21164
  if (requiredRoles.every((role) => freshRoles.has(role))) {
21147
21165
  return { ok: true, roles, timedOut: false };
21148
21166
  }
21167
+ if (soloStart) {
21168
+ const studioError = await this._soloStartFailure(soloStart.editPeerId, soloStart.testId, deadline);
21169
+ if (studioError !== void 0) {
21170
+ return { ok: false, roles: this._rolesForScope(instanceId), timedOut: false, studioError };
21171
+ }
21172
+ }
21149
21173
  await sleep2(250);
21150
21174
  }
21151
21175
  return {
@@ -21154,6 +21178,21 @@ var RobloxStudioTools = class {
21154
21178
  timedOut: true
21155
21179
  };
21156
21180
  }
21181
+ // Studio's error when the edit plugin's Execute*Async call for this start failed.
21182
+ async _soloStartFailure(editPeerId, testId, deadline) {
21183
+ try {
21184
+ const remainingMs = Math.max(1, Math.min(1e3, deadline - Date.now()));
21185
+ const editState = await this._requestPeer("/api/multiplayer-test-state", {}, editPeerId, remainingMs);
21186
+ const solo = editState?.soloSession;
21187
+ if (solo === null || typeof solo !== "object" || !("testId" in solo) || !("phase" in solo))
21188
+ return void 0;
21189
+ if (solo.testId !== testId || solo.phase !== "failed")
21190
+ return void 0;
21191
+ return "error" in solo && typeof solo.error === "string" ? solo.error : "unknown error";
21192
+ } catch {
21193
+ return void 0;
21194
+ }
21195
+ }
21157
21196
  async getFileTree(path12 = "", instance_id) {
21158
21197
  const response = await this._callSingle("/api/file-tree", { path: path12 }, void 0, instance_id);
21159
21198
  return {
@@ -22889,9 +22928,17 @@ var RobloxStudioTools = class {
22889
22928
  let wait;
22890
22929
  if (response?.success === true) {
22891
22930
  const requiredRoles = mode === "play" ? ["server", "client-1"] : ["server"];
22892
- wait = await this._waitForRuntimeRolesFresh(resolved.targetInstanceId, startedAt, requiredRoles, timeout);
22931
+ const soloStart = typeof response.testId === "string" ? { editPeerId: resolved.targetPeerId, testId: response.testId } : void 0;
22932
+ wait = await this._waitForRuntimeRolesFresh(resolved.targetInstanceId, startedAt, requiredRoles, timeout, soloStart);
22893
22933
  }
22894
- const body = wait ? {
22934
+ const body = wait?.studioError !== void 0 ? {
22935
+ ...response,
22936
+ ...describePlaytestStartFailure(wait.studioError, "playtest"),
22937
+ success: false,
22938
+ runtimeReady: false,
22939
+ timedOut: false,
22940
+ roles: wait.roles
22941
+ } : wait ? {
22895
22942
  ...response,
22896
22943
  runtimeReady: wait.ok,
22897
22944
  timedOut: wait.timedOut,
@@ -23109,7 +23156,9 @@ var RobloxStudioTools = class {
23109
23156
  error: body2.error ?? wait.error ?? "multiplayer_start_not_detected",
23110
23157
  message: body2.success === true ? "Multiplayer playtest start was requested, but MCP did not detect the required server/client peers before timeout." : body2.message ?? "Multiplayer playtest did not start.",
23111
23158
  multiplayerGroupId: multiplayerGroupId2,
23112
- roles: Array.isArray(body2.roles) ? body2.roles : void 0
23159
+ roles: Array.isArray(body2.roles) ? body2.roles : void 0,
23160
+ studioError: typeof body2.studioError === "string" ? body2.studioError : void 0,
23161
+ recoveryHint: typeof body2.recoveryHint === "string" ? body2.recoveryHint : void 0
23113
23162
  });
23114
23163
  }
23115
23164
  if (action === "add_players") {
@@ -23205,6 +23254,7 @@ var RobloxStudioTools = class {
23205
23254
  const definitelyFailed = state.phase === "failed" && !runtimeStillConnected;
23206
23255
  if (definitelyFailed)
23207
23256
  await this.bridge.removeMultiplayerGroupEverywhere(groupId);
23257
+ const startFailure = !success && wait.phase === "failed" ? describePlaytestStartFailure(typeof wait.error === "string" ? wait.error : String(wait.error ?? "unknown error"), "multiplayer playtest") : void 0;
23208
23258
  return {
23209
23259
  content: [{
23210
23260
  type: "text",
@@ -23219,8 +23269,10 @@ var RobloxStudioTools = class {
23219
23269
  wait,
23220
23270
  roles: wait.roles,
23221
23271
  state,
23222
- error: success ? void 0 : wait.error ?? "multiplayer_start_not_detected",
23223
- message: success ? "Multiplayer Studio test started and runtime peers detected." : "Multiplayer Studio test start was requested, but MCP did not detect the required server/client peers before timeout.",
23272
+ error: success ? void 0 : startFailure?.error ?? wait.error ?? "multiplayer_start_not_detected",
23273
+ message: success ? "Multiplayer Studio test started and runtime peers detected." : startFailure?.message ?? "Multiplayer Studio test start was requested, but MCP did not detect the required server/client peers before timeout.",
23274
+ studioError: startFailure?.studioError,
23275
+ recoveryHint: startFailure?.recoveryHint,
23224
23276
  startedAt
23225
23277
  })
23226
23278
  }]
@@ -25933,13 +25985,14 @@ async function listenWithRetry(app, host, startPort, maxAttempts = 5) {
25933
25985
  return { server, port };
25934
25986
  } catch (error) {
25935
25987
  if (error !== null && typeof error === "object" && "code" in error && error.code === "EADDRINUSE") {
25936
- console.error(`Port ${port} in use, trying next...`);
25988
+ if (i + 1 < maxAttempts)
25989
+ console.error(`Port ${port} in use, trying next...`);
25937
25990
  continue;
25938
25991
  }
25939
25992
  throw error;
25940
25993
  }
25941
25994
  }
25942
- throw new Error(`All ports ${startPort}-${startPort + maxAttempts - 1} are in use. Stop some MCP server instances and retry.`);
25995
+ throw new Error(maxAttempts === 1 ? `Port ${startPort} is in use.` : `All ports ${startPort}-${startPort + maxAttempts - 1} are in use. Stop some MCP server instances and retry.`);
25943
25996
  }
25944
25997
  function bindPort(app, host, port) {
25945
25998
  const { promise, resolve: resolve7, reject } = Promise.withResolvers();
@@ -26045,6 +26098,10 @@ var ProxyBridgeService = class _ProxyBridgeService extends BridgeService {
26045
26098
  waitForInitialRefresh() {
26046
26099
  return this.initialRefresh;
26047
26100
  }
26101
+ /** The port owner's version from its latest topology; undefined before one arrives. */
26102
+ getPrimaryVersion() {
26103
+ return this.primaryVersion;
26104
+ }
26048
26105
  authHeaders(extra) {
26049
26106
  const headers = { ...extra };
26050
26107
  if (this.authToken)
@@ -26692,6 +26749,7 @@ var RobloxStudioMCPServer = class {
26692
26749
  boundPort = result.port;
26693
26750
  console.error(`HTTP server listening on ${host}:${boundPort} for Studio plugin (primary mode)`);
26694
26751
  console.error(`Streamable HTTP MCP endpoint: http://localhost:${boundPort}/mcp`);
26752
+ await this.installStudioPlugin();
26695
26753
  } catch (error) {
26696
26754
  await primaryApp?.cleanup().catch(() => {
26697
26755
  });
@@ -26706,8 +26764,13 @@ var RobloxStudioMCPServer = class {
26706
26764
  this.bridge = proxyBridge;
26707
26765
  this.tools = new RobloxStudioTools(this.bridge);
26708
26766
  console.error(`Port ${basePort} in use - entering proxy mode (forwarding to localhost:${basePort})`);
26767
+ const primaryVersion = proxyBridge.getPrimaryVersion();
26768
+ if (primaryVersion !== void 0 && primaryVersion !== this.config.version) {
26769
+ console.error(`Port ${basePort} is owned by MCP server v${primaryVersion}; this v${this.config.version} session forwards to it and leaves its Studio plugin installed. Close the older session to use v${this.config.version}; this session takes the port and installs its plugin once it is free.`);
26770
+ }
26709
26771
  const promotionIntervalMs = parseInt(process.env.ROBLOX_STUDIO_PROXY_PROMOTION_INTERVAL_MS || "5000");
26710
26772
  promotionInterval = setInterval(async () => {
26773
+ let promoted = false;
26711
26774
  const candidateBridge = new BridgeService();
26712
26775
  const candidateTools = new RobloxStudioTools(candidateBridge);
26713
26776
  const candidateApp = createHttpServer(candidateTools, candidateBridge, this.allowedToolNames, this.config, security);
@@ -26728,11 +26791,14 @@ var RobloxStudioMCPServer = class {
26728
26791
  console.error(`Promoted from proxy to primary on port ${boundPort}`);
26729
26792
  if (promotionInterval)
26730
26793
  clearInterval(promotionInterval);
26794
+ promoted = true;
26731
26795
  await oldTools.dispose();
26732
26796
  } catch {
26733
26797
  await candidateApp.cleanup().catch(() => {
26734
26798
  });
26735
26799
  }
26800
+ if (promoted)
26801
+ await this.installStudioPlugin();
26736
26802
  }, promotionIntervalMs);
26737
26803
  }
26738
26804
  const stdioHandle = serveStdio((context) => createToolServer({
@@ -26802,6 +26868,16 @@ var RobloxStudioMCPServer = class {
26802
26868
  process.stdin.on("end", shutdown);
26803
26869
  process.stdin.on("close", shutdown);
26804
26870
  }
26871
+ /** Never throws: a failed install must not cost this process the port it owns. */
26872
+ async installStudioPlugin() {
26873
+ if (!this.config.installStudioPlugin)
26874
+ return;
26875
+ try {
26876
+ await this.config.installStudioPlugin();
26877
+ } catch (err2) {
26878
+ console.error(`[install-plugin] Auto-install skipped: ${err2 instanceof Error ? err2.message : String(err2)}`);
26879
+ }
26880
+ }
26805
26881
  };
26806
26882
 
26807
26883
  // ../core/dist/install-plugin-helpers.js
@@ -27377,23 +27453,18 @@ if (installBundledOnly || installWithFallback) {
27377
27453
  process.exitCode = 1;
27378
27454
  });
27379
27455
  } else {
27380
- if (process.argv.includes("--auto-install-plugin")) {
27381
- await installBundledPlugin({
27382
- sourcePath: pluginPath,
27383
- log: (message) => console.error(`[install-plugin] ${message}`),
27384
- warn: (message) => console.error(message)
27385
- }).catch((err2) => {
27386
- console.error(
27387
- `[install-plugin] Auto-install skipped: ${err2 instanceof Error ? err2.message : String(err2)}`
27388
- );
27389
- });
27390
- }
27456
+ const autoInstallPlugin = process.argv.includes("--auto-install-plugin");
27391
27457
  const require2 = createRequire(import.meta.url);
27392
27458
  const { version: VERSION } = require2("../package.json");
27393
27459
  const server = new RobloxStudioMCPServer({
27394
27460
  name: "robloxstudio-mcp-inspector",
27395
27461
  version: VERSION,
27396
- tools: getReadOnlyTools()
27462
+ tools: getReadOnlyTools(),
27463
+ installStudioPlugin: autoInstallPlugin ? () => installBundledPlugin({
27464
+ sourcePath: pluginPath,
27465
+ log: (message) => console.error(`[install-plugin] ${message}`),
27466
+ warn: (message) => console.error(message)
27467
+ }) : void 0
27397
27468
  });
27398
27469
  server.run().catch((error) => {
27399
27470
  console.error("Server failed to start:", error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrrxs/robloxstudio-mcp-inspector",
3
- "version": "3.4.3",
3
+ "version": "3.4.4",
4
4
  "description": "DataModel read-only MCP server for inspecting and debugging Roblox Studio from AI coding tools",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -2560,9 +2560,9 @@ local function computeBridgeStamp()
2560
2560
  for i = 1, #combined do
2561
2561
  h = (h * 33 + (string.byte(combined, i))) % 2147483647
2562
2562
  end
2563
- -- "3.4.3" is replaced with the package version at package time
2563
+ -- "3.4.4" is replaced with the package version at package time
2564
2564
  -- (scripts/build-plugin.mjs injectVersion), so a release bump also restamps.
2565
- return `{tostring(h)}-3.4.3`
2565
+ return `{tostring(h)}-3.4.4`
2566
2566
  end
2567
2567
  local BRIDGE_STAMP = computeBridgeStamp()
2568
2568
  local function setSource(scriptInst, source)
@@ -9365,7 +9365,13 @@ local StopPlayMonitor = TS.import(script, script.Parent.Parent, "StopPlayMonitor
9365
9365
  local PluginSession = TS.import(script, script.Parent.Parent, "PluginSession")
9366
9366
  local PeerRole = TS.import(script, script.Parent.Parent, "PeerRole")
9367
9367
  local StudioTestService = game:GetService("StudioTestService")
9368
+ local TestService = game:GetService("TestService")
9368
9369
  local testRunning = false
9370
+ -- Outcome of the latest solo Execute*Async call. MCP polls it so a start Studio
9371
+ -- refuses is reported with Studio's own error instead of a readiness timeout.
9372
+ local soloState = {
9373
+ phase = "idle",
9374
+ }
9369
9375
  local multiplayerState = {
9370
9376
  phase = "idle",
9371
9377
  }
@@ -9406,6 +9412,30 @@ local function cloneMultiplayerState()
9406
9412
  error = multiplayerState.error,
9407
9413
  }
9408
9414
  end
9415
+ local function cloneSoloState()
9416
+ return {
9417
+ phase = soloState.phase,
9418
+ testId = soloState.testId,
9419
+ mode = soloState.mode,
9420
+ startedAt = soloState.startedAt,
9421
+ completedAt = soloState.completedAt,
9422
+ error = soloState.error,
9423
+ }
9424
+ end
9425
+ -- With ExecuteWithStudioRun and NumberOfPlayers > 0, Run opens a separate server
9426
+ -- and NumberOfPlayers client windows instead of a solo run session.
9427
+ local function runModeClientCount()
9428
+ local ok, settings = pcall(function()
9429
+ return {
9430
+ executeWithStudioRun = TestService.ExecuteWithStudioRun,
9431
+ numberOfPlayers = TestService.NumberOfPlayers,
9432
+ }
9433
+ end)
9434
+ if not ok or not settings.executeWithStudioRun or settings.numberOfPlayers <= 0 then
9435
+ return nil
9436
+ end
9437
+ return settings.numberOfPlayers
9438
+ end
9409
9439
  local function normalizeNumPlayers(value)
9410
9440
  local _value = value
9411
9441
  if not (type(_value) == "number") then
@@ -9430,6 +9460,17 @@ local function startPlaytest(requestData)
9430
9460
  error = "start_playtest is single-player only. Use multiplayer_test_start for multi-client StudioTestService sessions.",
9431
9461
  }
9432
9462
  end
9463
+ if mode == "run" then
9464
+ local clientCount = runModeClientCount()
9465
+ if clientCount ~= nil then
9466
+ return {
9467
+ success = false,
9468
+ error = "run_opens_multiplayer_session",
9469
+ message = `TestService.ExecuteWithStudioRun is true and TestService.NumberOfPlayers is {clientCount}, ` .. `so Run would open a separate server and {clientCount} client window(s) that solo_playtest cannot track or stop. ` .. "Ending that session by hand can leave Studio refusing new tests until the place is reopened. " .. 'For a multi-client test use multiplayer_playtest action="start"; for a solo Run set ' .. "TestService.NumberOfPlayers to 0 or TestService.ExecuteWithStudioRun to false.",
9470
+ numberOfPlayers = clientCount,
9471
+ }
9472
+ end
9473
+ end
9433
9474
  -- Peer teardown and ExecutePlayModeAsync completion can precede native edit
9434
9475
  -- readiness. Do not acknowledge a new start that the engine cannot execute.
9435
9476
  if not StudioTestService.EditModeActive then
@@ -9456,6 +9497,13 @@ local function startPlaytest(requestData)
9456
9497
  end
9457
9498
  testRunning = true
9458
9499
  local preparedTest = PluginSession.prepareSoloTest()
9500
+ local testId = HttpService:GenerateGUID(false)
9501
+ soloState = {
9502
+ phase = "running",
9503
+ testId = testId,
9504
+ mode = mode,
9505
+ startedAt = tick(),
9506
+ }
9459
9507
  task.spawn(function()
9460
9508
  local ok, result = pcall(function()
9461
9509
  if mode == "play" then
@@ -9467,11 +9515,17 @@ local function startPlaytest(requestData)
9467
9515
  if not ok then
9468
9516
  warn(`[robloxstudio-mcp] Playtest ended with error: {result}`)
9469
9517
  end
9518
+ if soloState.testId == testId then
9519
+ soloState.completedAt = tick()
9520
+ soloState.phase = if ok then "completed" else "failed"
9521
+ soloState.error = if ok then nil else tostring(result)
9522
+ end
9470
9523
  testRunning = false
9471
9524
  end)
9472
9525
  local response = {
9473
9526
  success = true,
9474
9527
  message = `Playtest started in {mode} mode.`,
9528
+ testId = testId,
9475
9529
  }
9476
9530
  return response
9477
9531
  end
@@ -9621,6 +9675,7 @@ local function multiplayerTestState(_requestData)
9621
9675
  }
9622
9676
  if peer == "edit" then
9623
9677
  response.session = cloneMultiplayerState()
9678
+ response.soloSession = cloneSoloState()
9624
9679
  return response
9625
9680
  end
9626
9681
  local argsOk, args = pcall(function()
@@ -13472,7 +13527,7 @@ return {
13472
13527
  <Properties>
13473
13528
  <string name="Name">State</string>
13474
13529
  <string name="Source"><![CDATA[-- Compiled with roblox-ts v3.0.0
13475
- local CURRENT_VERSION = "3.4.3"
13530
+ local CURRENT_VERSION = "3.4.4"
13476
13531
  local PLUGIN_VARIANT = "inspector"
13477
13532
  local BASE_PORT = 58741
13478
13533
  local SENSITIVE_DIAGNOSTIC_TERMS = { "token", "authorization", "bearer", "password", "cookie", "secret" }