Skip to content

Commit 9a70fbe

Browse files
committed
feat: redirect to docs in case someone visits via browser
1 parent dc16a42 commit 9a70fbe

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

apps/mcp-remote/src/hooks.server.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
import { http_transport } from '$lib/mcp/index.js';
22
import { db } from '$lib/server/db/index.js';
3+
import { redirect } from '@sveltejs/kit';
34

45
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+
}
517
const mcp_response = await http_transport.respond(event.request, {
618
db,
719
});

0 commit comments

Comments
 (0)