Addressed all Claude review issues.

This commit is contained in:
Bob Dickinson 2026-04-07 10:33:28 -07:00
commit 446a9bc1cf
2 changed files with 228 additions and 58 deletions

View file

@ -844,6 +844,24 @@ app.post(
try {
const { url, init } = req.body as { url: string; init?: RequestInit };
if (typeof url !== "string" || url.length === 0) {
res.status(400).json({ error: "Missing or invalid url" });
return;
}
let parsedUrl: URL;
try {
parsedUrl = new URL(url);
} catch {
res.status(400).json({ error: "Invalid URL" });
return;
}
if (!["http:", "https:"].includes(parsedUrl.protocol)) {
res.status(400).json({ error: "Only http/https URLs are allowed" });
return;
}
const response = await fetch(url, {
method: init?.method ?? "GET",
headers: (init?.headers as Record<string, string>) ?? {},

View file

@ -12,6 +12,9 @@ import { isJSONRPCRequest } from "@modelcontextprotocol/sdk/types.js";
* the band are assigned over time — e.g. **-32002** is used for **ResourceNotFound** in parts of
* the MCP ecosystem). We use **-32099** so this inspector-only bridge error stays clear of those
* registered meanings; the client still keys off `error.data` shape, not the number alone.
*
* Keep in sync with `client/src/lib/constants.ts`; drift is caught by
* `client/src/lib/__tests__/mcpProxyTransportErrorCode.test.ts`.
*/
export const MCP_PROXY_TRANSPORT_ERROR_CODE = -32099;
@ -62,8 +65,8 @@ export function serializeProxyTransportError(
} else if (error instanceof SseError) {
if (error.code !== undefined) attachHttpStatusIfValid(error.code);
}
const u = headerHolder?.lastUpstream401;
if (u && headerHolder) {
if (headerHolder?.lastUpstream401) {
const u = headerHolder.lastUpstream401;
data.upstream401 = {
wwwAuthenticate: u.wwwAuthenticate,
body: u.body,