make server port configurable via URL query param
This commit is contained in:
@@ -61,8 +61,9 @@ async function main() {
|
|||||||
|
|
||||||
// Make sure our server/client didn't immediately fail
|
// Make sure our server/client didn't immediately fail
|
||||||
await Promise.any([server, client, delay(2 * 1000)]);
|
await Promise.any([server, client, delay(2 * 1000)]);
|
||||||
|
const portParam = SERVER_PORT === "3000" ? "" : `?port=${SERVER_PORT}`;
|
||||||
console.log(
|
console.log(
|
||||||
`\n🔍 MCP Inspector is up and running at http://localhost:${CLIENT_PORT} 🚀`,
|
`\n🔍 MCP Inspector is up and running at http://localhost:${CLIENT_PORT}${portParam} 🚀`,
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -191,7 +191,10 @@ const App = () => {
|
|||||||
}, [args]);
|
}, [args]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch("http://localhost:3000/config")
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const serverPort = params.get('port') || '3000';
|
||||||
|
|
||||||
|
fetch(`http://localhost:${serverPort}/config`)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
setEnv(data.defaultEnvironment);
|
setEnv(data.defaultEnvironment);
|
||||||
@@ -404,7 +407,9 @@ const App = () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const backendUrl = new URL("http://localhost:3000/sse");
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const serverPort = params.get('port') || '3000';
|
||||||
|
const backendUrl = new URL(`http://localhost:${serverPort}/sse`);
|
||||||
|
|
||||||
backendUrl.searchParams.append("transportType", transportType);
|
backendUrl.searchParams.append("transportType", transportType);
|
||||||
if (transportType === "stdio") {
|
if (transportType === "stdio") {
|
||||||
|
|||||||
Reference in New Issue
Block a user