Skip to content

Commit a3d542c

Browse files
committed
make server port configurable via URL query param
1 parent 2b79b6f commit a3d542c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

bin/cli.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ async function main() {
6161

6262
// Make sure our server/client didn't immediately fail
6363
await Promise.any([server, client, delay(2 * 1000)]);
64+
const portParam = SERVER_PORT === "3000" ? "" : `?port=${SERVER_PORT}`;
6465
console.log(
65-
`\n🔍 MCP Inspector is up and running at http://localhost:${CLIENT_PORT} 🚀`,
66+
`\n🔍 MCP Inspector is up and running at http://localhost:${CLIENT_PORT}${portParam} 🚀`,
6667
);
6768

6869
try {

client/src/App.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,10 @@ const App = () => {
191191
}, [args]);
192192

193193
useEffect(() => {
194-
fetch("http://localhost:3000/config")
194+
const params = new URLSearchParams(window.location.search);
195+
const serverPort = params.get('port') || '3000';
196+
197+
fetch(`http://localhost:${serverPort}/config`)
195198
.then((response) => response.json())
196199
.then((data) => {
197200
setEnv(data.defaultEnvironment);
@@ -404,7 +407,9 @@ const App = () => {
404407
},
405408
);
406409

407-
const backendUrl = new URL("http://localhost:3000/sse");
410+
const params = new URLSearchParams(window.location.search);
411+
const serverPort = params.get('port') || '3000';
412+
const backendUrl = new URL(`http://localhost:${serverPort}/sse`);
408413

409414
backendUrl.searchParams.append("transportType", transportType);
410415
if (transportType === "stdio") {

0 commit comments

Comments
 (0)