Skip to content

Commit 7ff70e1

Browse files
authored
Merge branch 'main' into fveiras/copy_json
2 parents 9842a62 + 4ab7794 commit 7ff70e1

23 files changed

+897
-159
lines changed

.github/workflows/e2e_tests.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ jobs:
2121
- uses: actions/checkout@v4
2222

2323
- uses: actions/setup-node@v4
24+
id: setup_node
2425
with:
25-
node-version: 18
26+
node-version-file: package.json
27+
cache: npm
2628

2729
# Cache Playwright browsers
2830
- name: Cache Playwright browsers
@@ -69,7 +71,7 @@ jobs:
6971
job-summary: true
7072
icon-style: "emojis"
7173
custom-info: |
72-
**Test Environment:** Ubuntu Latest, Node.js 18
74+
**Test Environment:** Ubuntu Latest, Node.js ${{ steps.setup_node.outputs.node-version }}
7375
**Browsers:** Chromium, Firefox
7476
7577
📊 [View Detailed HTML Report](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) (download artifacts)

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- uses: actions/setup-node@v4
2121
with:
22-
node-version: 18
22+
node-version-file: package.json
2323
cache: npm
2424

2525
# Working around https://github.com/npm/cli/issues/4828
@@ -53,7 +53,7 @@ jobs:
5353
- uses: actions/checkout@v4
5454
- uses: actions/setup-node@v4
5555
with:
56-
node-version: 18
56+
node-version-file: package.json
5757
cache: npm
5858
registry-url: "https://registry.npmjs.org"
5959

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22.x.x

client/bin/client.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22

