INNER CODE UNIT · JavaScript
mcpFetch
EdgeTypE/better-deepseek · src/background/index.js:650
async function mcpFetch(serverUrl, bodyObj, apiKey, { sessionId, signal, authMethod } = {}) {
const startedAt = Date.now();
const methodName = bodyObj?.method || "?";
devLog("MCP", `>> ${methodName} @ ${serverUrl} [auth=${authMethod}, sessionId=${sessionId}]`);
const ac = !signal ? new AbortController() : null;
const resolvedSignal = signal || ac.signal;
const timer = ac ? setTimeout(() => ac.abort(new DOMException("MCP server did not respond within 30s", "TimeoutError")), MCP_REQUEST_TIMEOUT_MS) : null;
try {
const resp = await fetch(serverUrl, {
method: "POST",
headers: mcpHeaders(apiKey, sessionId, authMethod),
body: JSON.stringify(bodyObj),
signal: resolvedSignal,
});
if (!resp.ok) {
let detail = "";
try { detail = await resp.text(); } catch (e) { }