This commit is contained in:
bipproduction
2025-10-27 10:16:26 +08:00
parent 4fde9c1087
commit f6eb645886

View File

@@ -1,20 +1,20 @@
import { Elysia } from "elysia"; import { Elysia } from "elysia";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
const API_KEY = process.env.MCP_API_KEY ?? "super-secret-key"; // const API_KEY = process.env.MCP_API_KEY ?? "super-secret-key";
const PORT = Number(process.env.PORT ?? 3000); // const PORT = Number(process.env.PORT ?? 3000);
// ===================== // // =====================
// Helper Functions // // Helper Functions
// ===================== // // =====================
function isAuthorized(headers: Headers) { // function isAuthorized(headers: Headers) {
const authHeader = headers.get("authorization"); // const authHeader = headers.get("authorization");
if (authHeader?.startsWith("Bearer ")) { // if (authHeader?.startsWith("Bearer ")) {
const token = authHeader.substring(7); // const token = authHeader.substring(7);
return token === API_KEY; // return token === API_KEY;
} // }
return headers.get("x-api-key") === API_KEY; // return headers.get("x-api-key") === API_KEY;
} // }
// ===================== // =====================
// Tools Definition // Tools Definition