File tree Expand file tree Collapse file tree 3 files changed +4
-29
lines changed Expand file tree Collapse file tree 3 files changed +4
-29
lines changed Original file line number Diff line number Diff line change 1
1
[build ]
2
2
publish = " public"
3
-
4
- [[redirects ]]
5
- from = " /"
6
- to = " https://docs.astro.build/en/reference/mcp-server/"
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js" ;
3
3
import { toFetchResponse , toReqRes } from "fetch-to-node" ;
4
4
import z from "zod" ;
5
- import type { Config } from "@netlify/edge-functions" ;
5
+ import type { Config , Context } from "@netlify/edge-functions" ;
6
6
7
7
const apiKey = Netlify . env . get ( "KAPA_API_KEY" ) ;
8
8
const projectId = Netlify . env . get ( "KAPA_PROJECT_ID" ) ;
@@ -95,8 +95,8 @@ function formatResponse(data: unknown): {
95
95
}
96
96
97
97
// Netlify Edge Function Handler
98
- export default async function handler ( req : Request ) {
99
- if ( req . method !== "POST" ) {
98
+ export default async function handler ( req : Request , { url } : Context ) {
99
+ if ( req . method !== "POST" || url . pathname !== "/mcp" ) {
100
100
return Response . redirect (
101
101
"https://docs.astro.build/en/reference/mcp-server/" ,
102
102
302
@@ -134,6 +134,6 @@ export default async function handler(req: Request) {
134
134
}
135
135
136
136
export const config : Config = {
137
- path : "/ mcp",
137
+ path : [ "/" , "/ mcp"] ,
138
138
method : [ "POST" , "GET" ] ,
139
139
} ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments