From ef0a96182a00cd03d325afede09e3fdb0d32b4a4 Mon Sep 17 00:00:00 2001 From: Kacper Date: Sun, 28 Dec 2025 15:49:39 +0100 Subject: [PATCH] fix: remove unreachable else branches in MCP routes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CodeRabbit identified dead code - the else blocks were unreachable since validation ensures serverId or serverConfig is truthy. Simplified to ternary expression. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- apps/server/src/routes/mcp/routes/list-tools.ts | 16 ++++------------ apps/server/src/routes/mcp/routes/test-server.ts | 16 ++++------------ 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/apps/server/src/routes/mcp/routes/list-tools.ts b/apps/server/src/routes/mcp/routes/list-tools.ts index ac1d0e84..d380d8b3 100644 --- a/apps/server/src/routes/mcp/routes/list-tools.ts +++ b/apps/server/src/routes/mcp/routes/list-tools.ts @@ -37,18 +37,10 @@ export function createListToolsHandler(mcpTestService: MCPTestService) { return; } - let result; - if (body.serverId) { - result = await mcpTestService.testServerById(body.serverId); - } else if (body.serverConfig) { - result = await mcpTestService.testServer(body.serverConfig); - } else { - res.status(400).json({ - success: false, - error: 'Invalid request', - }); - return; - } + // At this point, we know at least one of serverId or serverConfig is truthy + const result = body.serverId + ? await mcpTestService.testServerById(body.serverId) + : await mcpTestService.testServer(body.serverConfig!); // Return only tool-related information res.json({ diff --git a/apps/server/src/routes/mcp/routes/test-server.ts b/apps/server/src/routes/mcp/routes/test-server.ts index 8106dff1..2240fafc 100644 --- a/apps/server/src/routes/mcp/routes/test-server.ts +++ b/apps/server/src/routes/mcp/routes/test-server.ts @@ -37,18 +37,10 @@ export function createTestServerHandler(mcpTestService: MCPTestService) { return; } - let result; - if (body.serverId) { - result = await mcpTestService.testServerById(body.serverId); - } else if (body.serverConfig) { - result = await mcpTestService.testServer(body.serverConfig); - } else { - res.status(400).json({ - success: false, - error: 'Invalid request', - }); - return; - } + // At this point, we know at least one of serverId or serverConfig is truthy + const result = body.serverId + ? await mcpTestService.testServerById(body.serverId) + : await mcpTestService.testServer(body.serverConfig!); res.json(result); } catch (error) {