Skip to content

Commit 9dbd173

Browse files
feat: disable auto-open when authentication is enabled
- Auto-open browser only works when DANGEROUSLY_OMIT_AUTH=true - When auth is enabled (default), users must use the secure URL with token - Server displays clear message that auto-open is disabled with auth - Updates documentation to reflect this behavior This improves UX by preventing the browser from opening without auth token, forcing users to use the secure pre-filled URL instead.
1 parent 15ecb59 commit 9dbd173

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ The MCP Inspector proxy server requires authentication by default. When starting
148148
http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=3a1c267fad21f7150b7d624c160b7f09b0b8c4f623c7107bbf13378f051538d4
149149
```
150150

151-
This token must be included as a Bearer token in the Authorization header for all requests to the server.
151+
This token must be included as a Bearer token in the Authorization header for all requests to the server. When authentication is enabled, auto-open is disabled by default to ensure you use the secure URL.
152152

153-
**Option 1: Use the pre-filled URL** - Click the link shown in the console to open the inspector with the token already configured.
153+
**Recommended: Use the pre-filled URL** - Click or copy the link shown in the console to open the inspector with the token already configured.
154154

155-
**Option 2: Manual configuration** - If you already have the inspector open:
155+
**Alternative: Manual configuration** - If you already have the inspector open:
156156

157157
1. Click the "Configuration" button in the sidebar
158158
2. Find "Proxy Session Token" and enter the token displayed in the proxy console

client/bin/start.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ async function main() {
100100

101101
if (serverOk) {
102102
try {
103-
if (process.env.MCP_AUTO_OPEN_ENABLED !== "false") {
103+
// Only auto-open when auth is disabled
104+
const authDisabled = !!process.env.DANGEROUSLY_OMIT_AUTH;
105+
if (process.env.MCP_AUTO_OPEN_ENABLED !== "false" && authDisabled) {
104106
open(`http://127.0.0.1:${CLIENT_PORT}`);
105107
}
106108
await spawnPromise("node", [inspectorClientPath], {

server/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ server.on("listening", () => {
470470
// Display clickable URL with pre-filled token
471471
const clientPort = process.env.CLIENT_PORT || '6274';
472472
const clientUrl = `http://localhost:${clientPort}/?MCP_PROXY_AUTH_TOKEN=${sessionToken}`;
473-
console.log(`\n🔗 Open inspector with token pre-filled:\n ${clientUrl}`);
473+
console.log(`\n🔗 Open inspector with token pre-filled:\n ${clientUrl}\n (Auto-open is disabled when authentication is enabled)\n`);
474474
} else {
475475
console.log(`⚠️ WARNING: Authentication is disabled. This is not recommended.`);
476476
}

0 commit comments

Comments
 (0)