mcp
This commit is contained in:
@@ -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' }));
|
||||
|
||||
Reference in New Issue
Block a user