Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(mcp): exclude /mcp from SPA fallback; assert 404 when MCP_ENABLED is unset

Yudhi Armyndharisee4ce2e9ff4e
diff --git a/src/app.module.ts b/src/app.module.ts
index e4ac8e30e..1fce70fb0 100644
--- a/src/app.module.ts
+++ b/src/app.module.ts
@@ -76,7 +76,7 @@ if (dashboardServingEnabled && dashboardBuildPresent) {
rootPath: DASHBOARD_DIST,
// Let Nest own these so unknown API/socket routes return real 404s/JSON rather
// than the SPA index.html fallback (Express 5 / path-to-regexp v8 wildcard syntax).
- exclude: ['/api/{*splat}', '/socket.io/{*splat}'],
+ exclude: ['/api/{*splat}', '/socket.io/{*splat}', '/mcp', '/mcp/{*splat}'],
}),
);
}
diff --git a/test/app.e2e-spec.ts b/test/app.e2e-spec.ts
index 53e2d9520..8302843a3 100644
--- a/test/app.e2e-spec.ts
+++ b/test/app.e2e-spec.ts
@@ -61,4 +61,9 @@ describe('App smoke (e2e)', () => {
// Secure default: no scrape token configured → the endpoint must not exist.
return request(app.getHttpServer()).get('/api/metrics').expect(404);
});
+
+ it('POST /mcp returns 404 when MCP_ENABLED is unset', () => {
+ // MCP is off by default; the route must not be mounted, not fall through to the SPA.
+ return request(app.getHttpServer()).post('/mcp').send({ jsonrpc: '2.0', method: 'tools/list', id: 1 }).expect(404);
+ });
});