From a92546ace47b2fddbacc05dbe5c0598947d8df99 Mon Sep 17 00:00:00 2001 From: bendtherules Date: Wed, 22 Apr 2026 10:42:16 +0530 Subject: [PATCH] feat(mcp): add HEAD route for health probe and include it in CORS allowMethods --- src/mcp-server-http.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/mcp-server-http.ts b/src/mcp-server-http.ts index 23d8cfc..4a7336e 100644 --- a/src/mcp-server-http.ts +++ b/src/mcp-server-http.ts @@ -238,7 +238,7 @@ export async function main() { "*", cors({ origin: "*", - allowMethods: ["GET", "POST", "DELETE", "OPTIONS"], + allowMethods: ["GET", "POST", "HEAD", "DELETE", "OPTIONS"], allowHeaders: [ "Content-Type", "mcp-session-id", @@ -252,7 +252,19 @@ export async function main() { // Health check endpoint app.get("/health", (c) => c.json({ status: "ok" })); - // MCP endpoint - handles both GET and POST + // MCP HEAD endpoint - health check / availability probe + // Must be defined BEFORE app.all for proper route matching (specific routes first) + app.on("HEAD", "/mcp", (_c) => { + return new Response(null, { + status: 200, + headers: { + "Content-Type": "application/json", + "mcp-protocol-version": "2025-03-26", + }, + }); + }); + + // MCP endpoint - handles GET and POST // Must be defined BEFORE inspector (which mounts at /) for proper route matching app.all("/mcp", async (c) => { // Get parsed body from Hono (automatic JSON parsing)