fix: improve logging consistency between dev and prod client startup

Refactored startProdClient to match startDevClient's logging pattern,
ensuring consistent user feedback whether auto-open is enabled or disabled.

Also ensures that we log full information on how to open the browser
regardless of whether MCP_AUTO_OPEN_ENABLED=false.
This commit is contained in:
Felix Weinberger 2025-06-27 13:08:29 +01:00
commit ae1aeb3c3f
No known key found for this signature in database

View file

@ -133,8 +133,6 @@ async function startDevClient(clientOptions) {
echoOutput: true, echoOutput: true,
}); });
// Auto-open browser after vite starts
if (process.env.MCP_AUTO_OPEN_ENABLED !== "false") {
const url = getClientUrl( const url = getClientUrl(
CLIENT_PORT, CLIENT_PORT,
authDisabled, authDisabled,
@ -142,12 +140,14 @@ async function startDevClient(clientOptions) {
SERVER_PORT, SERVER_PORT,
); );
// Give vite time to start before opening browser // Give vite time to start before opening or logging the URL
setTimeout(() => { setTimeout(() => {
console.log(`\n🚀 MCP Inspector is up and running at:\n ${url}\n`);
if (process.env.MCP_AUTO_OPEN_ENABLED !== "false") {
console.log("🌐 Opening browser...");
open(url); open(url);
console.log(`\n🔗 Opening browser at: ${url}\n`);
}, 3000);
} }
}, 3000);
await new Promise((resolve) => { await new Promise((resolve) => {
client.subscribe({ client.subscribe({
@ -180,16 +180,21 @@ async function startProdClient(clientOptions) {
"client.js", "client.js",
); );
// Only auto-open browser if not cancelled
if (process.env.MCP_AUTO_OPEN_ENABLED !== "false" && !cancelled) {
const url = getClientUrl( const url = getClientUrl(
CLIENT_PORT, CLIENT_PORT,
authDisabled, authDisabled,
sessionToken, sessionToken,
SERVER_PORT, SERVER_PORT,
); );
// Handle auto-open and logging
if (!cancelled) {
console.log(`\n🚀 MCP Inspector is up and running at:\n ${url}\n`);
if (process.env.MCP_AUTO_OPEN_ENABLED !== "false") {
console.log(`\n🌐 Opening browser...:\n`);
open(url); open(url);
} }
}
await spawnPromise("node", [inspectorClientPath], { await spawnPromise("node", [inspectorClientPath], {
env: { ...process.env, CLIENT_PORT: CLIENT_PORT }, env: { ...process.env, CLIENT_PORT: CLIENT_PORT },