Skip to content

Context7 Platform -- Up-to-date docs for AI agents

fix: reject GET requests on MCP endpoints to eliminate idle SSE timeouts (#2099)

Fahreddin Özcan9523522d33a0
diff --git a/.changeset/bright-foxes-glow.md b/.changeset/bright-foxes-glow.md
new file mode 100644
index 00000000..61136cc5
--- /dev/null
+++ b/.changeset/bright-foxes-glow.md
@@ -0,0 +1,5 @@
+---
+"@upstash/context7-mcp": patch
+---
+
+Reject GET requests on MCP endpoints with 405 to eliminate idle SSE connection timeouts
diff --git a/packages/mcp/src/index.ts b/packages/mcp/src/index.ts
index ee403361..2bc67d8c 100644
--- a/packages/mcp/src/index.ts
+++ b/packages/mcp/src/index.ts
@@ -320,6 +320,17 @@ async function main() {
res: express.Response,
requireAuth: boolean
) => {
+ // Reject GET requests — this server is stateless and does not send server-initiated
+ // notifications, so SSE streams serve no purpose and cause mass NGINX timeouts.
+ // Returning 405 is spec-compliant per MCP StreamableHTTP (2025-03-26).
+ if (req.method === "GET") {
+ return res.status(405).json({
+ jsonrpc: "2.0",
+ error: { code: -32000, message: "Server does not support GET requests" },
+ id: null,
+ });
+ }
+
try {
const apiKey = extractApiKey(req);
const resourceUrl = RESOURCE_URL;