Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ async function main() {

// Make sure our server/client didn't immediately fail
await Promise.any([server, client, delay(2 * 1000)]);
const portParam = SERVER_PORT === "3000" ? "" : `?proxyPort=${SERVER_PORT}`;
console.log(
`\n🔍 MCP Inspector is up and running at http://localhost:${CLIENT_PORT} 🚀`,
`\n🔍 MCP Inspector is up and running at http://localhost:${CLIENT_PORT}${portParam} 🚀`,
);

try {
Expand Down
17 changes: 11 additions & 6 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ import ToolsTab from "./components/ToolsTab";

const DEFAULT_REQUEST_TIMEOUT_MSEC = 10000;

const params = new URLSearchParams(window.location.search);
const PROXY_PORT = params.get("proxyPort") ?? "3000";
const PROXY_SERVER_URL = `http://localhost:${PROXY_PORT}`;

const App = () => {
const [connectionStatus, setConnectionStatus] = useState<
"disconnected" | "connected" | "error"
Expand All @@ -82,7 +86,8 @@ const App = () => {
const [args, setArgs] = useState<string>(() => {
return localStorage.getItem("lastArgs") || "";
});
const [url, setUrl] = useState<string>("http://localhost:3001/sse");

const [sseUrl, setSseUrl] = useState<string>("http://localhost:3001/sse");
const [transportType, setTransportType] = useState<"stdio" | "sse">("stdio");
const [requestHistory, setRequestHistory] = useState<
{ request: string; response?: string }[]
Expand Down Expand Up @@ -191,7 +196,7 @@ const App = () => {
}, [args]);

useEffect(() => {
fetch("http://localhost:3000/config")
fetch(`${PROXY_SERVER_URL}/config`)
.then((response) => response.json())
.then((data) => {
setEnv(data.defaultEnvironment);
Expand Down Expand Up @@ -404,15 +409,15 @@ const App = () => {
},
);

const backendUrl = new URL("http://localhost:3000/sse");
const backendUrl = new URL(`${PROXY_SERVER_URL}/sse`);

backendUrl.searchParams.append("transportType", transportType);
if (transportType === "stdio") {
backendUrl.searchParams.append("command", command);
backendUrl.searchParams.append("args", args);
backendUrl.searchParams.append("env", JSON.stringify(env));
} else {
backendUrl.searchParams.append("url", url);
backendUrl.searchParams.append("url", sseUrl);
}

const clientTransport = new SSEClientTransport(backendUrl);
Expand Down Expand Up @@ -469,8 +474,8 @@ const App = () => {
setCommand={setCommand}
args={args}
setArgs={setArgs}
url={url}
setUrl={setUrl}
sseUrl={sseUrl}
setSseUrl={setSseUrl}
env={env}
setEnv={setEnv}
onConnect={connectMcpServer}
Expand Down
13 changes: 7 additions & 6 deletions client/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ interface SidebarProps {
setCommand: (command: string) => void;
args: string;
setArgs: (args: string) => void;
url: string;
setUrl: (url: string) => void;
sseUrl: string;
setSseUrl: (url: string) => void;
env: Record<string, string>;
setEnv: (env: Record<string, string>) => void;
onConnect: () => void;
Expand All @@ -38,8 +38,8 @@ const Sidebar = ({
setCommand,
args,
setArgs,
url,
setUrl,
sseUrl,
setSseUrl,
env,
setEnv,
onConnect,
Expand Down Expand Up @@ -75,6 +75,7 @@ const Sidebar = ({
</SelectContent>
</Select>
</div>

{transportType === "stdio" ? (
<>
<div className="space-y-2">
Expand All @@ -99,8 +100,8 @@ const Sidebar = ({
<label className="text-sm font-medium">URL</label>
<Input
placeholder="URL"
value={url}
onChange={(e) => setUrl(e.target.value)}
value={sseUrl}
onChange={(e) => setSseUrl(e.target.value)}
/>
</div>
)}
Expand Down