INNER CODE UNIT · TypeScript
startSseServer
lazy-dinosaur/ccxt-mcp · src/index.ts:118
async function startSseServer() {
const effectiveConfigPath = resolveConfigPath();
const expectedBearerToken = readMcpBearerTokenFromConfig(effectiveConfigPath);
const sessions = new Map<string, { transport: SSEServerTransport; mcpServer: CcxtMcpServer }>();
const httpServer = createServer(async (req: IncomingMessage, res: ServerResponse) => {
try {
const requestUrl = new URL(req.url || "/", `http://${req.headers.host || "localhost"}`);
const presentedBearerToken = readBearerTokenFromHeader(req);
if (!presentedBearerToken) {
res.writeHead(401, { "content-type": "application/json; charset=utf-8" });
res.end(
JSON.stringify({
jsonrpc: "2.0",
error: {
code: -32600,