Skip to content

Commit 95af65a

Browse files
committed
feat: add 404 handler for undefined routes for json responses
1 parent c910377 commit 95af65a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,14 @@ async function main() {
336336
res.json({ status: "ok", message: "pong" });
337337
});
338338

339+
// Catch-all 404 handler - must be after all other routes
340+
app.use((_req: express.Request, res: express.Response) => {
341+
res.status(404).json({
342+
error: "not_found",
343+
message: "Endpoint not found. Use /mcp for MCP protocol communication.",
344+
});
345+
});
346+
339347
const startServer = (port: number, maxAttempts = 10) => {
340348
const httpServer = app.listen(port, () => {
341349
actualPort = port;

0 commit comments

Comments
 (0)