This commit is contained in:
Bastian Wagner
2026-06-17 14:19:19 +02:00
parent fac7309116
commit 81b5f1dde9
2 changed files with 6 additions and 3 deletions

View File

@@ -65,13 +65,15 @@ export class McpServerService {
return;
}
const pathname = new URL(request.url ?? '/', 'http://localhost').pathname;
if (pathname !== '/mcp') {
const url = new URL(request.url ?? '/', 'http://localhost');
if (!['/mcp', '/mcp/', '/api/mcp', '/api/mcp/'].includes(url.pathname)) {
response.writeHead(404, { 'content-type': 'application/json' });
response.end(JSON.stringify({ error: 'Not found' }));
return;
}
request.url = `/mcp${url.search}`;
if (!this.isAuthorized(request)) {
response.writeHead(401, { 'content-type': 'application/json' });
response.end(JSON.stringify({ error: 'Unauthorized' }));