import { useState } from "react"; import { Play, ChevronDown, ChevronRight, CircleHelp, Bug, Github, Eye, EyeOff, RotateCcw, Settings, HelpCircle, RefreshCwOff, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { StdErrNotification } from "@/lib/notificationTypes"; import { LoggingLevel, LoggingLevelSchema, } from "@modelcontextprotocol/sdk/types.js"; import { InspectorConfig } from "@/lib/configurationTypes"; import { ConnectionStatus } from "@/lib/constants"; import useTheme from "../lib/useTheme"; import { version } from "../../../package.json"; import { Tooltip, TooltipTrigger, TooltipContent, } from "@/components/ui/tooltip"; interface SidebarProps { connectionStatus: ConnectionStatus; transportType: "stdio" | "sse"; setTransportType: (type: "stdio" | "sse") => void; command: string; setCommand: (command: string) => void; args: string; setArgs: (args: string) => void; sseUrl: string; setSseUrl: (url: string) => void; env: Record; setEnv: (env: Record) => void; bearerToken: string; setBearerToken: (token: string) => void; headerName?: string; setHeaderName?: (name: string) => void; onConnect: () => void; onDisconnect: () => void; stdErrNotifications: StdErrNotification[]; clearStdErrNotifications: () => void; logLevel: LoggingLevel; sendLogLevelRequest: (level: LoggingLevel) => void; loggingSupported: boolean; config: InspectorConfig; setConfig: (config: InspectorConfig) => void; } const Sidebar = ({ connectionStatus, transportType, setTransportType, command, setCommand, args, setArgs, sseUrl, setSseUrl, env, setEnv, bearerToken, setBearerToken, headerName, setHeaderName, onConnect, onDisconnect, stdErrNotifications, clearStdErrNotifications, logLevel, sendLogLevelRequest, loggingSupported, config, setConfig, }: SidebarProps) => { const [theme, setTheme] = useTheme(); const [showEnvVars, setShowEnvVars] = useState(false); const [showBearerToken, setShowBearerToken] = useState(false); const [showConfig, setShowConfig] = useState(false); const [shownEnvVars, setShownEnvVars] = useState>(new Set()); return (

MCP Inspector v{version}

{transportType === "stdio" ? ( <>
setCommand(e.target.value)} className="font-mono" />
setArgs(e.target.value)} className="font-mono" />
) : ( <>
setSseUrl(e.target.value)} className="font-mono" />
{showBearerToken && (
setHeaderName && setHeaderName(e.target.value) } data-testid="header-input" className="font-mono" value={headerName} /> setBearerToken(e.target.value)} data-testid="bearer-token-input" className="font-mono" type="password" />
)}
)} {transportType === "stdio" && (
{showEnvVars && (
{Object.entries(env).map(([key, value], idx) => (
{ const newKey = e.target.value; const newEnv = Object.entries(env).reduce( (acc, [k, v]) => { if (k === key) { acc[newKey] = value; } else { acc[k] = v; } return acc; }, {} as Record, ); setEnv(newEnv); setShownEnvVars((prev) => { const next = new Set(prev); if (next.has(key)) { next.delete(key); next.add(newKey); } return next; }); }} className="font-mono" />
{ const newEnv = { ...env }; newEnv[key] = e.target.value; setEnv(newEnv); }} className="font-mono" />
))}
)}
)} {/* Configuration */}
{showConfig && (
{Object.entries(config).map(([key, configItem]) => { const configKey = key as keyof InspectorConfig; return (
{configItem.description}
{typeof configItem.value === "number" ? ( { const newConfig = { ...config }; newConfig[configKey] = { ...configItem, value: Number(e.target.value), }; setConfig(newConfig); }} className="font-mono" /> ) : typeof configItem.value === "boolean" ? ( ) : ( { const newConfig = { ...config }; newConfig[configKey] = { ...configItem, value: e.target.value, }; setConfig(newConfig); }} className="font-mono" /> )}
); })}
)}
{connectionStatus === "connected" && (
)} {connectionStatus !== "connected" && ( )}
{ switch (connectionStatus) { case "connected": return "bg-green-500"; case "error": return "bg-red-500"; case "error-connecting-to-proxy": return "bg-red-500"; default: return "bg-gray-500"; } })()}`} /> {(() => { switch (connectionStatus) { case "connected": return "Connected"; case "error": return "Connection Error, is your MCP server running?"; case "error-connecting-to-proxy": return "Error Connecting to MCP Inspector Proxy - Check Console logs"; default: return "Disconnected"; } })()}
{loggingSupported && connectionStatus === "connected" && (
)} {stdErrNotifications.length > 0 && ( <>

Error output from MCP server

{stdErrNotifications.map((notification, index) => (
{notification.params.content}
))}
)}
); }; export default Sidebar;