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' }));

View File

@@ -33,7 +33,7 @@ server {
proxy_pass http://127.0.0.1:3000;
}
location = /mcp {
location ~ ^/(api/)?mcp/?$ {
proxy_http_version 1.1;
proxy_buffering off;
proxy_cache off;
@@ -43,6 +43,7 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Prefix /mcp;
proxy_pass http://127.0.0.1:3001;
}