Context7 Platform -- Up-to-date docs for AI agents
feat: add 404 handler for undefined routes for json responses
enesgules95af65abce4a
diff --git a/src/index.ts b/src/index.tsindex 23d478e2..e8cdc05c 100644--- a/src/index.ts+++ b/src/index.ts@@ -336,6 +336,14 @@ async function main() {res.json({ status: "ok", message: "pong" });});+ // Catch-all 404 handler - must be after all other routes+ app.use((_req: express.Request, res: express.Response) => {+ res.status(404).json({+ error: "not_found",+ message: "Endpoint not found. Use /mcp for MCP protocol communication.",+ });+ });+const startServer = (port: number, maxAttempts = 10) => {const httpServer = app.listen(port, () => {actualPort = port;