3+
import open from "open";
34
import { join, dirname } from "path";
45
import { fileURLToPath } from "url";
56
import handler from "serve-handler";
@@ -42,9 +43,12 @@ const server = http.createServer((request, response) => {
4243
const port = parseInt(process.env.CLIENT_PORT || "6274", 10);
4344
const host = process.env.HOST || "localhost";
4445
server.on("listening", () => {
45-
console.log(
46-
`🔍 MCP Inspector is up and running at http://${host}:${port} 🚀`,
47-
);
46+
const url = process.env.INSPECTOR_URL || `http://${host}:${port}`;
47+
console.log(`\n🚀 MCP Inspector is up and running at:\n ${url}\n`);
48+
if (process.env.MCP_AUTO_OPEN_ENABLED !== "false") {
49+
console.log(`🌐 Opening browser...`);
50+
open(url);
51+
}
4852
});
4953
server.on("error", (err) => {
5054
if (err.message.includes(`EADDRINUSE`)) {

client/bin/start.js

Lines changed: 58 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@ import { fileURLToPath } from "url";
77
import { randomBytes } from "crypto";
88

99
const __dirname = dirname(fileURLToPath(import.meta.url));
10+
const DEFAULT_MCP_PROXY_LISTEN_PORT = "6277";
1011

1112
function delay(ms) {
1213
return new Promise((resolve) => setTimeout(resolve, ms, true));
1314
}
1415

15-
function getClientUrl(port, authDisabled, sessionToken) {
16+
function getClientUrl(port, authDisabled, sessionToken, serverPort) {
1617
const host = process.env.HOST || "localhost";
1718
const baseUrl = `http://${host}:${port}`;
18-
return authDisabled
19-
? baseUrl
20-
: `${baseUrl}/?MCP_PROXY_AUTH_TOKEN=${sessionToken}`;
19+
20+
const params = new URLSearchParams();
21+
if (serverPort && serverPort !== DEFAULT_MCP_PROXY_LISTEN_PORT) {
22+
params.set("MCP_PROXY_PORT", serverPort);
23+
}
24+
if (!authDisabled) {
25+
params.set("MCP_PROXY_AUTH_TOKEN", sessionToken);
26+
}
27+
return params.size > 0 ? `${baseUrl}/?${params.toString()}` : baseUrl;
2128
}
2229

2330
async function startDevServer(serverOptions) {
@@ -31,8 +38,8 @@ async function startDevServer(serverOptions) {
3138
cwd: resolve(__dirname, "../..", "server"),
3239
env: {
3340
...process.env,
34-
SERVER_PORT: SERVER_PORT,
35-
CLIENT_PORT: CLIENT_PORT,
41+
SERVER_PORT,
42+
CLIENT_PORT,
3643
MCP_PROXY_TOKEN: sessionToken,
3744
MCP_ENV_VARS: JSON.stringify(envVars),
3845
},
@@ -90,8 +97,8 @@ async function startProdServer(serverOptions) {
9097
{
9198
env: {
9299
...process.env,
93-
SERVER_PORT: SERVER_PORT,
94-
CLIENT_PORT: CLIENT_PORT,
100+
SERVER_PORT,
101+
CLIENT_PORT,
95102
MCP_PROXY_TOKEN: sessionToken,
96103
MCP_ENV_VARS: JSON.stringify(envVars),
97104
},
@@ -107,29 +114,40 @@ async function startProdServer(serverOptions) {
107114
}
108115

109116
async function startDevClient(clientOptions) {
110-
const { CLIENT_PORT, authDisabled, sessionToken, abort, cancelled } =
111-
clientOptions;
117+
const {
118+
CLIENT_PORT,
119+
SERVER_PORT,
120+
authDisabled,
121+
sessionToken,
122+
abort,
123+
cancelled,
124+
} = clientOptions;
112125
const clientCommand = "npx";
113126
const host = process.env.HOST || "localhost";
114127
const clientArgs = ["vite", "--port", CLIENT_PORT, "--host", host];
115128

116129
const client = spawn(clientCommand, clientArgs, {
117130
cwd: resolve(__dirname, ".."),
118-
env: { ...process.env, CLIENT_PORT: CLIENT_PORT },
131+
env: { ...process.env, CLIENT_PORT },
119132
signal: abort.signal,
120133
echoOutput: true,
121134
});
122135

123-
// Auto-open browser after vite starts
124-
if (process.env.MCP_AUTO_OPEN_ENABLED !== "false") {
125-
const url = getClientUrl(CLIENT_PORT, authDisabled, sessionToken);
136+
const url = getClientUrl(
137+
CLIENT_PORT,
138+
authDisabled,
139+
sessionToken,
140+
SERVER_PORT,
141+
);
126142

127-
// Give vite time to start before opening browser
128-
setTimeout(() => {
143+
// Give vite time to start before opening or logging the URL
144+
setTimeout(() => {
145+
console.log(`\n🚀 MCP Inspector is up and running at:\n ${url}\n`);
146+
if (process.env.MCP_AUTO_OPEN_ENABLED !== "false") {
147+
console.log("🌐 Opening browser...");
129148
open(url);
130-
console.log(`\n🔗 Opening browser at: ${url}\n`);
131-
}, 3000);
132-
}
149+
}
150+
}, 3000);
133151

134152
await new Promise((resolve) => {
135153
client.subscribe({
@@ -146,8 +164,14 @@ async function startDevClient(clientOptions) {
146164
}
147165

148166
async function startProdClient(clientOptions) {
149-
const { CLIENT_PORT, authDisabled, sessionToken, abort, cancelled } =
150-
clientOptions;
167+
const {
168+
CLIENT_PORT,
169+
SERVER_PORT,
170+
authDisabled,
171+
sessionToken,
172+
abort,
173+
cancelled,
174+
} = clientOptions;
151175
const inspectorClientPath = resolve(
152176
__dirname,
153177
"../..",
@@ -156,14 +180,19 @@ async function startProdClient(clientOptions) {
156180
"client.js",
157181
);
158182

159-
// Only auto-open browser if not cancelled
160-
if (process.env.MCP_AUTO_OPEN_ENABLED !== "false" && !cancelled) {
161-
const url = getClientUrl(CLIENT_PORT, authDisabled, sessionToken);
162-
open(url);
163-
}
183+
const url = getClientUrl(
184+
CLIENT_PORT,
185+
authDisabled,
186+
sessionToken,
187+
SERVER_PORT,
188+
);
164189

165190
await spawnPromise("node", [inspectorClientPath], {
166-
env: { ...process.env, CLIENT_PORT: CLIENT_PORT },
191+
env: {
192+
...process.env,
193+
CLIENT_PORT,
194+
INSPECTOR_URL: url,
195+
},
167196
signal: abort.signal,
168197
echoOutput: true,
169198
});
@@ -210,7 +239,7 @@ async function main() {
210239
}
211240

212241
const CLIENT_PORT = process.env.CLIENT_PORT ?? "6274";
213-
const SERVER_PORT = process.env.SERVER_PORT ?? "6277";
242+
const SERVER_PORT = process.env.SERVER_PORT ?? DEFAULT_MCP_PROXY_LISTEN_PORT;
214243

215244
console.log(
216245
isDev
@@ -255,6 +284,7 @@ async function main() {
255284
try {
256285
const clientOptions = {
257286
CLIENT_PORT,
287+
SERVER_PORT,
258288
authDisabled,
259289
sessionToken,
260290
abort,

client/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<title>MCP Inspector</title>
88
</head>
99
<body>
10-
<div id="root"></div>
10+
<div id="root" class="w-full"></div>
1111
<script type="module" src="/src/main.tsx"></script>
1212
</body>
1313
</html>

client/src/App.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
#root {
2-
margin: 0 auto;
3-
}
4-
51
.logo {
62
height: 6em;
73
padding: 1.5em;

client/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import { z } from "zod";
5252
import "./App.css";
5353
import AuthDebugger from "./components/AuthDebugger";
5454
import ConsoleTab from "./components/ConsoleTab";
55-
import HistoryAndNotifications from "./components/History";
55+
import HistoryAndNotifications from "./components/HistoryAndNotifications";
5656
import PingTab from "./components/PingTab";
5757
import PromptsTab, { Prompt } from "./components/PromptsTab";
5858
import ResourcesTab from "./components/ResourcesTab";

0 commit comments

Comments
 (0)