Skip to content

Commit 4bb9a8d

Browse files
committed
ui fixes part 1
1 parent 9743a2f commit 4bb9a8d

5 files changed

Lines changed: 356 additions & 791 deletions

File tree

apps/sim/app/api/mcp/workflow-servers/route.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { db } from '@sim/db'
2-
import { workflowMcpServer } from '@sim/db/schema'
3-
import { eq, sql } from 'drizzle-orm'
2+
import { workflowMcpServer, workflowMcpTool } from '@sim/db/schema'
3+
import { eq, inArray, sql } from 'drizzle-orm'
44
import type { NextRequest } from 'next/server'
55
import { createLogger } from '@/lib/logs/console/logger'
66
import { getParsedBody, withMcpAuth } from '@/lib/mcp/middleware'
@@ -38,10 +38,38 @@ export const GET = withMcpAuth('read')(
3838
.from(workflowMcpServer)
3939
.where(eq(workflowMcpServer.workspaceId, workspaceId))
4040

41+
// Fetch all tools for these servers
42+
const serverIds = servers.map((s) => s.id)
43+
const tools =
44+
serverIds.length > 0
45+
? await db
46+
.select({
47+
serverId: workflowMcpTool.serverId,
48+
toolName: workflowMcpTool.toolName,
49+
})
50+
.from(workflowMcpTool)
51+
.where(inArray(workflowMcpTool.serverId, serverIds))
52+
: []
53+
54+
// Group tool names by server
55+
const toolNamesByServer: Record<string, string[]> = {}
56+
for (const tool of tools) {
57+
if (!toolNamesByServer[tool.serverId]) {
58+
toolNamesByServer[tool.serverId] = []
59+
}
60+
toolNamesByServer[tool.serverId].push(tool.toolName)
61+
}
62+
63+
// Attach tool names to servers
64+
const serversWithToolNames = servers.map((server) => ({
65+
...server,
66+
toolNames: toolNamesByServer[server.id] || [],
67+
}))
68+
4169
logger.info(
4270
`[${requestId}] Listed ${servers.length} workflow MCP servers for workspace ${workspaceId}`
4371
)
44-
return createMcpSuccessResponse({ servers })
72+
return createMcpSuccessResponse({ servers: serversWithToolNames })
4573
} catch (error) {
4674
logger.error(`[${requestId}] Error listing workflow MCP servers:`, error)
4775
return createMcpErrorResponse(

0 commit comments

Comments
 (0)