@modelcontextprotocol/inspector 0.2.2 โ 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -3
- package/bin/cli.js +75 -52
- package/client/dist/assets/index-2ujHziSR.js +22525 -0
- package/client/dist/assets/index-DY7RF803.css +2303 -0
- package/client/dist/index.html +2 -2
- package/package.json +9 -7
- package/server/build/index.js +5 -3
- package/client/dist/assets/index-CeTDqh-y.css +0 -1
- package/client/dist/assets/index-jOz_Q5JL.js +0 -185
package/README.md
CHANGED
|
@@ -2,18 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
The MCP inspector is a developer tool for testing and debugging MCP servers.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+

|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Running the Inspector
|
|
8
|
+
|
|
9
|
+
### From an MCP server repository
|
|
10
|
+
|
|
11
|
+
To inspect an MCP server implementation, there's no need to clone this repo. Instead, use `npx`. For example, if your server is built at `build/index.js`:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
8
14
|
npx @modelcontextprotocol/inspector build/index.js
|
|
9
15
|
```
|
|
10
16
|
|
|
11
|
-
You can also pass arguments along to
|
|
17
|
+
You can also pass arguments along which will get passed as arguments to your MCP server:
|
|
12
18
|
|
|
13
19
|
```
|
|
14
20
|
npx @modelcontextprotocol/inspector build/index.js arg1 arg2 ...
|
|
15
21
|
```
|
|
16
22
|
|
|
23
|
+
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:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
CLIENT_PORT=8080 SERVER_PORT=9000 npx @modelcontextprotocol/inspector build/index.js
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### From this repository
|
|
30
|
+
|
|
31
|
+
If you're working on the inspector itself:
|
|
32
|
+
|
|
33
|
+
Development mode:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm run dev
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Production mode:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm run build
|
|
43
|
+
npm start
|
|
44
|
+
```
|
|
45
|
+
|
|
17
46
|
## License
|
|
18
47
|
|
|
19
48
|
This project is licensed under the MIT Licenseโsee the [LICENSE](LICENSE) file for details.
|
package/bin/cli.js
CHANGED
|
@@ -1,65 +1,88 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { resolve, dirname } from "path";
|
|
4
|
+
import { spawnPromise } from "spawn-rx";
|
|
4
5
|
import { fileURLToPath } from "url";
|
|
5
|
-
import concurrently from "concurrently";
|
|
6
6
|
|
|
7
7
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
function delay(ms) {
|
|
10
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
11
|
+
}
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
async function main() {
|
|
14
|
+
// Get command line arguments
|
|
15
|
+
const [, , command, ...mcpServerArgs] = process.argv;
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
const inspectorServerPath = resolve(
|
|
18
|
+
__dirname,
|
|
19
|
+
"..",
|
|
20
|
+
"server",
|
|
21
|
+
"build",
|
|
22
|
+
"index.js",
|
|
23
|
+
);
|
|
16
24
|
|
|
17
|
-
|
|
25
|
+
// Path to the client entry point
|
|
26
|
+
const inspectorClientPath = resolve(
|
|
27
|
+
__dirname,
|
|
28
|
+
"..",
|
|
29
|
+
"client",
|
|
30
|
+
"bin",
|
|
31
|
+
"cli.js",
|
|
32
|
+
);
|
|
18
33
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return `\\"${arg.replace(/"/g, '\\\\\\"')}\\"`;
|
|
22
|
-
}
|
|
23
|
-
return arg;
|
|
24
|
-
}
|
|
34
|
+
const CLIENT_PORT = process.env.CLIENT_PORT ?? "5173";
|
|
35
|
+
const SERVER_PORT = process.env.SERVER_PORT ?? "3000";
|
|
25
36
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
command: `PORT=${SERVER_PORT} ${serverCommand}`,
|
|
44
|
-
name: "server",
|
|
45
|
-
},
|
|
37
|
+
console.log("Starting MCP inspector...");
|
|
38
|
+
|
|
39
|
+
const abort = new AbortController();
|
|
40
|
+
|
|
41
|
+
let cancelled = false;
|
|
42
|
+
process.on("SIGINT", () => {
|
|
43
|
+
cancelled = true;
|
|
44
|
+
abort.abort();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const server = spawnPromise(
|
|
48
|
+
"node",
|
|
49
|
+
[
|
|
50
|
+
inspectorServerPath,
|
|
51
|
+
...(command ? [`--env`, command] : []),
|
|
52
|
+
...(mcpServerArgs ? ["--args", mcpServerArgs.join(" ")] : []),
|
|
53
|
+
],
|
|
46
54
|
{
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
env: { ...process.env, PORT: SERVER_PORT },
|
|
56
|
+
signal: abort.signal,
|
|
57
|
+
echoOutput: true,
|
|
49
58
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const client = spawnPromise("node", [inspectorClientPath], {
|
|
62
|
+
env: { ...process.env, PORT: CLIENT_PORT },
|
|
63
|
+
signal: abort.signal,
|
|
64
|
+
echoOutput: true,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Make sure our server/client didn't immediately fail
|
|
68
|
+
await Promise.any([server, client, delay(2 * 1000)]);
|
|
69
|
+
const portParam = SERVER_PORT === "3000" ? "" : `?proxyPort=${SERVER_PORT}`;
|
|
70
|
+
console.log(
|
|
71
|
+
`\n๐ MCP Inspector is up and running at http://localhost:${CLIENT_PORT}${portParam} ๐`,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
await Promise.any([server, client]);
|
|
76
|
+
} catch (e) {
|
|
77
|
+
if (!cancelled || process.env.DEBUG) throw e;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
main()
|
|
84
|
+
.then((_) => process.exit(0))
|
|
85
|
+
.catch((e) => {
|
|
86
|
+
console.error(e);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
});
|