Skip to content

Commit bfdbdb9

Browse files
committed
force SSE
1 parent b3f02f0 commit bfdbdb9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/index.http.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@ app.get("/", (_req, res) => {
1414
res.json({ name: "cloudinary-mcp-server", status: "running", mcp: "/mcp" });
1515
});
1616

17+
18+
// Force SSE negotiation for ChatGPT connector validation
19+
app.use("/mcp", (req, _res, next) => {
20+
const accept = req.headers["accept"];
21+
22+
// Some clients (like ChatGPT connector validation) may not send the SSE accept header.
23+
// The MCP Streamable HTTP transport requires the client to accept text/event-stream.
24+
if (typeof accept !== "string" || !accept.includes("text/event-stream")) {
25+
req.headers["accept"] = accept
26+
? `${accept}, text/event-stream`
27+
: "application/json, text/event-stream";
28+
}
29+
30+
next();
31+
});
32+
33+
1734
app.post("/mcp", async (req, res) => {
1835
const server = new CloudinaryServer(); // ✅ no args
1936

0 commit comments

Comments
 (0)