INNER CODE UNIT · JavaScript
mcpHeaders
EdgeTypE/better-deepseek · src/background/index.js:626
function mcpHeaders(apiKey, sessionId, authMethod = "bearer") {
const h = { "Content-Type": "application/json", Accept: "application/json, text/event-stream" };
if (apiKey && authMethod === "bearer") {
h["Authorization"] = `Bearer ${apiKey}`;
} else if (apiKey && authMethod === "x-api-key") {
h["X-API-Key"] = apiKey;
}
if (sessionId) {
h["Mcp-Session-Id"] = sessionId;
}
return h;
}
/**
* Send a single JSON-RPC request and parse the response.
*
* Handles JSON and SSE (text/event-stream) response content types.
* Reads the Mcp-Session-Id response header for session tracking and