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 11import { http_transport } from '$lib/mcp/index.js' ;
22import { db } from '$lib/server/db/index.js' ;
3+ import { redirect } from '@sveltejs/kit' ;
34
45export 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' ) && event . url . pathname . startsWith ( '/mcp' ) ) {
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+ }
517 const mcp_response = await http_transport . respond ( event . request , {
618 db,
719 } ) ;
You can’t perform that action at this time.
0 commit comments