Skip to content

Commit da8ede3

Browse files
committed
improvement(mcp): subscribe settings page to the live push, lean on it over re-probing
The list_changed → SSE push pipeline was already wired end-to-end but only mounted in the workflow-editor tool picker. Subscribe the settings MCP page to the same shared, reference-counted EventSource so tool changes reflect in real time there too — the reference-client model (discover once, refresh on push). With push now active on the settings page, raise MCP_SERVER_TOOLS_STALE_TIME from 30s to 5min (matching the server-side cache TTL) so revisiting the page leans on push + stored state instead of re-probing every connected server. There is no background poll (no refetchInterval) — this only affects refetch-on-visit-if-stale; real changes still arrive instantly via push.
1 parent 93fbf58 commit da8ede3

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

  • apps/sim
    • app/workspace/[workspaceId]/settings/components/mcp
    • hooks/queries

apps/sim/app/workspace/[workspaceId]/settings/components/mcp/mcp.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
useDeleteMcpServer,
4040
useForceRefreshMcpTools,
4141
useMcpServers,
42+
useMcpToolsEvents,
4243
useMcpToolsQuery,
4344
useRefreshMcpServer,
4445
useStoredMcpTools,
@@ -195,6 +196,9 @@ export function MCP() {
195196
} = useMcpServers(workspaceId)
196197
const { data: mcpToolsData = [], toolsStateByServer } = useMcpToolsQuery(workspaceId)
197198
const { data: storedTools = [], refetch: refetchStoredTools } = useStoredMcpTools(workspaceId)
199+
// Real-time refresh via the shared list_changed → SSE push (same subscription the workflow
200+
// editor uses), so tool changes reflect here without re-probing on every visit.
201+
useMcpToolsEvents(workspaceId)
198202
const forceRefreshToolsMutation = useForceRefreshMcpTools()
199203
const forceRefreshTools = forceRefreshToolsMutation.mutate
200204
const createServerMutation = useCreateMcpServer()

apps/sim/hooks/queries/mcp.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ const logger = createLogger('McpQueries')
4242
export type { McpServerStatusConfig, McpTool, StoredMcpTool }
4343

4444
export const MCP_SERVER_LIST_STALE_TIME = 60 * 1000
45-
export const MCP_SERVER_TOOLS_STALE_TIME = 30 * 1000
45+
/**
46+
* Tool discovery is kept fresh by the `list_changed` → SSE push (see `useMcpToolsEvents`),
47+
* so the query only needs a re-probe-on-visit fallback for servers without push. Matches the
48+
* server-side cache TTL (`MCP_CONSTANTS.CACHE_TIMEOUT`) — no reference MCP client re-probes
49+
* more often than its cache; real changes arrive via push regardless of this value.
50+
*/
51+
export const MCP_SERVER_TOOLS_STALE_TIME = 5 * 60 * 1000
4652
export const MCP_STORED_TOOL_LIST_STALE_TIME = 60 * 1000
4753
export const MCP_ALLOWED_DOMAINS_STALE_TIME = 5 * 60 * 1000
4854

0 commit comments

Comments
 (0)