respond to PR feedback

This commit is contained in:
Ashwin Bhat
2025-01-10 07:50:45 -08:00
parent a976aefb39
commit 052de8690d
3 changed files with 39 additions and 17 deletions

View File

@@ -21,10 +21,13 @@ You can pass both arguments and environment variables to your MCP server. Argume
npx @modelcontextprotocol/inspector build/index.js arg1 arg2 npx @modelcontextprotocol/inspector build/index.js arg1 arg2
# Pass environment variables only # Pass environment variables only
npx @modelcontextprotocol/inspector -e KEY=value -e KEY2=value2 build/index.js npx @modelcontextprotocol/inspector -e KEY=value -e KEY2=$VALUE2 build/index.js
# Pass both environment variables and arguments # Pass both environment variables and arguments
npx @modelcontextprotocol/inspector -e KEY=value -e KEY2=value2 build/index.js arg1 arg2 npx @modelcontextprotocol/inspector -e KEY=value -e KEY2=$VALUE2 build/index.js arg1 arg2
# Use -- to separate inspector flags from server arguments
npx @modelcontextprotocol/inspector -e KEY=$VALUE -- build/index.js -e server-flag
``` ```
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: 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:

View File

@@ -16,17 +16,25 @@ async function main() {
const envVars = {}; const envVars = {};
const mcpServerArgs = []; const mcpServerArgs = [];
let command = null; let command = null;
let parsingFlags = true;
for (let i = 0; i < args.length; i++) { for (let i = 0; i < args.length; i++) {
if (args[i] === "-e" && i + 1 < args.length) { const arg = args[i];
if (parsingFlags && arg === "--") {
parsingFlags = false;
continue;
}
if (parsingFlags && arg === "-e" && i + 1 < args.length) {
const [key, value] = args[++i].split("="); const [key, value] = args[++i].split("=");
if (key && value) { if (key && value) {
envVars[key] = value; envVars[key] = value;
} }
} else if (!command) { } else if (!command) {
command = args[i]; command = arg;
} else { } else {
mcpServerArgs.push(args[i]); mcpServerArgs.push(arg);
} }
} }

View File

@@ -56,7 +56,7 @@ const Sidebar = ({
}: SidebarProps) => { }: SidebarProps) => {
const [theme, setTheme] = useTheme(); const [theme, setTheme] = useTheme();
const [showEnvVars, setShowEnvVars] = useState(false); const [showEnvVars, setShowEnvVars] = useState(false);
const [shownEnvVars, setShownEnvVars] = useState<Record<string, boolean>>({}); const [shownEnvVars, setShownEnvVars] = useState<Set<string>>(new Set());
return ( return (
<div className="w-80 bg-card border-r border-border flex flex-col h-full"> <div className="w-80 bg-card border-r border-border flex flex-col h-full">
@@ -149,8 +149,12 @@ const Sidebar = ({
newEnv[newKey] = value; newEnv[newKey] = value;
setEnv(newEnv); setEnv(newEnv);
setShownEnvVars((prev) => { setShownEnvVars((prev) => {
const { [key]: shown, ...rest } = prev; const next = new Set(prev);
return shown ? { ...rest, [newKey]: true } : rest; if (next.has(key)) {
next.delete(key);
next.add(newKey);
}
return next;
}); });
}} }}
className="font-mono" className="font-mono"
@@ -170,7 +174,7 @@ const Sidebar = ({
</div> </div>
<div className="flex gap-2"> <div className="flex gap-2">
<Input <Input
type={shownEnvVars[key] ? "text" : "password"} type={shownEnvVars.has(key) ? "text" : "password"}
placeholder="Value" placeholder="Value"
value={value} value={value}
onChange={(e) => { onChange={(e) => {
@@ -185,16 +189,24 @@ const Sidebar = ({
size="icon" size="icon"
className="h-9 w-9 p-0 shrink-0" className="h-9 w-9 p-0 shrink-0"
onClick={() => { onClick={() => {
setShownEnvVars((prev) => ({ setShownEnvVars((prev) => {
...prev, const next = new Set(prev);
[key]: !prev[key], if (next.has(key)) {
})); next.delete(key);
} else {
next.add(key);
}
return next;
});
}} }}
aria-label={shownEnvVars.has(key) ? "Hide value" : "Show value"}
aria-pressed={shownEnvVars.has(key)}
title={shownEnvVars.has(key) ? "Hide value" : "Show value"}
> >
{shownEnvVars[key] ? ( {shownEnvVars.has(key) ? (
<Eye className="h-4 w-4" /> <Eye className="h-4 w-4" aria-hidden="true" />
) : ( ) : (
<EyeOff className="h-4 w-4" /> <EyeOff className="h-4 w-4" aria-hidden="true" />
)} )}
</Button> </Button>
</div> </div>
@@ -208,7 +220,6 @@ const Sidebar = ({
const newEnv = { ...env }; const newEnv = { ...env };
newEnv[key] = ""; newEnv[key] = "";
setEnv(newEnv); setEnv(newEnv);
setShownEnvVars({});
}} }}
> >
Add Environment Variable Add Environment Variable