File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { http_transport } from '$lib/mcp/index.js' ;
2
2
import { db } from '$lib/server/db/index.js' ;
3
+ import { redirect } from '@sveltejs/kit' ;
3
4
4
5
export async function handle ( { event, resolve } ) {
6
+ if ( event . request . method === 'GET' ) {
7
+ const accept = event . request . headers . get ( 'accept' ) ;
8
+ if ( accept ) {
9
+ const accepts = accept . split ( ',' ) ;
10
+ if ( ! accepts . includes ( 'text/event-stream' ) ) {
11
+ // the request it's a browser request, not an MCP client request
12
+ // it means someone probably opened it from the docs...we should redirect to the docs
13
+ redirect ( 302 , 'https://svelte.dev/docs/mcp/overview' ) ;
14
+ }
15
+ }
16
+ }
5
17
const mcp_response = await http_transport . respond ( event . request , {
6
18
db,
7
19
} ) ;
You can’t perform that action at this time.
0 commit comments