)
);
+ if (method === 'DELETE' && url.includes(CORS_PROXY_ENDPOINT)) {
+ const response = new Response(null, { status: 200, statusText: 'OK' });
+
+ logIfEnabled(
+ this.createLog(
+ MCPConnectionPhase.INITIALIZING,
+ `HTTP 200 ${method} ${url} (fake response)`,
+ MCPLogLevel.INFO,
+ {
+ response: {
+ url,
+ status: response.status,
+ statusText: response.statusText,
+ durationMs: 0,
+ isFake: true
+ }
+ }
+ )
+ );
+
+ // fake response, bypass real fetch()
+ return response;
+ }
+
try {
const response = await fetch(input, {
...baseInit,
});
});
+ it('DELETE request with CORS proxy should return a fake 200 response', async () => {
+ const logs: MCPConnectionLog[] = [];
+ const fetchMock = vi.fn();
+
+ vi.stubGlobal('fetch', fetchMock);
+
+ const config: MCPServerConfig = {
+ url: 'https://example.com/mcp',
+ transport: MCPTransportType.STREAMABLE_HTTP,
+ useProxy: true
+ };
+
+ const controller = createDiagnosticFetch(config, (log) => logs.push(log), {}, true);
+
+ const response = await controller.fetch(
+ 'http://localhost:8080/cors-proxy?url=https%3A%2F%2Fexample.com%2Fmcp',
+ { method: 'DELETE' }
+ );
+
+ expect(fetchMock).not.toHaveBeenCalled();
+ expect(response.status).toBe(200);
+ expect(logs.at(-1)?.details).toMatchObject({
+ response: { status: 200, isFake: true }
+ });
+ });
+
it('partially redacts mcp-session-id in diagnostic request and response logs', async () => {
const logs: MCPConnectionLog[] = [];
const response = new Response('{}', {