Skip to content

Commit 2a9230d

Browse files
authored
Merge branch 'main' into fix-integer
2 parents 2ee0a53 + fa7f9c8 commit 2a9230d

File tree

9 files changed

+87
-62
lines changed

9 files changed

+87
-62
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Thanks for your interest in contributing! This guide explains how to get involve
77
1. Fork the repository and clone it locally
88
2. Install dependencies with `npm install`
99
3. Run `npm run dev` to start both client and server in development mode
10-
4. Use the web UI at http://127.0.0.1:5173 to interact with the inspector
10+
4. Use the web UI at http://127.0.0.1:6274 to interact with the inspector
1111

1212
## Development Process & Pull Requests
1313

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ npx @modelcontextprotocol/inspector -e KEY=value -e KEY2=$VALUE2 node build/inde
3030
npx @modelcontextprotocol/inspector -e KEY=$VALUE -- node build/index.js -e server-flag
3131
```
3232

33-
The inspector runs both a client UI (default port 5173) and an MCP proxy server (default port 3000). Open the client UI in your browser to use the inspector. You can customize the ports if needed:
33+
The inspector runs both an MCP Inspector (MCPI) client UI (default port 6274) and an MCP Proxy (MCPP) server (default port 6277). Open the MCPI client UI in your browser to use the inspector. (These ports are derived from the T9 dialpad mapping of MCPI and MCPP respectively, as a mnemonic). You can customize the ports if needed:
3434

3535
```bash
3636
CLIENT_PORT=8080 SERVER_PORT=9000 npx @modelcontextprotocol/inspector node build/index.js

bin/cli.js

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { fileURLToPath } from "url";
77
const __dirname = dirname(fileURLToPath(import.meta.url));
88

99
function delay(ms) {
10-
return new Promise((resolve) => setTimeout(resolve, ms));
10+
return new Promise((resolve) => setTimeout(resolve, ms, true));
1111
}
1212

1313
async function main() {
@@ -61,8 +61,8 @@ async function main() {
6161
"cli.js",
6262
);
6363

64-
const CLIENT_PORT = process.env.CLIENT_PORT ?? "5173";
65-
const SERVER_PORT = process.env.SERVER_PORT ?? "3000";
64+
const CLIENT_PORT = process.env.CLIENT_PORT ?? "6274";
65+
const SERVER_PORT = process.env.SERVER_PORT ?? "6277";
6666

6767
console.log("Starting MCP inspector...");
6868

@@ -73,42 +73,40 @@ async function main() {
7373
cancelled = true;
7474
abort.abort();
7575
});
76-
77-
const server = spawnPromise(
78-
"node",
79-
[
80-
inspectorServerPath,
81-
...(command ? [`--env`, command] : []),
82-
...(mcpServerArgs ? [`--args=${mcpServerArgs.join(" ")}`] : []),
83-
],
84-
{
85-
env: {
86-
...process.env,
87-
PORT: SERVER_PORT,
88-
MCP_ENV_VARS: JSON.stringify(envVars),
89-
},
90-
signal: abort.signal,
91-
echoOutput: true,
92-
},
93-
);
94-
95-
const client = spawnPromise("node", [inspectorClientPath], {
96-
env: { ...process.env, PORT: CLIENT_PORT },
97-
signal: abort.signal,
98-
echoOutput: true,
99-
});
100-
101-
// Make sure our server/client didn't immediately fail
102-
await Promise.any([server, client, delay(2 * 1000)]);
103-
const portParam = SERVER_PORT === "3000" ? "" : `?proxyPort=${SERVER_PORT}`;
104-
console.log(
105-
`\n🔍 MCP Inspector is up and running at http://127.0.0.1:${CLIENT_PORT}${portParam} 🚀`,
106-
);
107-
76+
let server, serverOk;
10877
try {
109-
await Promise.any([server, client]);
110-
} catch (e) {
111-
if (!cancelled || process.env.DEBUG) throw e;
78+
server = spawnPromise(
79+
"node",
80+
[
81+
inspectorServerPath,
82+
...(command ? [`--env`, command] : []),
83+
...(mcpServerArgs ? [`--args=${mcpServerArgs.join(" ")}`] : []),
84+
],
85+
{
86+
env: {
87+
...process.env,
88+
PORT: SERVER_PORT,
89+
MCP_ENV_VARS: JSON.stringify(envVars),
90+
},
91+
signal: abort.signal,
92+
echoOutput: true,
93+
},
94+
);
95+
96+
// Make sure server started before starting client
97+
serverOk = await Promise.race([server, delay(2 * 1000)]);
98+
} catch (error) {}
99+
100+
if (serverOk) {
101+
try {
102+
await spawnPromise("node", [inspectorClientPath], {
103+
env: { ...process.env, PORT: CLIENT_PORT },
104+
signal: abort.signal,
105+
echoOutput: true,
106+
});
107+
} catch (e) {
108+
if (!cancelled || process.env.DEBUG) throw e;
109+
}
112110
}
113111

