Commit graph inspector/client/bin/client.js
Author SHA1 Message Date
Felix Weinberger
042e7a2aa7
refactor: move browser auto-open logic to client process
Simplifies the startup flow by consolidating browser opening
in the client script rather than the start script for prod.

We were duplicating a lot of logging, making it easy for
logs to go out of sync - this is a proposal to consolidate:

- server only logs info about itself
- client only logs info about itself

To reduce the number of places we print connection information
to the user.
2025-06-27 15:01:34 +01:00
Felix Weinberger
d0673ba9e1
refactor: Use specific SERVER_PORT and CLIENT_PORT env vars
Per PR feedback from cliffhall:
- Changed PORT to SERVER_PORT in server/src/index.ts
- Changed PORT to CLIENT_PORT in client/bin/client.js
- Added parseInt() for CLIENT_PORT consistency
- Updated start.js to pass correct env var names

This improves clarity by using specific environment variables for
server and client ports instead of the generic PORT variable.
2025-06-24 10:43:13 +01:00
Felix Weinberger
fe2c5c767d
refactor: deduplicate URL generation and standardize on localhost
- Extract duplicated URL generation code into getClientUrl() helper function in start.js
- Replace all 127.0.0.1 references with localhost for consistency across codebase
- Update server to respect HOST environment variable for URL generation
- Remove 127.0.0.1 from default allowed origins in CORS configuration
- Update documentation to use localhost instead of 127.0.0.1

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-24 10:43:13 +01:00
Felix Weinberger
9c5c7575c0
fix: Bind client to localhost by default to prevent DNS rebinding attacks
Complete the security hardening started in e8e9909 by also binding the client to localhost only.
Previously only the server was protected while the client remained exposed to the network,
allowing attackers to access the server through the client as a proxy.

Changes:
- Add HOST environment variable support to client (prod mode)
- Configure Vite dev server to bind to localhost by default
- Update browser auto-open URLs to use actual host instead of hardcoded 127.0.0.1
- Fix missing cancelled parameter in startProdClient function

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-24 10:43:13 +01:00
cliffhall
59cc89dbe9 Fix the inspector caching problem
* I've noticed that on a new version of the inspector, I have to go to the browser's devtools panel and clear site data then reload the page.
* The assets are hashed and immutable, so caching should be allowed for them
* The index.html file is the problem, because if cached, it will point to old assets, and therefore needs to have caching turned forf
* This PR adds appropriate headers to the index.html and assets that are served.
2025-04-30 17:31:58 -04:00
cliffhall
6a99feaf33 Refactor project components
* Remove bin folder, leaving cli, server, and client
* This fixes #315
* In .gitignore,
  - add .idea
  - remove bin/build
* Remove bin and bin/cli.js
* Remove bin/scripts/copy-cli.js
* Refactor/move bin/scripts to cli/scripts
* Refactor/move bin/src/index.ts to cli/src/cli.ts
* Refactor/renamed client/bin/cli.js to client/bin/client.js
* In .github/workflows/main.yml,
  - add run of cli tests
* In cli/pacakge.json
  - change main and bin/mcp-inspector-cli properties to build/cli.js
* In client/package.json,
  - change bin/mcp-inspector-client properties to build/start.js
* In pacakge.json
  - change bin/mcp-inspector property to ./cli/build/cli.js
  - removed bin and cli/bin from files list
  - removed @modelcontextprotocol/inspector-bin dependency
  - rearranged and corrected scripts
2025-04-15 17:59:26 -04:00
Renamed from client/bin/cli.js (Previous history)