Skip to content

The agent that grows with you

fix(desktop): route the MCP health sweep and command palette through getServers

Teknium9f2ab334c81c
diff --git a/apps/desktop/src/app/command-palette/index.tsx b/apps/desktop/src/app/command-palette/index.tsx
index da4d4f3742b..69b687d5259 100644
--- a/apps/desktop/src/app/command-palette/index.tsx
+++ b/apps/desktop/src/app/command-palette/index.tsx
@@ -56,6 +56,7 @@ import {
Wrench,
Zap
} from '@/lib/icons'
+import { getServers } from '@/lib/mcp-servers'
import { normalize } from '@/lib/text'
import { cn } from '@/lib/utils'
import { resolveVersionStatus } from '@/lib/version-status'
@@ -659,13 +660,9 @@ function CommandPaletteBody({ onExited }: { onExited: () => void }) {
queryFn: () => listAllProfileSessions(200, 0, 'only')
})
- const mcpServers = useMemo(() => {
- const raw = configQuery.data?.mcp_servers
-
- return raw && typeof raw === 'object' && !Array.isArray(raw)
- ? Object.keys(raw as Record<string, unknown>).sort()
- : []
- }, [configQuery.data])
+ // getServers is the shared choke point that also drops malformed (null/
+ // scalar) entries, so the palette never lists a server the MCP tab dropped.
+ const mcpServers = useMemo(() => Object.keys(getServers(configQuery.data ?? null)).sort(), [configQuery.data])
const sessions = useMemo(() => (sessionsQuery.data?.sessions ?? []).map(toSessionEntry), [sessionsQuery.data])
const archivedSessions = useMemo(() => (archivedQuery.data?.sessions ?? []).map(toSessionEntry), [archivedQuery.data])
diff --git a/apps/desktop/src/store/mcp-health.ts b/apps/desktop/src/store/mcp-health.ts
index 243a6eec0f0..0e1dbeb90f7 100644
--- a/apps/desktop/src/store/mcp-health.ts
+++ b/apps/desktop/src/store/mcp-health.ts
@@ -15,6 +15,7 @@
import { getHermesConfigRecord, type McpTestResult, testMcpServer } from '@/hermes'
import { translateNow } from '@/i18n'
import { classifyProbe, freshProbe, probeCache, probeKey } from '@/lib/mcp-probe-cache'
+import { getServers } from '@/lib/mcp-servers'
import { notify } from '@/store/notifications'
import { $activeGatewayProfile, normalizeProfileKey } from '@/store/profile'
import { $gatewayState } from '@/store/session'
@@ -106,10 +107,9 @@ async function sweep(): Promise<void> {
return
}
- const raw = config.mcp_servers
-
- const servers =
- raw && typeof raw === 'object' && !Array.isArray(raw) ? (raw as Record<string, Record<string, unknown>>) : {}
+ // getServers drops non-object entries (a bare `name:` in config.yaml parses
+ // as `null`), so isUrlServer below never reads `.url` off a null entry.
+ const servers = getServers(config)
for (const [name, server] of Object.entries(servers)) {
if (!isUrlServer(server)) {
diff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]
new file mode 100644
index 00000000000..29619e2c53c
--- /dev/null
+++ b/contributors/emails/[email protected]
@@ -0,0 +1 @@
+ignaciochiappero