inspector icon indicating copy to clipboard operation
inspector copied to clipboard

[BUG] Electron server port is hardcoded and not configurable via environment variable

Open Skylertodd opened this issue 9 months ago • 3 comments

Issue

When running https://docs.mcpjam.com/installation#start-with-custom-port npx @mcpjam/inspector@latest --port 4000 The port used by the MCPJam Inspector's internal server is hardcoded to 6274 when running in Electron (see src/main.ts). This prevents users from configuring or overriding the port via an environment variable or command line flag, which is inconsistent with the server behavior outside Electron.

How to reproduce

  1. Run the MCPJam Inspector Electron app locally (development or packaged build).
  2. Observe that the server always starts on port 6274, regardless of SERVER_PORT or similar environment variables.
  3. Attempting to change the port via env or CLI does not affect Electron's embedded server.

Expected Behavior

Users should be able to configure the MCPJam Inspector server port via an environment variable (e.g., SERVER_PORT or ELECTRON_PORT) when running in Electron, consistent with non-Electron usage.

Platform

  • Electron app (all OSes)

Additional Context

This affects running multiple MCPJam servers, port conflicts with other local software, and developer flexibility. Ideally, MCPJam should allow the port to be set with an env variable inside Electron, rather than hardcoding it in the entrypoint. See also the workaround of patching src/main.ts or reverse proxying, but these are not user-friendly.

Skylertodd avatar Feb 12 '26 16:02 Skylertodd

Hi @Skylertodd! I'm Dosu and I’m helping the inspector team.

You're right—the Electron app's server port is hardcoded to 6274 in src/main.ts and doesn't check environment variables or CLI flags, so you can't override it like you can in non-Electron modes. In contrast, the standalone server uses a pattern where the port is settable via the SERVER_PORT environment variable or the --port CLI flag, with the value read from process.env.SERVER_PORT and defaulting to 6274 if not set (source).

To make the Electron port configurable, you can update the startHonoServer function in src/main.ts to read the port from process.env.SERVER_PORT (or a similar env var), falling back to 6274 if not set. For example:

const port = process.env.SERVER_PORT ? parseInt(process.env.SERVER_PORT, 10) : 6274;

This change would bring Electron mode in line with the rest of the system and let you avoid port conflicts or run multiple instances as needed. There are no merged PRs or docs that address this yet, but this pattern matches how the rest of the app handles port configuration (source, source).

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about inspector with Dosu Add Dosu to your team

dosubot[bot] avatar Feb 12 '26 16:02 dosubot[bot]

Implemented this in PR https://github.com/MCPJam/inspector/pull/1460.

What changed:

  • now reads port from -> -> instead of hardcoding 6274.
  • Added host-aware port availability checks and fallback scan (+100) when no explicit port is provided.
  • Preserves explicit-port behavior: if an explicit port is set and unavailable, startup fails fast.

███╗ ███╗ ██████╗██████╗ ██╗ █████╗ ███╗ ███╗ ████╗ ████║██╔════╝██╔══██╗ ██║██╔══██╗████╗ ████║ ██╔████╔██║██║ ██████╔╝ ██║███████║██╔████╔██║ ██║╚██╔╝██║██║ ██╔═══╝██ ██║██╔══██║██║╚██╔╝██║ ██║ ╚═╝ ██║╚██████╗██║ ╚█████╔╝██║ ██║██║ ╚═╝ ██║ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚════╝ ╚═╝ ╚═╝╚═╝ ╚═╝

❌ Production build not found at /Users/ramarivera/dev/inspector--ramarivera/mcpjam-inspector/dist/server/index.js. Build artifacts are required to start. ℹ️ Run this command with --rebuild or build in CI/CD before starting. now follows similar logic for CLI startup (/), including auto-selecting next available port when no explicit value is set.

Quick verify:

  • Existing local blockers remain for this repo: tests/build currently fail on unresolved entrypoint () unrelated to this change.

🤖 This content was generated with AI assistance using GPT-5.

ramarivera avatar Feb 14 '26 01:02 ramarivera

Implemented in PR https://github.com/MCPJam/inspector/pull/1460.

What changed:

  • src/main.ts now reads port from ELECTRON_PORT -> SERVER_PORT -> PORT instead of hardcoding 6274.
  • Added host-aware port availability checks and a fallback scan (up to +100) when no explicit port is provided.
  • Preserves explicit-port behavior: if an explicit port is set and unavailable, startup fails fast with guidance.
  • bin/start.js now follows the same pattern for CLI startup (--port/SERVER_PORT), including next-free-port fallback when no explicit value is set.

Self-verification performed:

  • node --check bin/start.js
  • node --check src/main.ts
  • Existing local blockers remain: tests/build currently fail on unresolved @mcpjam/sdk entrypoint (sdk/dist/index.mjs), unrelated to this change.

🤖 This content was generated with AI assistance using GPT-5.

ramarivera avatar Feb 14 '26 01:02 ramarivera