Skip to content

Commit aa08802

Browse files
authored
Merge pull request #5 from trueberryless/fix/get-request-method-not-allowed
Return "Method Not Allowed" and Do Not Allow MCP Requests to "/"
2 parents 8e1e1d0 + defad8a commit aa08802

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

netlify.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
11
[build]
22
publish = "public"
3-
4-
[[redirects]]
5-
from = "/mcp"
6-
to = "/"
7-
status = 303

netlify/edge-functions/mcp-server.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ function formatResponse(data: unknown): {
9696

9797
// Netlify Edge Function Handler
9898
export default async function handler(req: Request) {
99+
if (req.method === "GET") {
100+
return new Response("Method Not Allowed", {
101+
status: 405,
102+
headers: {
103+
"Content-Type": "text/plain",
104+
Allow: "POST",
105+
},
106+
});
107+
}
99108
try {
100109
const { req: nodeReq, res: nodeRes } = toReqRes(req);
101110
const server = getServer();
@@ -128,6 +137,6 @@ export default async function handler(req: Request) {
128137
}
129138

130139
export const config: Config = {
131-
path: ["/mcp", "/"],
132-
method: ["POST"],
140+
path: ["/mcp"],
141+
method: ["POST", "GET"],
133142
};

0 commit comments

Comments
 (0)