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.
This commit is contained in:
Felix Weinberger 2025-06-27 14:46:40 +01:00
commit 042e7a2aa7
No known key found for this signature in database

View file

@ -539,27 +539,9 @@ const server = app.listen(PORT, HOST);
server.on("listening", () => {
console.log(`⚙️ Proxy server listening on ${HOST}:${PORT}`);
if (!authDisabled) {
console.log(`🔑 Session token: ${sessionToken}`);
console.log(
`Use this token to authenticate requests or set DANGEROUSLY_OMIT_AUTH=true to disable auth`,
);
// Display clickable URL with pre-filled token
const clientPort = process.env.CLIENT_PORT || "6274";
const clientHost = process.env.HOST || "localhost";
// Build URL with query parameters
const params = new URLSearchParams();
params.set("MCP_PROXY_AUTH_TOKEN", sessionToken);
// Add server port if it's not the default
if (PORT !== parseInt(DEFAULT_MCP_PROXY_LISTEN_PORT, 10)) {
params.set("MCP_PROXY_PORT", PORT.toString());
}
const clientUrl = `http://${clientHost}:${clientPort}/?${params.toString()}`;
console.log(
`\n🔗 Open inspector with token pre-filled:\n ${clientUrl}\n`,
`🔑 Session token: ${sessionToken}\n ` +
`Use this token to authenticate requests or set DANGEROUSLY_OMIT_AUTH=true to disable auth`,
);
} else {
console.log(