Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions client/bin/client.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node

import open from "open";
import { join, dirname } from "path";
import { fileURLToPath } from "url";
import handler from "serve-handler";
Expand Down Expand Up @@ -42,9 +43,12 @@ const server = http.createServer((request, response) => {
const port = parseInt(process.env.CLIENT_PORT || "6274", 10);
const host = process.env.HOST || "localhost";
server.on("listening", () => {
console.log(
`🔍 MCP Inspector is up and running at http://${host}:${port} 🚀`,
);
const url = process.env.INSPECTOR_URL || `http://${host}:${port}`;
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);
}
});
server.on("error", (err) => {
if (err.message.includes(`EADDRINUSE`)) {
Expand Down
48 changes: 24 additions & 24 deletions client/bin/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,21 @@ async function startDevClient(clientOptions) {
echoOutput: true,
});

// Auto-open browser after vite starts
if (process.env.MCP_AUTO_OPEN_ENABLED !== "false") {
const url = getClientUrl(
CLIENT_PORT,
authDisabled,
sessionToken,
SERVER_PORT,
);
const url = getClientUrl(
CLIENT_PORT,
authDisabled,
sessionToken,
SERVER_PORT,
);

// Give vite time to start before opening browser
setTimeout(() => {
// Give vite time to start before opening or logging the URL
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);
console.log(`\n🔗 Opening browser at: ${url}\n`);
}, 3000);
}
}
}, 3000);

await new Promise((resolve) => {
client.subscribe({
Expand Down Expand Up @@ -180,19 +180,19 @@ async function startProdClient(clientOptions) {
"client.js",
);

// Only auto-open browser if not cancelled
if (process.env.MCP_AUTO_OPEN_ENABLED !== "false" && !cancelled) {
const url = getClientUrl(
CLIENT_PORT,
authDisabled,
sessionToken,
SERVER_PORT,
);
open(url);
}
const url = getClientUrl(
CLIENT_PORT,
authDisabled,
sessionToken,
SERVER_PORT,
);

await spawnPromise("node", [inspectorClientPath], {
env: { ...process.env, CLIENT_PORT: CLIENT_PORT },
env: {
...process.env,
CLIENT_PORT: CLIENT_PORT,
INSPECTOR_URL: url,
},
signal: abort.signal,
echoOutput: true,
});
Expand Down
22 changes: 2 additions & 20 deletions server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down