@modelcontextprotocol/inspector 0.3.0 → 0.4.0

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 CHANGED
@@ -14,10 +14,20 @@ To inspect an MCP server implementation, there's no need to clone this repo. Ins
14
14
  npx @modelcontextprotocol/inspector build/index.js
15
15
  ```
16
16
 
17
- You can also pass arguments along which will get passed as arguments to your MCP server:
17
+ You can pass both arguments and environment variables to your MCP server. Arguments are passed directly to your server, while environment variables can be set using the `-e` flag:
18
18
 
19
- ```
20
- npx @modelcontextprotocol/inspector build/index.js arg1 arg2 ...
19
+ ```bash
20
+ # Pass arguments only
21
+ npx @modelcontextprotocol/inspector build/index.js arg1 arg2
22
+
23
+ # Pass environment variables only
24
+ npx @modelcontextprotocol/inspector -e KEY=value -e KEY2=$VALUE2 build/index.js
25
+
26
+ # Pass both environment variables and arguments
27
+ npx @modelcontextprotocol/inspector -e KEY=value -e KEY2=$VALUE2 build/index.js arg1 arg2
28
+
29
+ # Use -- to separate inspector flags from server arguments
30
+ npx @modelcontextprotocol/inspector -e KEY=$VALUE -- build/index.js -e server-flag
21
31
  ```
22
32
 
23
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:
@@ -26,7 +36,7 @@ The inspector runs both a client UI (default port 5173) and an MCP proxy server
26
36
  CLIENT_PORT=8080 SERVER_PORT=9000 npx @modelcontextprotocol/inspector build/index.js
27
37
  ```
28
38
 
29
- For more details on ways to use the inspector, see the [Inspector section of the MCP docs site](https://modelcontextprotocol.io/docs/tools/inspector).
39
+ For more details on ways to use the inspector, see the [Inspector section of the MCP docs site](https://modelcontextprotocol.io/docs/tools/inspector). For help with debugging, see the [Debugging guide](https://modelcontextprotocol.io/docs/tools/debugging).
30
40
 
31
41
  ### From this repository
32
42
 
package/bin/cli.js CHANGED
@@ -11,8 +11,32 @@ function delay(ms) {
11
11
  }
12
12
 
13
13
  async function main() {
14
- // Get command line arguments
15
- const [, , command, ...mcpServerArgs] = process.argv;
14
+ // Parse command line arguments
15
+ const args = process.argv.slice(2);
16
+ const envVars = {};
17
+ const mcpServerArgs = [];
18
+ let command = null;
19
+ let parsingFlags = true;
20
+
21
+ for (let i = 0; i < args.length; i++) {
22
+ const arg = args[i];
23
+
24
+ if (parsingFlags && arg === "--") {
25
+ parsingFlags = false;
26
+ continue;
27
+ }
28
+
29
+ if (parsingFlags && arg === "-e" && i + 1 < args.length) {
30
+ const [key, value] = args[++i].split("=");
31
+ if (key && value) {
32
+ envVars[key] = value;
33
+ }
34
+ } else if (!command) {
35
+ command = arg;
36
+ } else {
37
+ mcpServerArgs.push(arg);
38
+ }
39
+ }
16
40
 
17
41
  const inspectorServerPath = resolve(
18
42
  __dirname,
@@ -52,7 +76,11 @@ async function main() {
52
76
  ...(mcpServerArgs ? [`--args=${mcpServerArgs.join(" ")}`] : []),
53
77
  ],
54
78
  {
55
- env: { ...process.env, PORT: SERVER_PORT },
79
+ env: {
80
+ ...process.env,
81
+ PORT: SERVER_PORT,
82
+ MCP_ENV_VARS: JSON.stringify(envVars),
83
+ },
56
84
  signal: abort.signal,
57
85
  echoOutput: true,
58
86
  },
@@ -0,0 +1,33 @@
1
+ import { r as reactExports, j as jsxRuntimeExports, S as SESSION_KEYS, h as handleOAuthCallback } from "./index-DjoEM10P.js";
2
+ const OAuthCallback = () => {
3
+ const hasProcessedRef = reactExports.useRef(false);
4
+ reactExports.useEffect(() => {
5
+ const handleCallback = async () => {
6
+ if (hasProcessedRef.current) {
7
+ return;
8
+ }
9
+ hasProcessedRef.current = true;
10
+ const params = new URLSearchParams(window.location.search);
11
+ const code = params.get("code");
12
+ const serverUrl = sessionStorage.getItem(SESSION_KEYS.SERVER_URL);
13
+ if (!code || !serverUrl) {
14
+ console.error("Missing code or server URL");
15
+ window.location.href = "/";
16
+ return;
17
+ }
18
+ try {
19
+ const accessToken = await handleOAuthCallback(serverUrl, code);
20
+ sessionStorage.setItem(SESSION_KEYS.ACCESS_TOKEN, accessToken);
21
+ window.location.href = `/?serverUrl=${encodeURIComponent(serverUrl)}`;
22
+ } catch (error) {
23
+ console.error("OAuth callback error:", error);
24
+ window.location.href = "/";
25
+ }
26
+ };
27
+ void handleCallback();
28
+ }, []);
29
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-screen", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-lg text-gray-500", children: "Processing OAuth callback..." }) });
30
+ };
31
+ export {
32
+ OAuthCallback as default
33
+ };