Skip to content

Commit 3fd031c

Browse files
committed
chore(mcp): trim verbose comments
1 parent a91546e commit 3fd031c

3 files changed

Lines changed: 6 additions & 19 deletions

File tree

apps/sim/hooks/mcp/use-mcp-tools.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ export function useMcpTools(workspaceId: string): UseMcpToolsResult {
5555
}))
5656
}, [mcpToolsData])
5757

58-
// Soft refresh: invalidate per-server query entries so React Query refetches
59-
// them, but let the server-side cache decide whether to go live (the per-server
60-
// queryFn always sends refresh=false). For an explicit cache-bypass refresh,
61-
// use `useForceRefreshMcpTools` instead.
58+
// Soft refresh — invalidate per-server entries. For cache-bypass, use `useForceRefreshMcpTools`.
6259
const refreshTools = useCallback(async () => {
6360
if (!workspaceId) {
6461
logger.warn('Cannot refresh tools: no workspaceId provided')

apps/sim/hooks/queries/mcp.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,8 @@ export function useMcpServerTools(workspaceId: string, serverId?: string) {
140140
export function useMcpToolsQuery(workspaceId: string) {
141141
const { data: servers, isLoading: serversLoading } = useMcpServers(workspaceId)
142142

143-
// Filter on (a) enabled (disabled servers would 404 in discover and pollute the
144-
// negative cache), and (b) workspaceId match (useMcpServers keeps the previous
145-
// workspace's data via keepPreviousData, so during a workspace switch we'd
146-
// otherwise spawn discover calls for the wrong workspace's IDs).
143+
// Skip disabled rows (would 404 → negative-cache) and rows from a previous
144+
// workspace (keepPreviousData on useMcpServers).
147145
const serverIds = useMemo(
148146
() =>
149147
servers
@@ -173,9 +171,7 @@ export function useMcpToolsQuery(workspaceId: string) {
173171
let anyServerLoading = false
174172
let firstError: Error | null = null
175173
for (const result of results) {
176-
// Drop stale data when the latest refetch failed — otherwise React Query's
177-
// stale-while-revalidate behavior would surface broken-server tools in the
178-
// aggregate while the per-server card shows an error.
174+
// Drop stale data from servers whose latest refetch errored.
179175
if (result.data && !result.isError) {
180176
tools.push(...result.data)
181177
hasData = true
@@ -185,12 +181,9 @@ export function useMcpToolsQuery(workspaceId: string) {
185181
}
186182
return {
187183
data: tools,
188-
// Stay loading until we have something to render; once any server
189-
// returned, drop the spinner and let slow neighbors fill in.
190184
isLoading: (serversLoading || anyServerLoading) && !hasData,
191185
isFetching: serversLoading || results.some((r) => r.isFetching),
192-
// One dead server must not blank out the workspace — only surface the
193-
// aggregate error when nothing rendered. Per-server errors live in `perServer`.
186+
// Suppress when any healthy server rendered; per-server errors live in `perServer`.
194187
error: hasData ? null : firstError,
195188
perServer: results,
196189
}
@@ -210,7 +203,6 @@ export function useForceRefreshMcpTools() {
210203
return tools
211204
})
212205
)
213-
// Failed servers: invalidate so React Query retries via the server-side negative cache.
214206
results.forEach((result, index) => {
215207
if (result.status === 'rejected') {
216208
const failedServer = servers[index]

apps/sim/lib/mcp/service.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,9 +723,7 @@ class McpService {
723723
await sleep(100)
724724
continue
725725
}
726-
// Drop any stale positive cache so a follow-up cache-respecting call
727-
// doesn't keep returning old tools from a now-broken server. The
728-
// negative cache marker then makes that follow-up fail fast.
726+
// Drop positive cache so a follow-up doesn't return stale tools.
729727
await Promise.allSettled([
730728
this.cacheAdapter
731729
.delete(serverCacheKey(workspaceId, serverId))

0 commit comments

Comments
 (0)