114112
return 0;

client/bin/cli.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,19 @@ const server = http.createServer((request, response) => {
1515
});
1616
});
1717

18-
const port = process.env.PORT || 5173;
19-
server.listen(port, () => {});
18+
const port = process.env.PORT || 6274;
19+
server.on("listening", () => {
20+
console.log(
21+
`🔍 MCP Inspector is up and running at http://127.0.0.1:${port} 🚀`,
22+
);
23+
});
24+
server.on("error", (err) => {
25+
if (err.message.includes(`EADDRINUSE`)) {
26+
console.error(
27+
`❌ MCP Inspector PORT IS IN USE at http://127.0.0.1:${port} ❌ `,
28+
);
29+
} else {
30+
throw err;
31+
}
32+
});
33+
server.listen(port);

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"dev": "vite",
1919
"build": "tsc -b && vite build",
2020
"lint": "eslint .",
21-
"preview": "vite preview",
21+
"preview": "vite preview --port 6274",
2222
"test": "jest --config jest.config.cjs",
2323
"test:watch": "jest --config jest.config.cjs --watch"
2424
},

client/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import { DEFAULT_INSPECTOR_CONFIG } from "./lib/constants";
4949
import { InspectorConfig } from "./lib/configurationTypes";
5050

5151
const params = new URLSearchParams(window.location.search);
52-
const PROXY_PORT = params.get("proxyPort") ?? "3000";
52+
const PROXY_PORT = params.get("proxyPort") ?? "6277";
5353
const PROXY_SERVER_URL = `http://${window.location.hostname}:${PROXY_PORT}`;
5454
const CONFIG_LOCAL_STORAGE_KEY = "inspectorConfig_v1";
5555

client/src/components/Sidebar.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
Github,
99
Eye,
1010
EyeOff,
11+
RotateCcw,
1112
Settings,
1213
} from "lucide-react";
1314
import { Button } from "@/components/ui/button";
@@ -375,8 +376,17 @@ const Sidebar = ({
375376

376377
<div className="space-y-2">
377378
<Button className="w-full" onClick={onConnect}>
378-
<Play className="w-4 h-4 mr-2" />
379-
Connect
379+
{connectionStatus === "connected" ? (
380+
<>
381+
<RotateCcw className="w-4 h-4 mr-2" />
382+
{transportType === "stdio" ? "Restart" : "Reconnect"}
383+
</>
384+
) : (
385+
<>
386+
<Play className="w-4 h-4 mr-2" />
387+
Connect
388+
</>
389+
)}
380390
</Button>
381391

382392
<div className="flex items-center justify-center space-x-2 mb-4">

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/src/index.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
StdioClientTransport,
1313
getDefaultEnvironment,
1414
} from "@modelcontextprotocol/sdk/client/stdio.js";
15+
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
1516
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
1617
import express from "express";
1718
import { findActualExecutable } from "spawn-rx";
@@ -98,12 +99,14 @@ const createTransport = async (req: express.Request) => {
9899
}
99100
};
100101

102+
let backingServerTransport: Transport | undefined;
103+
101104
app.get("/sse", async (req, res) => {
102105
try {
103106
console.log("New SSE connection");
104107

105-
let backingServerTransport;
106108
try {
109+
await backingServerTransport?.close();
107110
backingServerTransport = await createTransport(req);
108111
} catch (error) {
109112
if (error instanceof SseError && error.code === 401) {
@@ -182,17 +185,17 @@ app.get("/config", (req, res) => {
182185
}
183186
});
184187

185-
const PORT = process.env.PORT || 3000;
186-
187-
try {
188-
const server = app.listen(PORT);
188+
const PORT = process.env.PORT || 6277;
189189

190-
server.on("listening", () => {
191-
const addr = server.address();
192-
const port = typeof addr === "string" ? addr : addr?.port;
193-
console.log(`Proxy server listening on port ${port}`);
194-
});
195-
} catch (error) {
196-
console.error("Failed to start server:", error);
190+
const server = app.listen(PORT);
191+
server.on("listening", () => {
192+
console.log(`⚙️ Proxy server listening on port ${PORT}`);
193+
});
194+
server.on("error", (err) => {
195+
if (err.message.includes(`EADDRINUSE`)) {
196+
console.error(`❌ Proxy Server PORT IS IN USE at port ${PORT} ❌ `);
197+
} else {
198+
console.error(err.message);
199+
}
197200
process.exit(1);
198-
}
201+
});

0 commit comments

Comments
 (0)