The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
chore(desktop): remove the old MCP tab (#119083)
Siddharth Balyanf21e583211f7
diff --git a/apps/desktop/src/app/capabilities/mcp/mcp-avatar.tsx b/apps/desktop/src/app/capabilities/mcp/mcp-avatar.tsxdeleted file mode 100644index 31f6825075c..00000000000--- a/apps/desktop/src/app/capabilities/mcp/mcp-avatar.tsx+++ /dev/null@@ -1,24 +0,0 @@-import { AvatarChip } from '@/components/ui/avatar-chip'-import { brandFor } from '@/lib/mcp-brands'-import { cn } from '@/lib/utils'--import { type ServerStatus, STATUS_DOT } from './mcp-status'--export function McpAvatar({ className, name, status }: { className?: string; name: string; status: ServerStatus }) {- return (- <AvatarChip- brand={brandFor(name)}- className={className}- name={name}- overlay={- <span- aria-hidden- className={cn(- 'absolute -bottom-0.5 -right-0.5 size-2 rounded-full ring-2 ring-(--ui-chat-surface-background)',- STATUS_DOT[status]- )}- />- }- />- )-}diff --git a/apps/desktop/src/app/capabilities/mcp/mcp-doc.ts b/apps/desktop/src/app/capabilities/mcp/mcp-doc.tsindex 62eb2f1763f..625e5655110 100644--- a/apps/desktop/src/app/capabilities/mcp/mcp-doc.ts+++ b/apps/desktop/src/app/capabilities/mcp/mcp-doc.ts@@ -1,4 +1,4 @@-// oxlint-disable-next-line anti-slop/no-shape-in-symbol-names -- `isServerShape` is main's exported name, shared with mcp-tab.tsx; it is bound to a domain name here instead of renaming the export.+// oxlint-disable-next-line anti-slop/no-shape-in-symbol-names -- `isServerShape` is main's exported name; it is bound to a domain name here instead of renaming the export.import { type McpServerEntry, type McpServers, isServerShape as namesAServer, normalizeEntry } from '@/lib/mcp-servers'export const STARTER_ENTRY = { command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem', '/path/to/dir'] }diff --git a/apps/desktop/src/app/capabilities/mcp/mcp-tab.tsx b/apps/desktop/src/app/capabilities/mcp/mcp-tab.tsxdeleted file mode 100644index 719533452a9..00000000000--- a/apps/desktop/src/app/capabilities/mcp/mcp-tab.tsx+++ /dev/null@@ -1,1840 +0,0 @@-import { compactNumber } from '@hermes/shared'-import { useStore } from '@nanostores/react'-import { useQuery } from '@tanstack/react-query'-import { useEffect, useMemo, useRef, useState } from 'react'--import { type CodeEditorApi } from '@/components/chat/code-editor'-import { JsonDocumentEditor } from '@/components/chat/json-document-editor'-import { LogTail } from '@/components/chat/log-tail'-import { PageLoader } from '@/components/page-loader'-import { AvatarChip } from '@/components/ui/avatar-chip'-import { Button } from '@/components/ui/button'-import { Codicon } from '@/components/ui/codicon'-import { ErrorBanner } from '@/components/ui/error-state'-import { Input } from '@/components/ui/input'-import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'-import { Switch } from '@/components/ui/switch'-import { TextTab } from '@/components/ui/text-tab'-import { Textarea } from '@/components/ui/textarea'-import { Tip } from '@/components/ui/tooltip'-import {- getActionStatus,- getLogs,- getMcpCatalog,- getUsageAnalytics,- type HermesGateway,- installMcpCatalogEntry,- type McpCatalogEntry,- type McpTestResult,- type ProfileScope,- profileScopeKey,- saveMcpServers,- testMcpServer-} from '@/hermes'-import { type Translations, useI18n } from '@/i18n'-import { startCompletionPoll } from '@/lib/completion-poll'-import { brandFor } from '@/lib/mcp-brands'-import { estimateServerTokens, serverUsageCount } from '@/lib/mcp-cost'-import { completeMcpDesktopOAuth } from '@/lib/mcp-dashboard-oauth'-import { type McpImportEntry, parseMcpImport } from '@/lib/mcp-import'-import { NEEDS_AUTH_RE, PROBE_TTL_MS, probeCache, probeKey, serverFingerprint } from '@/lib/mcp-probe-cache'-import { getServers, isServerShape, type McpServers, normalizeEntry } from '@/lib/mcp-servers'-import { countEnabledTools, isToolEnabled, toggleToolInServer } from '@/lib/mcp-tool-filter'-import { cn } from '@/lib/utils'-import { notify, notifyError } from '@/store/notifications'-import { $activeGatewayProfile, normalizeProfileKey } from '@/store/profile'-import { $activeSessionId } from '@/store/session'--import { hermesConfigCacheWriter, useHermesConfigRecord } from '../../hooks/use-config-record'-import { useOnProfileSwitch } from '../../hooks/use-on-profile-switch'-import { useProfileSwitchLatch } from '../../hooks/use-profile-switch-latch'-import { DetailPane, ICON_BUTTON, MASTER_DETAIL_WIDE_COLS } from '../../master-detail'-import { PanelAddButton, PanelEmpty } from '../../overlays/panel'-import { prettyName } from '../../settings/helpers'-import { useDeepLinkHighlight } from '../../settings/use-deep-link-highlight'--// The editor always speaks the ecosystem's mcp.json document format — names-// are the JSON keys, transport is inferred from `command` vs `url` — so any-// README's "add this to your mcp.json" snippet pastes verbatim. Storage stays-// the config.yaml `mcp_servers` map (CLI/TUI untouched).-const STARTER_ENTRY = { command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem', '/path/to/dir'] }--const pretty = (value: unknown) => JSON.stringify(value, null, 2)-const wrapDoc = (entries: McpServers) => pretty({ mcpServers: entries })--/** Accepts `{"mcpServers": {...}}` (ecosystem), a bare name→config map, or throws. */-function parseServersDoc(raw: string): McpServers {- const parsed = JSON.parse(raw) as unknown-- if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {- throw new Error('Expected a JSON object')- }-- const doc = parsed as Record<string, unknown>-- if (isServerShape(doc)) {- throw new Error('Wrap the server in {"mcpServers": {"name": …}} so it has a name')- }-- const wrapper = doc.mcpServers ?? doc.mcp_servers-- const map =- wrapper && typeof wrapper === 'object' && !Array.isArray(wrapper) ? (wrapper as McpServers) : (doc as McpServers)-- return Object.fromEntries(Object.entries(map).map(([name, entry]) => [name, normalizeEntry(entry)]))-}--// The runtime gate is `enabled: false` — the same flag `hermes mcp` and the-// agent's MCP loader read.-const serverEnabled = (server: Record<string, unknown>) => server.enabled !== false--// Shared cache for the Nous-approved catalog — feeds both description enrichment-// and the Catalog install view; invalidated after an install.-const MCP_CATALOG_KEY = ['mcp-catalog'] as const--type Probe = McpTestResult | 'probing'--// Per-server cost/usage overlay inputs: `tokens` is the approximate per-call-// schema cost from the probe (null = no estimate — older backend or no probe-// yet), `uses` is the 30-day analytics call count (null = analytics-// unavailable, so usage is simply omitted).-interface ServerCost {- tokens: null | number- uses: null | number-}--// 30-day per-tool call counts for the MCP fleet — same shape and TTL rules as-// the Toolsets tab's toolCallsCache (skills/index.tsx), but a 30-day window-// keyed by the Capabilities scope profile. Purely cosmetic: a failed analytics-// fetch caches nothing and the overlay omits usage.-const MCP_USAGE_TTL_MS = 10 * 60_000-const mcpUsageCache = new Map<string, { at: number; value: Record<string, number> }>()--async function loadMcpUsage(scopeKey: string, scopeProfile: ProfileScope): Promise<null | Record<string, number>> {- const cached = mcpUsageCache.get(scopeKey)-- if (cached && Date.now() - cached.at < MCP_USAGE_TTL_MS) {- return cached.value- }-- try {- const analytics = await getUsageAnalytics(30, scopeProfile)- const value = Object.fromEntries((analytics.tools ?? []).map(entry => [entry.tool, entry.count]))- mcpUsageCache.set(scopeKey, { at: Date.now(), value })-- return value- } catch {- // Analytics unavailable — degrade to "no usage shown", never an error UI.- return null- }-}--type ServerStatus = 'off' | 'probing' | 'ok' | 'needs-auth' | 'error' | 'unknown'--function statusOf(server: Record<string, unknown>, probe: Probe | undefined): ServerStatus {- if (!serverEnabled(server)) {- return 'off'- }-- if (probe === 'probing') {- return 'probing'- }-- if (!probe) {- return 'unknown'- }-- if (probe.ok) {- return 'ok'- }-- return NEEDS_AUTH_RE.test(probe.error ?? '') ? 'needs-auth' : 'error'-}--const STATUS_DOT: Record<ServerStatus, string> = {- ok: 'bg-emerald-500',- error: 'bg-red-500',- 'needs-auth': 'bg-amber-500',- probing: 'animate-pulse bg-foreground/40',- off: 'bg-foreground/20',- unknown: 'bg-foreground/20'-}--// "12 tools enabled" / "25 tools, 1 prompts, 103 resources enabled" — only-// the capabilities the server actually has. When a `server` config is passed,-// the tool count reflects the per-tool include/exclude filter (what's actually-// registered), not the raw discovered count. The optional `cost` appends the-// overlay — "…, ~4.2k tok, 3 uses/30d" — with each half omitted when unknown.-function capabilitySummary(- m: Translations['settings']['mcp'],- probe: McpTestResult,- server?: Record<string, unknown>,- cost?: ServerCost-): string {- const toolCount = server- ? countEnabledTools(- server,- probe.tools.map(tool => tool.name)- )- : probe.tools.length-- const parts = [m.capabilitySummary(toolCount, probe.prompts ?? 0, probe.resources ?? 0)]-- if (cost && cost.tokens !== null && cost.tokens > 0) {- parts.push(m.costTokens(compactNumber(cost.tokens)))- }-- if (cost && cost.uses !== null) {- parts.push(m.usage30d(compactNumber(cost.uses)))- }-- return parts.join(', ')-}--function statusLine(- m: Translations['settings']['mcp'],- status: ServerStatus,- probe: Probe | undefined,- server?: Record<string, unknown>,- cost?: ServerCost-): string {- switch (status) {- case 'ok':- return capabilitySummary(m, probe as McpTestResult, server, cost)-- case 'probing':- return m.statusConnecting-- case 'needs-auth':- return m.statusNeedsAuth-- case 'error':- return m.statusError-- case 'off':- return m.statusOff-- default:- return ''- }-}--// ----------------------------------------------------------------------------// Cursor → server-block mapping. A tolerant character walker (not JSON.parse —-// it must work mid-edit) that finds each server's key+object range inside the-// mcpServers container, so the editor cursor selects a server and the block-// can be highlighted.-// -----------------------------------------------------------------------------interface ServerBlock {- from: number- name: string- to: number-}--function scanServerBlocks(text: string): ServerBlock[] {- const skipString = (index: number): number => {- let i = index + 1-- while (i < text.length) {- if (text[i] === '\\') {- i += 2- } else if (text[i] === '"') {- return i + 1- } else {- i++- }- }-- return i- }-- // Container: the object after "mcpServers"/"mcp_servers", else the doc root.- let start = -1- const wrapper = /"mcpServers"|"mcp_servers"/.exec(text)-- if (wrapper) {- let i = wrapper.index + wrapper[0].length-- while (i < text.length && text[i] !== '{') {- i++- }-- start = i- } else {- start = text.indexOf('{')- }-- if (start < 0 || text[start] !== '{') {- return []- }-- const blocks: ServerBlock[] = []- let i = start + 1-- while (i < text.length) {- const ch = text[i]-- if (ch === '}') {- break- }-- if (ch !== '"') {- i++-- continue- }-- const keyStart = i- const keyEnd = skipString(i)- const name = text.slice(keyStart + 1, keyEnd - 1)- i = keyEnd-- while (i < text.length && text[i] !== ':') {- i++- }-- i++-- while (i < text.length && /\s/.test(text[i])) {- i++- }-- if (text[i] === '{') {- let depth = 0- let j = i-- while (j < text.length) {- const c = text[j]-- if (c === '"') {- j = skipString(j)-- continue- }-- if (c === '{') {- depth++- } else if (c === '}') {- depth---- if (depth === 0) {- j++-- break- }- }-- j++- }-- blocks.push({ from: keyStart, name, to: j })- i = j- } else {- // Non-object value — skip to the next sibling.- while (i < text.length && text[i] !== ',' && text[i] !== '}') {- if (text[i] === '"') {- i = skipString(i)-- continue- }-- i++- }- }- }-- return blocks-}--export function McpTab({ gateway, profile }: { gateway: HermesGateway | null; profile?: ProfileScope }) {- const { t } = useI18n()- const m = t.settings.mcp- const activeSessionId = useStore($activeSessionId)-- // The profile this tab configures: the Capabilities profile-scope selector's- // choice (`profile`) when set, otherwise the app-wide active profile. Every- // fetch/save below is scoped to it, and it keys the config/catalog/probe- // caches so switching the selector refetches and never shows another- // profile's servers (AGENTS.md scope-in-key). When no override is passed this- // resolves to $activeGatewayProfile, so behavior is identical to before.- const appProfile = useStore($activeGatewayProfile)- const scopeProfileKey = profile != null ? profileScopeKey(profile) : normalizeProfileKey(appProfile)-- // Shared config cache (see use-config-record): revisiting the tab paints the- // cached record instantly; mutations write through `setConfig` and stay- // visible to the other settings surfaces.- const {- data: config,- isLoading: configLoading,- isError: configFailed,- error: configError,- refetch: refetchConfig,- dataUpdatedAt: configUpdatedAt,- errorUpdatedAt: configErroredAt- } = useHermesConfigRecord(profile)-- const setConfig = hermesConfigCacheWriter(profile)-- // True from a profile switch until the config query resettles for the new- // profile. Until then `config` (and thus `servers`) still holds profile A's- // data, so any persist would write A's server list into B — block mutations.- const { arm: armProfileLatch, pending: profilePending } = useProfileSwitchLatch({- dataUpdatedAt: configUpdatedAt,- errorUpdatedAt: configErroredAt- })-- const [saving, setSaving] = useState(false)- const [probes, setProbes] = useState<Record<string, Probe>>({})- const probesRef = useRef(probes)- probesRef.current = probes-- // 30-day per-tool call counts (registry names). null = analytics unavailable- // or not loaded yet — the cost overlay then omits usage entirely.- const [toolCalls30d, setToolCalls30d] = useState<null | Record<string, number>>(null)-- // Blocks the browser until an OAuth flow lands a token; also reset on profile- // switch, so declared up here alongside the other per-profile view state.- const [authing, setAuthing] = useState<null | string>(null)-- // Master document draft. `docVersion` remounts the editor when the draft is- // regenerated programmatically (list-side mutations); `dirty` guards user- // edits from being clobbered by those regenerations.- const [draft, setDraft] = useState('')- const [dirty, setDirty] = useState(false)- const [docVersion, setDocVersion] = useState(0)- const [logSource, setLogSource] = useState<'stdio' | 'agent'>('stdio')-- // Selection IS the editor cursor: whichever server block contains it is the- // configured server on the left. Cursor outside every block → the list.- const editorApi = useRef<CodeEditorApi | null>(null)- const [cursor, setCursor] = useState(0)- const blocks = useMemo(() => scanServerBlocks(draft), [draft])-- const activeBlock = useMemo(- () => blocks.find(block => cursor >= block.from && cursor <= block.to) ?? null,- [blocks, cursor]- )-- const selected = activeBlock?.name ?? null-- const focusServer = (name: string) => {- const block = blocks.find(b => b.name === name)-- if (block) {- // Land just inside the key so the block claims the cursor.- editorApi.current?.setCursor(block.from + 1)- setCursor(block.from + 1)- }- }-- const servers = useMemo(() => getServers(config ?? null), [config])-- // Config/document order, not alphabetical — the list mirrors mcp.json.- const names = useMemo(() => Object.keys(servers), [servers])-- // Key by the SCOPED profile — installed/enabled badges are per-profile, so- // sharing one cache across profiles would flash the previous profile's state- // on switch. When no selector override is set this is the active profile,- // identical to before.- const catalogQuery = useQuery({- queryKey: [...MCP_CATALOG_KEY, scopeProfileKey],- queryFn: () => getMcpCatalog(profile ?? undefined),- staleTime: 5 * 60_000- })-- const catalog = useMemo(() => catalogQuery.data?.entries ?? [], [catalogQuery.data])-- // The catalog SECTION of the unified list only offers entries that aren't- // already configured — installed servers appear once, in the fleet list- // above, with live status. Match by catalog `installed` flag or a config- // entry under the same name (covers a just-saved doc the catalog refetch- // hasn't caught up with yet).- const availableCatalog = useMemo(- () => catalog.filter((entry: McpCatalogEntry) => !entry.installed && !(entry.name in servers)),- [catalog, servers]- )-- const descriptionFor = (serverName: string, server: Record<string, unknown>): null | string => {- const lower = serverName.toLowerCase()-- const match = catalog.find(- entry =>- entry.name.toLowerCase() === lower ||- (entry.url && entry.url === server.url) ||- (entry.command && entry.command === server.command)- )-- return match?.description ?? null- }-- const resetDraft = (entries: McpServers) => {- setDraft(wrapDoc(entries))- setDirty(false)- setDocVersion(version => version + 1)- }-- // Mirror a list-side mutation into a dirty draft without losing the user's- // other edits. Unparseable drafts are left alone — save resolves the race.- const patchDraft = (mutate: (doc: McpServers) => McpServers) => {- try {- setDraft(wrapDoc(mutate(parseServersDoc(draft))))- setDocVersion(version => version + 1)- } catch {- // Draft is mid-edit / invalid JSON; the user's text wins until save.- }- }-- // Seed the editor draft from config exactly once, the first time it lands.- // Background refetches thereafter update the list but must not clobber an- // in-progress edit — the draft is the user's until they save or reset.- const draftSeeded = useRef(false)-- // eslint-disable-next-line no-restricted-syntax -- legitimate non-atom ref write (see eslint rule comment)- useEffect(() => {- // profilePending: config still holds the PREVIOUS profile's record right- // after a switch — seeding from it would latch the wrong profile's doc.- if (!config || profilePending) {- return- }-- if (!draftSeeded.current) {- draftSeeded.current = true- resetDraft(getServers(config))-- return- }-- if (dirty || names.length === 0) {- return- }-- // Heal the early-boot race: the first config snapshot can land before the- // backend has mcp_servers assembled, seeding (and latching) an empty doc- // while later refetches fill the list — saving would then wipe the real- // servers. A PRISTINE empty draft reseeds when servers arrive; any user- // edit (dirty) still always wins.- try {- if (Object.keys(parseServersDoc(draft)).length === 0) {- resetDraft(servers)- }- } catch {- // Mid-edit / invalid JSON — the user's text wins.- }- }, [config, dirty, draft, names, profilePending, servers])-- // Bumped on every profile switch. Async probe/auth completions capture the- // epoch at call time and bail if it changed, so a slow profile-A request can't- // write its result into profile B's state after the user switched.- const profileEpoch = useRef(0)-- // Scoped Skills tabs remount when their owner changes; stop the old native- // OAuth waiter even when no app-wide profile-switch event is emitted.- useEffect(- () => () => {- profileEpoch.current += 1- },- [scopeProfileKey]- )-- // A profile switch invalidates the config query (see store/profile.ts), which- // refetches the new backend's mcp.json. Reset ALL per-profile view state — the- // draft (incl. a dirty one, so profile A's edits can't be saved into B), its- // seed latch, probes, and cursor — so everything reseeds for the new profile.- // The probe cache is already profile-keyed, so this just forces a re-probe.- useOnProfileSwitch(() => {- profileEpoch.current += 1- draftSeeded.current = false- setProbes({})- setToolCalls30d(null)- setCursor(0)- setAuthing(null)- setDirty(false)- setDraft('')- setDocVersion(version => version + 1)- // Mark stale until the config query replaces profile A's data — guards- // sidebar mutations from persisting A's server list into B mid-refetch.- // The latch releases on a fresh success OR a fresh failure, so a failed- // refetch surfaces the retry UI instead of leaving mutations no-op forever.- armProfileLatch()- })-- useDeepLinkHighlight({- block: 'nearest',- elementId: serverName => `mcp-server-${serverName}`,- onResolve: focusServer,- param: 'server',- ready: serverName => blocks.some(block => block.name === serverName)- })-- const runProbe = async (serverName: string) => {- const epoch = profileEpoch.current- const key = probeKey(serverName, servers[serverName], scopeProfileKey)- setProbes(current => ({ ...current, [serverName]: 'probing' }))-- try {- const result = await testMcpServer(serverName, profile ?? undefined)-- // Drop the result if the profile changed mid-probe — it belongs to A.- if (profileEpoch.current !== epoch) {- return- }-- probeCache.set(key, { at: Date.now(), result })- setProbes(current => ({ ...current, [serverName]: result }))- } catch (err) {- if (profileEpoch.current !== epoch) {- return- }-- const result = { ok: false, error: err instanceof Error ? err.message : String(err), tools: [] }- probeCache.set(key, { at: Date.now(), result })- setProbes(current => ({ ...current, [serverName]: result }))- }- }-- // First-class OAuth: opens the system browser, blocks until the flow lands a- // token (verified on disk — a friendly tools/list is not proof), then the- // auth result doubles as the probe (it carries the tool list).- const authenticate = async (serverName: string) => {- const epoch = profileEpoch.current- setAuthing(serverName)- setProbes(current => ({ ...current, [serverName]: 'probing' }))-- try {- const flow = await completeMcpDesktopOAuth({- serverName,- profile,- cancelled: () => profileEpoch.current !== epoch- })-- const result: McpTestResult = { ok: true, tools: flow.tools ?? [] }-- // Bail if the user switched profiles mid-flow — this result is profile A's.- if (profileEpoch.current !== epoch) {- return- }-- setProbes(current => ({ ...current, [serverName]: result }))- // Cache under the POST-auth fingerprint (auth: oauth) on success — that's- // the config the mount effect will read back, so it hits this entry.- const probedConfig = result.ok ? { ...servers[serverName], auth: 'oauth' } : servers[serverName]- probeCache.set(probeKey(serverName, probedConfig, scopeProfileKey), { at: Date.now(), result })-- if (result.ok) {- // The endpoint persisted `auth: oauth` — mirror it locally.- const nextServers = { ...servers, [serverName]: { ...servers[serverName], auth: 'oauth' } }- setConfig(current => (current ? { ...current, mcp_servers: nextServers } : current))-- // Mirror `auth: oauth` into the editor too. If we only reset a clean- // draft, a dirty draft keeps the pre-auth text and the next Save would- // drop the freshly-persisted auth field — so patch the dirty draft in- // place instead of clobbering the user's other edits.- if (dirty) {- patchDraft(doc => (doc[serverName] ? { ...doc, [serverName]: { ...doc[serverName], auth: 'oauth' } } : doc))- } else {- resetDraft(nextServers)- }-- notify({- kind: 'success',- title: m.authenticatedTitle,- message: m.authenticatedMessage(serverName, result.tools.length)- })- void silentReload()- } else if (result.error) {- notifyError(new Error(result.error), serverName)- }- } catch (err) {- if (profileEpoch.current !== epoch) {- return- }-- setProbes(current => ({- ...current,- [serverName]: { ok: false, error: err instanceof Error ? err.message : String(err), tools: [] }- }))- notifyError(err, serverName)- } finally {- if (profileEpoch.current === epoch) {- setAuthing(null)- }- }- }-- // It should just know: probe enabled servers as config arrives — but through- // the cache, so revisiting the page doesn't respawn/reconnect the fleet.- useEffect(() => {- for (const [serverName, server] of Object.entries(servers)) {- if (!serverEnabled(server) || probesRef.current[serverName] !== undefined) {- continue- }-- const cached = probeCache.get(probeKey(serverName, server, scopeProfileKey))-- if (cached && Date.now() - cached.at < PROBE_TTL_MS) {- setProbes(current => ({ ...current, [serverName]: cached.result }))- } else {- void runProbe(serverName)- }- }- // Re-run only when the server set changes; runProbe is recreated every- // render and adding it would re-probe the fleet on every keystroke.- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [servers])-- // Cosmetic 30-day usage counts for the cost overlay — cached module-wide per- // scope profile, epoch-guarded like the probes so a slow profile-A fetch- // can't paint into profile B.- useEffect(() => {- const epoch = profileEpoch.current-- void loadMcpUsage(scopeProfileKey, profile ?? appProfile ?? null).then(value => {- if (profileEpoch.current === epoch) {- setToolCalls30d(value)- }- })- }, [scopeProfileKey, profile, appProfile])-- // Overlay inputs for one server: token estimate from its (successful) probe,- // 30-day uses from analytics. Both halves degrade to null independently.- const costFor = (serverName: string, server: Record<string, unknown>): ServerCost => {- const probe = probes[serverName]-- return {- tokens: probe && probe !== 'probing' && probe.ok ? estimateServerTokens(server, probe.tools) : null,- uses: toolCalls30d ? serverUsageCount(serverName, toolCalls30d) : null- }- }-- // Config writes reach live sessions immediately — no manual "Reload MCP".- const silentReload = async () => {- if (!gateway) {- return- }-- try {- await gateway.request('reload.mcp', { confirm: true, session_id: activeSessionId ?? undefined })- } catch (err) {- notifyError(err, m.reloadFailed)- }- }-- // Whole-map replace (NOT saveHermesConfig, which deep-merges and so can never- // delete a server, drop `enabled: false`, or remove a nested field). Only- // after the replace lands do we write the cache through + reload live sessions.- // Returns false when the profile switched mid-save: the write hit profile A's- // backend (correct), but the client-side cache/editor now belong to B, so the- // caller must skip its post-await writes.- const persist = async (nextServers: McpServers): Promise<boolean> => {- const epoch = profileEpoch.current- await saveMcpServers(nextServers, profile ?? undefined)-- if (profileEpoch.current !== epoch) {- return false- }-- setConfig(current => ({ ...current, mcp_servers: nextServers }))- void silentReload()-- return true- }-- // A catalog install wrote a new server into config.yaml on the backend —- // refresh the catalog (installed state) and the config, then RECONCILE THE- // EDITOR DRAFT with the fresh servers. Without this a dirty draft (or even a- // clean one the seed never refreshes) would omit the new server, and the next- // whole-map Save would silently drop it.- const onCatalogInstalled = async () => {- void catalogQuery.refetch()- const { data } = await refetchConfig()- const nextServers = getServers(data ?? null)-- if (dirty) {- // Keep the user's in-progress edits (doc wins), add any server the install- // introduced that the draft doesn't have yet.- patchDraft(doc => ({ ...nextServers, ...doc }))- } else {- resetDraft(nextServers)- }-- void silentReload()- }-- const withEnabled = (server: Record<string, unknown>, enabled: boolean) => {- const next = { ...server }-- if (enabled) {- delete next.enabled- } else {- next.enabled = false- }-- return next- }-- const setServerEnabled = async (serverName: string, enabled: boolean) => {- if (profilePending) {- return- }-- const next = withEnabled(servers[serverName], enabled)-- try {- if (!(await persist({ ...servers, [serverName]: next }))) {- return- }-- if (dirty) {- patchDraft(doc => (doc[serverName] ? { ...doc, [serverName]: withEnabled(doc[serverName], enabled) } : doc))- } else {- resetDraft({ ...servers, [serverName]: next })- }-- if (enabled) {- void runProbe(serverName)- }- } catch (err) {- notifyError(err, m.saveFailed)- }- }-- // Per-tool gating writes the server's `tools.include`/`tools.exclude` and- // persists like any other config change (immediate reload of live sessions).- // The probe still lists every discovered tool; the filter decides which ones- // the agent actually registers.- const toggleTool = async (serverName: string, toolName: string) => {- const base = servers[serverName]-- if (!base || profilePending) {- return- }-- const next = toggleToolInServer(base, toolName)-- try {- if (!(await persist({ ...servers, [serverName]: next }))) {- return- }-- if (dirty) {- patchDraft(doc =>- doc[serverName] ? { ...doc, [serverName]: toggleToolInServer(doc[serverName], toolName) } : doc- )- } else {- resetDraft({ ...servers, [serverName]: next })- }- } catch (err) {- notifyError(err, m.saveFailed)- }- }-- const removeServer = async (serverName: string) => {- if (profilePending) {- return- }-- setSaving(true)-- try {- const next = { ...servers }- delete next[serverName]-- if (!(await persist(next))) {- return- }-- if (dirty) {- patchDraft(doc => {- const patched = { ...doc }- delete patched[serverName]-- return patched- })- } else {- resetDraft(next)- }-- setCursor(0)- } catch (err) {- notifyError(err, m.removeFailed)- } finally {- setSaving(false)- }- }-- // "+" seeds a starter entry into the document (unique key) and marks it- // dirty — naming happens in the editor, like every other mcp.json.- const addServer = () => {- if (profilePending) {- return- }-- let base: McpServers-- try {- base = parseServersDoc(draft)- } catch {- base = { ...servers }- }-- let key = 'my-server'-- for (let i = 2; key in base; i++) {- key = `my-server-${i}`- }-- const nextDraft = wrapDoc({ ...base, [key]: STARTER_ENTRY })- setDraft(nextDraft)- setDirty(true)- setDocVersion(version => version + 1)-- // Focus the fresh block once the editor remounts with the new doc.- const from = nextDraft.indexOf(`"${key}"`)-- if (from >= 0) {- requestAnimationFrame(() => {- editorApi.current?.setCursor(from + 1)- setCursor(from + 1)- })- }- }-- // Paste-anything import: merge parsed entries into the draft exactly like- // addServer seeds its starter — dirty draft, unique keys, focus the first- // new block. Saving stays an explicit step, so the user can fix placeholder- // env values (YOUR_KEY, …) in the editor first.- const importServers = (entries: McpImportEntry[]) => {- if (profilePending || entries.length === 0) {- return- }-- let base: McpServers-- try {- base = parseServersDoc(draft)- } catch {- base = { ...servers }- }-- let firstKey: null | string = null-- for (const entry of entries) {- let key = entry.name-- for (let i = 2; key in base; i++) {- key = `${entry.name}-${i}`- }-- base = { ...base, [key]: entry.config }- firstKey ??= key- }-- const nextDraft = wrapDoc(base)- setDraft(nextDraft)- setDirty(true)- setDocVersion(version => version + 1)-- if (firstKey) {- const from = nextDraft.indexOf(`"${firstKey}"`)-- if (from >= 0) {- requestAnimationFrame(() => {- editorApi.current?.setCursor(from + 1)- setCursor(from + 1)- })- }- }- }-- const saveDoc = async () => {- if (profilePending) {- return- }-- let entries: McpServers-- try {- entries = parseServersDoc(draft)- } catch (err) {- notifyError(err, m.invalidJson)-- return- }-- setSaving(true)-- const prevServers = servers-- try {- if (!(await persist(entries))) {- return- }-- resetDraft(entries)- // Keep only probes for servers that survived AND kept the same config;- // removed OR edited entries drop their probe so the mount effect re-probes- // the new shape (the cache also misses on the changed fingerprint).- setProbes(current =>- Object.fromEntries(- Object.entries(current).filter(- ([name]) =>- name in entries && serverFingerprint(entries[name]) === serverFingerprint(prevServers[name] ?? {})- )- )- )- notify({ kind: 'success', title: m.savedTitle, message: m.savedMessage('mcp.json') })- } catch (err) {- notifyError(err, m.saveFailed)- } finally {- setSaving(false)- }- }-- // Cached data paints instantly; a spinner only ever shows on the first-ever- // load, and a failed load gets a real retry — never a silent blank pane.- if (configFailed && !config) {- return (- <div className="flex h-full min-h-0 flex-1 items-center justify-center p-6">- <ErrorBanner className="max-w-sm">- <span className="flex flex-col gap-2">- {configError instanceof Error ? configError.message : m.failedLoad}- <Button className="self-start" onClick={() => void refetchConfig()} size="xs" variant="text">- {m.reload}- </Button>- </span>- </ErrorBanner>- </div>- )- }-- if (!config) {- return <PageLoader className="min-h-24" label={configLoading ? m.loading : t.skills.loading} />- }-- // Selection may reference an unsaved block (freshly pasted) — fall back to- // the draft's parsed entry so the config pane can still describe it.- const savedEntry = selected ? servers[selected] : undefined-- const draftEntry = (() => {- if (!selected || savedEntry) {- return undefined- }-- try {- return parseServersDoc(draft)[selected]- } catch {- return undefined- }- })()-- const activeEntry = savedEntry ?? draftEntry-- return (- <div className={cn('grid h-full min-h-0 grid-cols-1', MASTER_DETAIL_WIDE_COLS)}>- {/* LEFT: the focused block's server config, or the unified fleet+catalog list. */}- <aside className="flex min-h-0 flex-col overflow-hidden border-r border-(--ui-stroke-quaternary)">- {selected && activeEntry ? (- <ServerConfig- authing={authing === selected}- cost={costFor(selected, activeEntry)}- description={descriptionFor(selected, activeEntry)}- entry={activeEntry}- name={selected}- onAuthenticate={() => void authenticate(selected)}- onBack={() => setCursor(0)}- onProbe={() => void runProbe(selected)}- onRemove={() => void removeServer(selected)}- onToggle={checked => void setServerEnabled(selected, checked)}- onToggleTool={toolName => void toggleTool(selected, toolName)}- probe={probes[selected]}- saved={savedEntry !== undefined}- saving={saving}- />- ) : (- <div className="flex min-h-0 flex-1 flex-col p-2">- <div className="min-h-0 flex-1 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]">- {/* ONE coherent column: the configured fleet on top, the- Nous-approved catalog below it. Installed entries live in the- fleet list (with live status), so the catalog section only- offers what's NOT installed yet — no duplicate rows, no tab- flipping to find the install button. */}- {/* Geometry mirrors ListStrip (mb-1 h-6 pl-2) so this header- lands on the exact line the sort link occupies in the- Skills/Tools views. */}- <div className="mb-1 flex h-6 shrink-0 items-center pl-2 pr-1">- <span className="flex-1 text-[0.72rem] font-medium text-(--ui-text-tertiary)">{m.tabServers}</span>- <McpImportButton disabled={profilePending} onImport={importServers} />- </div>- {names.length === 0 ? (- <PanelEmpty- action={- <Button onClick={addServer} size="sm">- {m.newServer}- </Button>- }- description={m.emptyDesc}- icon="plug"- title={m.emptyTitle}- />- ) : (- <>- {names.map(serverName => {- const server = servers[serverName]- const status = statusOf(server, probes[serverName])- const cost = costFor(serverName, server)-- return (- <McpRow- active={false}- busy={saving}- enabled={serverEnabled(server)}- key={serverName}- name={serverName}- onProbe={() => void runProbe(serverName)}- onRemove={() => void removeServer(serverName)}- onSelect={() => focusServer(serverName)}- onToggle={checked => void setServerEnabled(serverName, checked)}- status={status}- statusText={statusLine(m, status, probes[serverName], server, cost)}- unused={- serverEnabled(server) &&- status === 'ok' &&- cost.tokens !== null &&- cost.tokens > 0 &&- cost.uses === 0- }- />- )- })}- <PanelAddButton label={m.newServer} onClick={addServer} />- </>- )}- {(catalogQuery.isLoading || availableCatalog.length > 0) && (- <>- <div className="mb-1 mt-3 flex h-6 shrink-0 items-center border-t border-(--ui-stroke-quaternary) pl-2 pr-1 pt-2">- <span className="text-[0.72rem] font-medium text-(--ui-text-tertiary)">{m.tabCatalog}</span>- </div>- <McpCatalog- entries={availableCatalog}- loading={catalogQuery.isLoading}- onInstalled={onCatalogInstalled}- profile={profile}- />- </>- )}- </div>- </div>- )}- </aside>-- {/* RIGHT: the mcp.json editor, logs hard-pinned below. */}- <main className="flex min-h-0 flex-col overflow-hidden">- <JsonDocumentEditor- apiRef={editorApi}- disabled={saving}- filePath="mcp.json"- header={- <>- mcp.json- {dirty && <span aria-hidden className="size-1.5 rounded-full bg-current/60" />}- </>- }- highlight={activeBlock ? { from: activeBlock.from, to: activeBlock.to } : null}- initialValue={draft}- onChange={next => {- setDraft(next)- setDirty(true)- }}- onCursorChange={setCursor}- onFormatJsonError={error => notifyError(new Error(error), m.invalidJson)}- onSave={() => void saveDoc()}- remountKey={docVersion}- trailing={- <Button disabled={saving || !dirty} onClick={() => void saveDoc()} size="xs">- {saving ? t.common.saving : t.common.save}- </Button>- }- />- <DetailPane- actions={- <span className="flex items-center gap-1.5">- {(['stdio', 'agent'] as const).map(kind => (- <TextTab- active={logSource === kind}- className="h-5 px-0.5 text-[0.65rem]"- key={kind}- onClick={() => setLogSource(kind)}- >- {kind}- </TextTab>- ))}- </span>- }- defaultHeight={176}- id="mcp-logs"- title={- <span className="text-[0.68rem] font-normal text-muted-foreground/60">- {selected && savedEntry ? selected : m.allServers}- </span>- }- >- <McpLogs emptyLabel={m.noOutput} server={selected && savedEntry ? selected : null} source={logSource} />- </DetailPane>- </main>- </div>- )-}--// ----------------------------------------------------------------------------// Left column: one server's config (mirrors the block under the cursor).-// -----------------------------------------------------------------------------function ServerConfig({- authing,- cost,- description,- entry,- name,- onAuthenticate,- onBack,- onProbe,- onRemove,- onToggle,- onToggleTool,- probe,- saved,- saving-}: {- authing: boolean- cost?: ServerCost- description: null | string- entry: Record<string, unknown>- name: string- onAuthenticate: () => void- onBack: () => void- onProbe: () => void- onRemove: () => void- onToggle: (checked: boolean) => void- onToggleTool: (toolName: string) => void- probe: Probe | undefined- saved: boolean- saving: boolean-}) {- const { t } = useI18n()- const m = t.settings.mcp- const status = statusOf(entry, probe)-- // OAuth is only offered to servers that are actually OAuth-shaped. A server- // with `headers` uses API-key/bearer auth — a 401 there means a bad key, NOT- // "log in with OAuth"; routing it through the browser flow would wrongly- // rewrite its config to `auth: oauth`. So: explicit `auth: oauth` can re-auth- // on failure; an auth-less HTTP server may try OAuth on a 401; header servers- // never do.- const hasHeaderAuth = !!entry.headers && typeof entry.headers === 'object'-- const canAuth =- typeof entry.url === 'string' &&- !hasHeaderAuth &&- (entry.auth === 'oauth' ? status === 'needs-auth' || status === 'error' : !entry.auth && status === 'needs-auth')-- const summary = probe && probe !== 'probing' && probe.ok ? capabilitySummary(m, probe, entry, cost) : null-- return (- // p-2 matches the list view's container so flipping list ⇄ config keeps- // content anchored at the same origin.- <div className="min-h-0 flex-1 overflow-y-auto overscroll-contain p-2 [scrollbar-gutter:stable]">- {/* Geometry cloned from McpRow so nothing jumps when flipping list ⇄- config: items-start with per-element top margins that reproduce the- row's h-11 centering exactly (h-5 controls → mt-3, size-6 avatar →- mt-2.5, h-4 switch → mt-3.5) no matter how tall the text column gets. */}- <div className="flex items-start gap-2 pr-1.5">- <Tip label={m.allServers}>- <Button- aria-label={m.allServers}- className={cn('mt-3', ICON_BUTTON)}- onClick={onBack}- size="icon"- variant="ghost"- >- <Codicon name="chevron-left" size="0.8125rem" />- </Button>- </Tip>- <McpAvatar className="mt-2.5" name={name} status={status} />- <div className="min-w-0 flex-1 pt-1">- <h3 className="min-w-0 truncate text-[0.9375rem] font-semibold tracking-tight">{prettyName(name)}</h3>- <p className="mt-0.5 truncate text-[0.68rem] text-(--ui-text-tertiary)">- {typeof entry.url === 'string' ? entry.url : [entry.command, ...((entry.args as string[]) ?? [])].join(' ')}- </p>- {summary && <p className="mt-0.5 text-[0.68rem] text-(--ui-text-tertiary)">{summary}</p>}- </div>- {saved && (- // Direct row children (no wrapper): the icons↔switch gap must be the- // row's own gap-2, byte-identical to McpRow.- <>- <ServerIconActions- className="mt-3"- onProbe={onProbe}- onRemove={onRemove}- probing={probe === 'probing'}- saving={saving}- />- <ServerSwitch- className="mt-3.5"- disabled={saving}- enabled={serverEnabled(entry)}- name={name}- onToggle={onToggle}- />- </>- )}- </div>-- {description && (- <p className="mt-2 text-[length:var(--conversation-caption-font-size)] leading-(--conversation-caption-line-height) text-(--ui-text-tertiary)">- {description}- </p>- )}-- {canAuth && saved && (- <div className="mt-3 flex justify-end">- <Button disabled={authing} onClick={onAuthenticate} size="xs">- {authing ? m.waitingForBrowser : m.authenticate}- </Button>- </div>- )}- {!saved && <p className="mt-3 text-[0.68rem] text-muted-foreground/60">{m.unsavedConnect}</p>}-- {status === 'probing' && <PageLoader className="min-h-24" label={t.skills.loading} />}-- {/* No inline error dump — the status dot/line says "Error"/"Needs- authentication", and the actual failure lands in the logs pane below- (and the console). A big red block here just shouts the same thing. */}-- {probe && probe !== 'probing' && probe.ok && probe.tools.length > 0 && (- <div className="mt-3 flex flex-wrap gap-1">- {/* Chip = a discovered tool; click to include/exclude it (struck- through when excluded, so it won't register). The probe always- lists every tool regardless of the filter. */}- {probe.tools.map(tool => {- const on = isToolEnabled(entry, tool.name)-- return (- <button- aria-pressed={on}- className={cn(- 'rounded-md px-1.5 py-0.5 font-mono text-[0.65rem] text-(--ui-text-tertiary) hover:text-foreground',- saved ? 'cursor-pointer' : 'cursor-default',- on ? 'bg-(--ui-bg-quinary)' : 'line-through opacity-70'- )}- disabled={!saved}- key={tool.name}- onClick={() => onToggleTool(tool.name)}- type="button"- >- {tool.name}- </button>- )- })}- </div>- )}- </div>- )-}--// The enable toggle, shared by the row and the config header. It reflects the-// configured `enabled` flag ONLY — full-strength when on, dimmed when off — so-// "is this on?" reads instantly from config, never gated on a probe that can-// take seconds (stdio servers spawn `npx`). Whether it's actually *connected*-// is the status dot's job, not the switch's.-function ServerSwitch({- className,- disabled,- enabled,- name,- onToggle-}: {- className?: string- disabled: boolean- enabled: boolean- name: string- onToggle: (checked: boolean) => void-}) {- return (- <Switch- aria-label={name}- checked={enabled}- className={cn('shrink-0 cursor-pointer', !enabled && 'opacity-60', className)}- disabled={disabled}- onCheckedChange={onToggle}- size="xs"- title={name}- />- )-}--// Refresh + delete, identical beside every toggle (rows and config header).-function ServerIconActions({- className,- onProbe,- onRemove,- probing,- saving-}: {- className?: string- onProbe: () => void- onRemove: () => void- probing: boolean- saving: boolean-}) {- const { t } = useI18n()- const m = t.settings.mcp-- return (- <span className={cn('flex items-center gap-0.5', className)}>- <Tip label={m.reload}>- <Button- aria-label={m.reload}- className={ICON_BUTTON}- disabled={probing}- onClick={onProbe}- size="icon"- variant="ghost"- >- <Codicon name="refresh" size="0.8125rem" spinning={probing} />- </Button>- </Tip>- <Tip label={m.remove}>- <Button- aria-label={m.remove}- className={cn(ICON_BUTTON, 'hover:text-destructive')}- disabled={saving}- onClick={onRemove}- size="icon"- variant="ghost"- >- <Codicon name="trash" size="0.8125rem" />- </Button>- </Tip>- </span>- )-}--// Paste-anything import: a compact popover on the Servers header. Paste any-// README shape — mcp.json snippet, npx/docker command line, `claude mcp add`,-// a bare URL, or a Cursor deeplink — see the inferred name + config, then-// merge it into the editor draft (unsaved, like the "+" starter entry).-function McpImportButton({ disabled, onImport }: { disabled: boolean; onImport: (entries: McpImportEntry[]) => void }) {- const { t } = useI18n()- const m = t.settings.mcp- const [open, setOpen] = useState(false)- const [text, setText] = useState('')-- const entries = useMemo(() => parseMcpImport(text), [text])-- const reset = () => {- setText('')- }-- const confirm = () => {- if (!entries) {- return- }-- onImport(entries)- setOpen(false)- reset()- }-- return (- <Popover- onOpenChange={next => {- setOpen(next)-- if (!next) {- reset()- }- }}- open={open}- >- <PopoverTrigger asChild>- <Button className="h-5 px-1 text-[0.68rem]" disabled={disabled} size="xs" variant="text">- <Codicon name="clippy" size="0.75rem" />- {m.importButton}- </Button>- </PopoverTrigger>- <PopoverContent align="end" className="w-80">- <div className="flex flex-col gap-2">- <Textarea- aria-label={m.importButton}- autoFocus- className="max-h-40 min-h-20 font-mono text-[0.68rem]"- onChange={event => setText(event.currentTarget.value)}- placeholder={m.importPlaceholder}- value={text}- />- {entries ? (- <div className="flex max-h-40 flex-col gap-1 overflow-y-auto">- {entries.map((entry, index) => (- <div className="rounded-md bg-(--ui-bg-tertiary) px-2 py-1.5" key={`${entry.name}-${index}`}>- <span className="block truncate text-[0.72rem] font-medium text-foreground/85">{entry.name}</span>- <span className="block truncate font-mono text-[0.62rem] text-muted-foreground/60">- {typeof entry.config.url === 'string'- ? entry.config.url- : [entry.config.command, ...((entry.config.args as string[]) ?? [])].join(' ')}- </span>- </div>- ))}- </div>- ) : (- text.trim() && <p className="px-0.5 text-[0.62rem] text-muted-foreground/60">{m.importNoMatch}</p>- )}- <div className="flex justify-end">- <Button disabled={!entries} onClick={confirm} size="xs">- {entries && entries.length > 1 ? m.importConfirmMany(entries.length) : m.importConfirm}- </Button>- </div>- </div>- </PopoverContent>- </Popover>- )-}--// Small gray attribute chip (transport / auth / needs-build), matching the-// catalog's flat row treatment.-function CatalogTag({ children }: { children: string }) {- return (- <span className="rounded bg-(--ui-bg-tertiary) px-1.5 py-0.5 text-[0.6rem] text-(--ui-text-secondary)">- {children}- </span>- )-}--// The Nous-approved MCP catalog: one-click installs of curated servers, with an-// inline prompt for any required credentials (never shows stored values). On-// install the parent refetches config + catalog and reloads live sessions.-function McpCatalog({- entries,- loading,- onInstalled,- profile-}: {- entries: McpCatalogEntry[]- loading: boolean- onInstalled: () => void- profile?: ProfileScope-}) {- const { t } = useI18n()- const m = t.settings.mcp- const [installing, setInstalling] = useState<null | string>(null)- const [envDrafts, setEnvDrafts] = useState<Record<string, Record<string, string>>>({})- const [envOpenFor, setEnvOpenFor] = useState<null | string>(null)-- const install = async (entry: McpCatalogEntry) => {- const required = entry.required_env.filter(env => env.required)- const draft = envDrafts[entry.name] ?? {}-- // Reveal the credential prompt first; only error once it's shown and unfilled.- if (required.some(env => !draft[env.name]?.trim())) {- if (envOpenFor !== entry.name) {- setEnvOpenFor(entry.name)-- return- }-- notify({ kind: 'error', title: m.catalogEnvPrompt(entry.name), message: m.catalogEnvRequired })-- return- }-- setInstalling(entry.name)-- try {- const res = await installMcpCatalogEntry(entry.name, draft, profile ?? undefined)-- // Git-backed entries clone in the background — keep the row busy and poll- // the action to completion before refetching / re-enabling, so a re-click- // can't spawn a second install over the first's tracked process. A non-zero- // exit is a real failure — surface it instead of a false success.- if (res.background && res.action) {- for (;;) {- const status = await getActionStatus(res.action, 1, profile ?? undefined)-- if (!status.running) {- if (status.exit_code !== 0) {- throw new Error(m.catalogInstallFailed(entry.name))- }-- break- }-- await new Promise(resolve => setTimeout(resolve, CATALOG_INSTALL_POLL_MS))- }- }-- notify({ kind: 'success', title: m.catalogInstallStarted(entry.name), message: '' })- setEnvOpenFor(null)- onInstalled()- } catch (err) {- notifyError(err, m.catalogInstallFailed(entry.name))- } finally {- setInstalling(null)- }- }-- if (loading) {- return <PageLoader className="min-h-24" label={m.catalogLoading} />- }-- if (entries.length === 0) {- return <PanelEmpty description={m.catalogEmpty} icon="plug" title={m.tabCatalog} />- }-- return (- <div className="flex flex-col">- {entries.map(entry => {- const draft = envDrafts[entry.name] ?? {}-- return (- <div className="rounded-md px-2 py-2" key={entry.name}>- <div className="flex items-start gap-2">- {/* 2px nudge so the start-aligned avatar sits where McpRow's- center-aligned one does — no jump when flipping Servers⇄Catalog. */}- <McpAvatar- className="mt-0.5"- name={entry.name}- status={entry.installed ? (entry.enabled ? 'ok' : 'off') : 'unknown'}- />- <div className="min-w-0 flex-1">- <div className="flex flex-wrap items-center gap-1.5">- <span className="truncate text-[0.78rem] font-medium text-foreground/85">- {prettyName(entry.name)}- </span>- <CatalogTag>{entry.transport}</CatalogTag>- {entry.auth_type === 'oauth' && <CatalogTag>OAuth</CatalogTag>}- {entry.auth_type === 'api_key' && <CatalogTag>API key</CatalogTag>}- {entry.needs_install && !entry.installed && <CatalogTag>{m.catalogNeedsInstall}</CatalogTag>}- {entry.installed && (- <span className="text-[0.6rem] text-emerald-400">- {entry.enabled ? m.catalogEnabled : m.catalogInstalled}- </span>- )}- </div>- <p className="mt-0.5 line-clamp-2 text-[0.68rem] text-muted-foreground/70">{entry.description}</p>- {envOpenFor === entry.name && entry.required_env.length > 0 && (- <div className="mt-2 grid gap-2">- {entry.required_env.map(env => (- <label className="grid gap-1" key={env.name}>- <span className="text-[0.62rem] text-muted-foreground">- {env.prompt || env.name}- {env.required ? ' *' : ''}- </span>- <Input- className="h-7 text-xs"- onChange={event =>- setEnvDrafts(prev => ({- ...prev,- [entry.name]: { ...prev[entry.name], [env.name]: event.currentTarget.value }- }))- }- type="password"- value={draft[env.name] ?? ''}- />- </label>- ))}- </div>- )}- </div>- <Button- className="mt-0.5 shrink-0"- disabled={entry.installed || installing !== null}- onClick={() => void install(entry)}- size="xs"- variant="text"- >- {installing === entry.name- ? m.catalogInstalling- : entry.installed- ? m.catalogInstalled- : m.catalogInstall}- </Button>- </div>- </div>- )- })}- </div>- )-}--const LOG_POLL_MS = 2000--// Cadence for polling a background (git-bootstrap) catalog install to completion.-const CATALOG_INSTALL_POLL_MS = 1500--const STDIO_MARKER_RE = /^===== \[.*\] starting MCP server '(.+)' =====$/--// Keep only the stdio-log sections belonging to one server. The shared file-// has no per-line tags — sections start at that server's session marker and-// run until the next marker (any server's).-function filterStdioSections(lines: string[], server: string): string[] {- const out: string[] = []- let inSection = false-- for (const line of lines) {- const marker = STDIO_MARKER_RE.exec(line.trim())-- if (marker) {- inSection = marker[1] === server- }-- if (inSection) {- out.push(line)- }- }-- return out-}--// The MCP output channel — Cursor's "MCP Logs" equivalent, pinned under the-// editor. Scope follows the cursor-selected server (all servers otherwise);-// source controls live in the pane header. Body is the app's tool-output-// surface: CodeCardBody typography + the floating hover-reveal copy button.-function McpLogs({- emptyLabel,- server,- source-}: {- emptyLabel: string- server: null | string- source: 'stdio' | 'agent'-}) {- const [lines, setLines] = useState<null | string[]>(null)- // A profile switch reroutes getLogs to the new backend; keying the effect on- // the active profile tears down the old poll (stop suppresses a late- // publish) so profile A's logs never flash in B.- const activeProfile = useStore($activeGatewayProfile)-- useEffect(() => {- setLines(null)-- return startCompletionPoll({- delayMs: LOG_POLL_MS,- poll: async () => {- const response =- source === 'stdio'- ? await getLogs({ file: 'mcp', lines: 500 })- : await getLogs({ file: 'agent', lines: 300, search: server ?? 'mcp' })-- return source === 'stdio' && server ? filterStdioSections(response.lines, server) : response.lines- },- publish: setLines- })- }, [server, source, activeProfile])-- return <LogTail emptyLabel={emptyLabel} lines={lines} />-}--// ----------------------------------------------------------------------------// Avatars + list rows-// -----------------------------------------------------------------------------// The shared identity chip (`ui/avatar-chip`) plus a status dot. Identity-// ladder: curated brand glyph (lib/mcp-brands, shared with the composer-// suggestion pills and the inline setup card) → letter monogram. Nothing here-// reaches the network for a mark: a configured MCP URL can be a private host,-// and the connector card's favicon rung only ever reads a public site's own-// markup, never a third-party icon service.-function McpAvatar({ className, name, status }: { className?: string; name: string; status: ServerStatus }) {- return (- <AvatarChip- brand={brandFor(name)}- className={className}- name={name}- overlay={- <span- aria-hidden- className={cn(- 'absolute -bottom-0.5 -right-0.5 size-2 rounded-full ring-2 ring-(--ui-chat-surface-background)',- STATUS_DOT[status]- )}- />- }- />- )-}--function McpRow({- active,- busy,- enabled,- name,- onProbe,- onRemove,- onSelect,- onToggle,- status,- statusText,- unused-}: {- active: boolean- busy: boolean- enabled: boolean- name: string- onProbe: () => void- onRemove: () => void- onSelect: () => void- onToggle: (checked: boolean) => void- status: ServerStatus- statusText: string- unused?: boolean-}) {- const { t } = useI18n()- const m = t.settings.mcp-- return (- <div- className={cn(- 'group/row row-hover flex h-11 w-full shrink-0 items-center gap-2 rounded-md pl-2 pr-1.5 hover:text-foreground',- active ? 'bg-(--ui-row-active-background) text-foreground' : 'text-(--ui-text-secondary)'- )}- id={`mcp-server-${name}`}- >- <button- className="flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-left"- onClick={onSelect}- type="button"- >- <McpAvatar name={name} status={status} />- <span className="min-w-0 flex-1">- <span className="flex min-w-0 items-center gap-1.5">- <span- className={cn(- 'min-w-0 truncate text-[0.78rem]',- enabled ? 'font-medium text-foreground/85' : 'font-normal text-muted-foreground/60'- )}- >- {prettyName(name)}- </span>- {/* Subtle "paying for schemas, not using them" hint — a muted pill,- never a dialog. Shown only when the overlay KNOWS both halves:- nonzero schema cost and zero 30-day uses. */}- {unused && (- <span className="shrink-0 rounded bg-(--ui-bg-tertiary) px-1 py-px text-[0.58rem] font-normal text-muted-foreground/60">- {m.unusedPill}- </span>- )}- </span>- <span className="block truncate text-[0.62rem] text-muted-foreground/50">{statusText}</span>- </span>- </button>- <ServerIconActions- className="opacity-0 transition-opacity focus-within:opacity-100 group-hover/row:opacity-100"- onProbe={onProbe}- onRemove={onRemove}- probing={status === 'probing'}- saving={busy}- />- <ServerSwitch disabled={busy} enabled={enabled} name={name} onToggle={onToggle} />- </div>- )-}diff --git a/apps/desktop/src/app/settings/use-deep-link-highlight.ts b/apps/desktop/src/app/settings/use-deep-link-highlight.tsindex 2a93596cec0..ee4b8434be3 100644--- a/apps/desktop/src/app/settings/use-deep-link-highlight.ts+++ b/apps/desktop/src/app/settings/use-deep-link-highlight.ts@@ -11,7 +11,7 @@ interface DeepLinkHighlightOptions {// react-router's useSearchParams throws with no router context. Inside Settings// (every original caller) there always is one, so behavior is unchanged; when a-// consumer is embedded OUTSIDE the router (e.g. McpTab in a plugin dialog) there+// consumer is embedded OUTSIDE the router (a plugin dialog) there// is none, and this degrades to an inert [empty params, no-op setter] instead of// crashing. Router presence is stable for a mounted instance's lifetime, so the// try/catch never changes the hook count between renders (rules-of-hooks safe).diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex eb66c96af27..05107a4a8b7 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -1038,31 +1038,16 @@ export const ar = defineLocale({},mcp: {loading: 'جار تحميل خوادم MCP...',- failedLoad: 'فشل تحميل إعدادات MCP',- nameRequiredTitle: 'الاسم مطلوب',- nameRequiredMessage: 'أعط هذا الخادم مفتاح إعداد.',- objectRequired: 'يجب أن تكون إعدادات الخادم كائن JSON',invalidJson: 'JSON الخاص بـ MCP غير صالح',saveFailed: 'فشل الحفظ',removeFailed: 'فشلت الإزالة',- gatewayUnavailableTitle: 'البوابة غير متاحة',- gatewayUnavailableMessage: 'أعد الاتصال بالبوابة قبل إعادة تحميل MCP.',- reloadedTitle: 'تمت إعادة تحميل أدوات MCP',- reloadedMessage: 'مخططات الأدوات الجديدة تطبق على الأدوار الجديدة.',reloadFailed: 'فشلت إعادة تحميل MCP',savedTitle: 'تم حفظ خادم MCP',savedMessage: name => `سيطبق ${name} بعد إعادة تحميل MCP.`,- newServer: 'خادم جديد',- reload: 'إعادة تحميل MCP',- reloading: 'جار إعادة التحميل...',- emptyTitle: 'لا توجد خوادم MCP',- emptyDesc: 'أضف خادم stdio أو HTTP لإتاحة أدوات MCP.',disabled: 'معطل',- editServer: 'تحرير الخادم',name: 'الاسم',serverJson: 'JSON الخادم',remove: 'إزالة',- saveServer: 'حفظ الخادم',deepLinkTitle: 'إضافة خادم MCP؟',deepLinkDescription:'طلب رابط إضافة خادم MCP هذا إلى Hermes. راجع الإعدادات الكاملة أدناه — فهي قادمة من الرابط وليست من Hermes.',diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex ce4389f027c..f4f36147518 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -1583,59 +1583,24 @@ export const en: Translations = {},mcp: {loading: 'Loading MCP servers...',- failedLoad: 'MCP config failed to load',- nameRequiredTitle: 'Name required',- nameRequiredMessage: 'Give this MCP server a config key.',- objectRequired: 'Server config must be a JSON object',invalidJson: 'Invalid MCP JSON',saveFailed: 'Save failed',removeFailed: 'Remove failed',- gatewayUnavailableTitle: 'Gateway unavailable',- gatewayUnavailableMessage: 'Reconnect the gateway before reloading MCP.',- reloadedTitle: 'MCP tools reloaded',- reloadedMessage: 'New tool schemas apply to fresh turns.',reloadFailed: 'MCP reload failed',savedTitle: 'MCP server saved',savedMessage: name => `${name} applies after MCP reload.`,- newServer: 'New server',- reload: 'Reload MCP',- reloading: 'Reloading...',- emptyTitle: 'No MCP servers',- emptyDesc: 'Add a stdio or HTTP server to expose MCP tools.',disabled: 'disabled',- editServer: 'Edit server',name: 'Name',serverJson: 'Server JSON',remove: 'Remove',- saveServer: 'Save server',test: 'Test connection',- testing: 'Testing...',- testOk: count => `Connected — ${count} tool${count === 1 ? '' : 's'} available`,- testFailed: 'Connection failed',- enableServer: name => `Enable ${name}`,- disableServer: name => `Disable ${name}`,- serverEnabled: name => `${name} enabled — applies to new sessions.`,- serverDisabled: name => `${name} disabled — applies to new sessions.`,- toggleFailed: (name, enabled) => `Failed to turn ${name} ${enabled ? 'on' : 'off'}`,- tabServers: 'Servers',- tabCatalog: 'Catalog',catalogLoading: 'Loading MCP catalog...',- catalogLoadFailed: 'MCP catalog failed to load',- catalogEmpty: 'No catalog entries available.',- catalogInstalled: 'Installed',- catalogEnabled: 'Enabled',- catalogNeedsInstall: 'Needs build',- catalogInstall: 'Install',- catalogInstalling: 'Installing...',- catalogInstallStarted: name => `Installing ${name}... applies to new sessions when done.`,catalogInstallFailed: name => `Failed to install ${name}`,- catalogEnvPrompt: name => `${name} requires credentials`,catalogEnvRequired: 'Fill in the required values before installing.',capabilitySummary: (tools, prompts, resources) =>`${[`${tools} tools`, ...(prompts ? [`${prompts} prompts`] : []), ...(resources ? [`${resources} resources`] : [])].join(', ')} enabled`,costTokens: tokens => `~${tokens} tok/call`,usage30d: uses => `${uses} uses/30d`,- unusedPill: 'unused',statusConnecting: 'Connecting…',statusNeedsAuth: 'Needs authentication',statusError: 'Error',@@ -1643,11 +1608,7 @@ export const en: Translations = {allServers: 'All servers',authenticatedTitle: 'Authenticated',authenticatedMessage: (server, count) => `${server}: ${count} tools`,- waitingForBrowser: 'Waiting for browser…',authenticate: 'Authenticate',- unsavedConnect: 'Unsaved — save mcp.json to connect.',- enableTool: tool => `Enable ${tool}`,- disableTool: tool => `Disable ${tool}`,noOutput: 'No output yet.',deepLinkTitle: 'Add MCP server?',deepLinkDescription:@@ -1662,13 +1623,7 @@ export const en: Translations = {deepLinkErrorConfig: 'The link\u2019s config is not valid base64-encoded JSON.',deepLinkErrorShape: 'The config must be a JSON object with a string `url` or `command` field.',deepLinkErrorUrl: 'Only http:// and https:// server URLs are allowed.',- deepLinkErrorTooLarge: 'The config payload exceeds the 32KB limit.',- importButton: 'Import',- importPlaceholder: 'Paste an mcp.json snippet, npx/docker command, claude mcp add line, URL, or Cursor link…',- importNoMatch: 'No server config recognized in the pasted text.',- importConfirm: 'Add to mcp.json',- importConfirmMany: count => `Add ${count} servers to mcp.json`- },+ deepLinkErrorTooLarge: 'The config payload exceeds the 32KB limit.',},model: {loading: 'Loading model configuration...',appliesDesc: 'Applies to new sessions. Use the model picker in the composer to hot-swap the active chat.',@@ -2020,7 +1975,6 @@ export const en: Translations = {tabSkills: 'Skills',tabToolsets: 'Tools',configuringProfile: 'Configuring:',- tabMcp: 'MCP',all: 'All',searchSkills: 'Search skills...',searchToolsets: 'Search tools...',diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 8ef6f94ea34..eb4ca4962cc 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -1182,36 +1182,20 @@ export const ja = defineLocale({},mcp: {loading: 'MCP サーバーを読み込み中...',- failedLoad: 'MCP 設定の読み込みに失敗しました',- nameRequiredTitle: '名前が必要です',- nameRequiredMessage: 'この MCP サーバーに設定キーを付けてください。',- objectRequired: 'サーバー設定は JSON オブジェクトである必要があります',invalidJson: '無効な MCP JSON',saveFailed: '保存に失敗しました',removeFailed: '削除に失敗しました',- gatewayUnavailableTitle: 'ゲートウェイが利用できません',- gatewayUnavailableMessage: 'MCP を再読み込みする前にゲートウェイを再接続してください。',- reloadedTitle: 'MCP ツールを再読み込みしました',- reloadedMessage: '新しいツールスキーマは新しいターンに適用されます。',reloadFailed: 'MCP の再読み込みに失敗しました',savedTitle: 'MCP サーバーを保存しました',savedMessage: name => `${name} は MCP の再読み込み後に適用されます。`,- newServer: '新しいサーバー',- reload: 'MCP を再読み込み',- reloading: '再読み込み中...',- emptyTitle: 'MCP サーバーがありません',- emptyDesc: 'MCP ツールを公開するには stdio または HTTP サーバーを追加してください。',disabled: '無効',- editServer: 'サーバーを編集',name: '名前',serverJson: 'サーバー JSON',remove: '削除',- saveServer: 'サーバーを保存',capabilitySummary: (tools, prompts, resources) =>`${[`ツール ${tools} 個`, ...(prompts ? [`プロンプト ${prompts} 個`] : []), ...(resources ? [`リソース ${resources} 個`] : [])].join('、')} を有効化`,costTokens: tokens => `1 呼び出しあたり約 ${tokens} トークン`,usage30d: uses => `過去 30 日で ${uses} 回使用`,- unusedPill: '未使用',statusConnecting: '接続中…',statusNeedsAuth: '認証が必要です',statusError: 'エラー',@@ -1219,11 +1203,7 @@ export const ja = defineLocale({allServers: 'すべてのサーバー',authenticatedTitle: '認証済み',authenticatedMessage: (server, count) => `${server}: ツール ${count} 個`,- waitingForBrowser: 'ブラウザを待機中…',authenticate: '認証',- unsavedConnect: '未保存 — 接続するには mcp.json を保存してください。',- enableTool: tool => `${tool} を有効化`,- disableTool: tool => `${tool} を無効化`,noOutput: 'まだ出力がありません。',deepLinkTitle: 'MCP サーバーを追加しますか?',deepLinkDescription:@@ -1240,13 +1220,7 @@ export const ja = defineLocale({deepLinkErrorShape:'設定は文字列の `url` または `command` フィールドを持つ JSON オブジェクトである必要があります。',deepLinkErrorUrl: 'サーバー URL は http:// と https:// のみ許可されます。',- deepLinkErrorTooLarge: '設定ペイロードが 32KB の上限を超えています。',- importButton: 'インポート',- importPlaceholder: 'mcp.json スニペット、npx/docker コマンド、claude mcp add 行、URL、Cursor リンクを貼り付け…',- importNoMatch: '貼り付けたテキストからサーバー設定を認識できませんでした。',- importConfirm: 'mcp.json に追加',- importConfirmMany: count => `${count} 件のサーバーを mcp.json に追加`- },+ deepLinkErrorTooLarge: '設定ペイロードが 32KB の上限を超えています。',},model: {loading: 'モデル設定を読み込み中...',appliesDesc:@@ -1547,7 +1521,6 @@ export const ja = defineLocale({skills: {tabSkills: 'スキル',tabToolsets: 'ツールセット',- tabMcp: 'MCP',all: 'すべて',searchSkills: 'スキルを検索...',searchToolsets: 'ツールセットを検索...',diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.tsindex 244a2817edb..bd436e1359a 100644--- a/apps/desktop/src/i18n/ru.ts+++ b/apps/desktop/src/i18n/ru.ts@@ -1375,60 +1375,24 @@ export const ru = defineLocale({},mcp: {loading: 'Загрузка MCP-серверов…',- failedLoad: 'Не удалось загрузить конфигурацию MCP',- nameRequiredTitle: 'Нужно имя',- nameRequiredMessage: 'Задайте этому MCP-серверу ключ конфигурации.',- objectRequired: 'Конфигурация сервера должна быть JSON-объектом',invalidJson: 'Неверный JSON MCP',saveFailed: 'Не удалось сохранить',removeFailed: 'Не удалось удалить',- gatewayUnavailableTitle: 'Шлюз недоступен',- gatewayUnavailableMessage: 'Переподключите шлюз, прежде чем перезагружать MCP.',- reloadedTitle: 'Инструменты MCP перезагружены',- reloadedMessage: 'Новые схемы инструментов применяются к новым ходам.',reloadFailed: 'Не удалось перезагрузить MCP',savedTitle: 'MCP-сервер сохранён',savedMessage: name => `${name} применится после перезагрузки MCP.`,- newServer: 'Новый сервер',- reload: 'Перезагрузить MCP',- reloading: 'Перезагрузка…',- emptyTitle: 'MCP-серверов нет',- emptyDesc: 'Добавьте stdio- или HTTP-сервер, чтобы получить инструменты MCP.',disabled: 'отключён',- editServer: 'Изменить сервер',name: 'Имя',serverJson: 'JSON сервера',remove: 'Удалить',- saveServer: 'Сохранить сервер',test: 'Проверить соединение',- testing: 'Проверка…',- testOk: count =>- `Подключено — доступно ${count} ${RU_PLURAL(count, 'инструмент', 'инструмента', 'инструментов')}`,- testFailed: 'Не удалось подключиться',- enableServer: name => `Включить ${name}`,- disableServer: name => `Отключить ${name}`,- serverEnabled: name => `${name} включён — применится к новым сеансам.`,- serverDisabled: name => `${name} отключён — применится к новым сеансам.`,- toggleFailed: (name, enabled) => `Не удалось ${enabled ? 'включить' : 'отключить'} ${name}`,- tabServers: 'Серверы',- tabCatalog: 'Каталог',catalogLoading: 'Загрузка каталога MCP…',- catalogLoadFailed: 'Не удалось загрузить каталог MCP',- catalogEmpty: 'Записей каталога нет.',- catalogInstalled: 'Установлен',- catalogEnabled: 'Включён',- catalogNeedsInstall: 'Нужна сборка',- catalogInstall: 'Установить',- catalogInstalling: 'Установка…',- catalogInstallStarted: name => `Установка ${name}… применится к новым сеансам после завершения.`,catalogInstallFailed: name => `Не удалось установить ${name}`,- catalogEnvPrompt: name => `${name} требует учётные данные`,catalogEnvRequired: 'Заполните обязательные значения перед установкой.',capabilitySummary: (tools, prompts, resources) =>`${[`${tools} ${RU_NOUN(tools, 'инструмент', 'инструмента', 'инструментов')}`, ...(prompts ? [`${prompts} ${RU_NOUN(prompts, 'промпт', 'промпта', 'промптов')}`] : []), ...(resources ? [`${resources} ${RU_NOUN(resources, 'ресурс', 'ресурса', 'ресурсов')}`] : [])].join(', ')} включено`,costTokens: tokens => `~${tokens} ток/вызов`,usage30d: uses => `${uses} ${RU_NOUN(uses, 'использование', 'использования', 'использований')}/30д`,- unusedPill: 'не используется',statusConnecting: 'Подключение…',statusNeedsAuth: 'Нужна аутентификация',statusError: 'Ошибка',@@ -1437,11 +1401,7 @@ export const ru = defineLocale({authenticatedTitle: 'Аутентифицирован',authenticatedMessage: (server, count) =>`${server}: ${count} ${RU_PLURAL(count, 'инструмент', 'инструмента', 'инструментов')}`,- waitingForBrowser: 'Ожидание браузера…',authenticate: 'Аутентифицироваться',- unsavedConnect: 'Не сохранено — сохраните mcp.json, чтобы подключиться.',- enableTool: tool => `Включить ${tool}`,- disableTool: tool => `Отключить ${tool}`,noOutput: 'Вывода пока нет.',deepLinkTitle: 'Добавить MCP-сервер?',deepLinkDescription:@@ -1456,14 +1416,7 @@ export const ru = defineLocale({deepLinkErrorConfig: 'Конфигурация в ссылке не является корректным JSON в base64.',deepLinkErrorShape: 'Конфигурация должна быть JSON-объектом со строковым полем `url` или `command`.',deepLinkErrorUrl: 'Разрешены только URL серверов http:// и https://.',- deepLinkErrorTooLarge: 'Пакет конфигурации превышает лимит 32 КБ.',- importButton: 'Импортировать',- importPlaceholder:- 'Вставьте фрагмент mcp.json, команду npx/docker, строку claude mcp add, URL или ссылку Cursor…',- importNoMatch: 'В вставленном тексте не распознана конфигурация сервера.',- importConfirm: 'Добавить в mcp.json',- importConfirmMany: count => `Добавить ${count} ${RU_PLURAL(count, 'сервер', 'сервера', 'серверов')} в mcp.json`- },+ deepLinkErrorTooLarge: 'Пакет конфигурации превышает лимит 32 КБ.',},model: {loading: 'Загрузка конфигурации модели…',appliesDesc:@@ -1653,7 +1606,6 @@ export const ru = defineLocale({tabSkills: 'Навыки',tabToolsets: 'Инструменты',configuringProfile: 'Настраивается:',- tabMcp: 'MCP',all: 'Все',searchSkills: 'Поиск навыков...',searchToolsets: 'Поиск инструментов...',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 87f4a84ef93..2bae016d0e9 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -1344,58 +1344,23 @@ export interface Translations {}mcp: {loading: string- failedLoad: string- nameRequiredTitle: string- nameRequiredMessage: string- objectRequired: stringinvalidJson: stringsaveFailed: stringremoveFailed: string- gatewayUnavailableTitle: string- gatewayUnavailableMessage: string- reloadedTitle: string- reloadedMessage: stringreloadFailed: stringsavedTitle: stringsavedMessage: (name: string) => string- newServer: string- reload: string- reloading: string- emptyTitle: string- emptyDesc: stringdisabled: string- editServer: stringname: stringserverJson: stringremove: string- saveServer: stringtest: string- testing: string- testOk: (count: number) => string- testFailed: string- enableServer: (name: string) => string- disableServer: (name: string) => string- serverEnabled: (name: string) => string- serverDisabled: (name: string) => string- toggleFailed: (name: string, enabled: boolean) => string- tabServers: string- tabCatalog: stringcatalogLoading: string- catalogLoadFailed: string- catalogEmpty: string- catalogInstalled: string- catalogEnabled: string- catalogNeedsInstall: string- catalogInstall: string- catalogInstalling: string- catalogInstallStarted: (name: string) => stringcatalogInstallFailed: (name: string) => string- catalogEnvPrompt: (name: string) => stringcatalogEnvRequired: stringcapabilitySummary: (tools: number, prompts: number, resources: number) => stringcostTokens: (tokens: string) => stringusage30d: (uses: string) => string- unusedPill: stringstatusConnecting: stringstatusNeedsAuth: stringstatusError: string@@ -1403,11 +1368,7 @@ export interface Translations {allServers: stringauthenticatedTitle: stringauthenticatedMessage: (server: string, count: number) => string- waitingForBrowser: stringauthenticate: string- unsavedConnect: string- enableTool: (tool: string) => string- disableTool: (tool: string) => stringnoOutput: stringdeepLinkTitle: stringdeepLinkDescription: string@@ -1420,13 +1381,7 @@ export interface Translations {deepLinkErrorConfig: stringdeepLinkErrorShape: stringdeepLinkErrorUrl: string- deepLinkErrorTooLarge: string- importButton: string- importPlaceholder: string- importNoMatch: string- importConfirm: string- importConfirmMany: (count: number) => string- }+ deepLinkErrorTooLarge: string}model: {loading: stringappliesDesc: string@@ -1735,7 +1690,6 @@ export interface Translations {tabSkills: stringtabToolsets: stringconfiguringProfile: string- tabMcp: stringall: stringsearchSkills: stringsearchToolsets: stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex 220d3820b58..2ea46fab6a1 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -1204,36 +1204,20 @@ export const zhHant = defineLocale({},mcp: {loading: '正在載入 MCP 伺服器...',- failedLoad: 'MCP 設定載入失敗',- nameRequiredTitle: '需要名稱',- nameRequiredMessage: '請為此 MCP 伺服器提供設定鍵。',- objectRequired: '伺服器設定必須是 JSON 物件',invalidJson: 'MCP JSON 無效',saveFailed: '儲存失敗',removeFailed: '移除失敗',- gatewayUnavailableTitle: '閘道不可用',- gatewayUnavailableMessage: '重新載入 MCP 前請先重新連線閘道。',- reloadedTitle: 'MCP 工具已重新載入',- reloadedMessage: '新的工具 Schema 將套用至後續回合。',reloadFailed: 'MCP 重新載入失敗',savedTitle: 'MCP 伺服器已儲存',savedMessage: name => `${name} 會在 MCP 重新載入後生效。`,- newServer: '新伺服器',- reload: '重新載入 MCP',- reloading: '重新載入中...',- emptyTitle: '沒有 MCP 伺服器',- emptyDesc: '新增 stdio 或 HTTP 伺服器以公開 MCP 工具。',disabled: '已停用',- editServer: '編輯伺服器',name: '名稱',serverJson: '伺服器 JSON',remove: '移除',- saveServer: '儲存伺服器',capabilitySummary: (tools, prompts, resources) =>`已啟用 ${[`${tools} 個工具`, ...(prompts ? [`${prompts} 個提示`] : []), ...(resources ? [`${resources} 個資源`] : [])].join('、')}`,costTokens: tokens => `每次呼叫約 ${tokens} token`,usage30d: uses => `30 天內 ${uses} 次呼叫`,- unusedPill: '未使用',statusConnecting: '連線中…',statusNeedsAuth: '需要驗證',statusError: '錯誤',@@ -1241,11 +1225,7 @@ export const zhHant = defineLocale({allServers: '所有伺服器',authenticatedTitle: '已驗證',authenticatedMessage: (server, count) => `${server}:${count} 個工具`,- waitingForBrowser: '等待瀏覽器…',authenticate: '驗證',- unsavedConnect: '未儲存 — 儲存 mcp.json 以連線。',- enableTool: tool => `啟用 ${tool}`,- disableTool: tool => `停用 ${tool}`,noOutput: '尚無輸出。',deepLinkTitle: '新增 MCP 伺服器?',deepLinkDescription: '一個連結要求將此 MCP 伺服器加入 Hermes。請檢查下方的完整設定——它來自該連結,而非 Hermes。',@@ -1258,13 +1238,7 @@ export const zhHant = defineLocale({deepLinkErrorConfig: '連結中的設定不是有效的 base64 編碼 JSON。',deepLinkErrorShape: '設定必須是包含字串 `url` 或 `command` 欄位的 JSON 物件。',deepLinkErrorUrl: '僅允許 http:// 和 https:// 伺服器網址。',- deepLinkErrorTooLarge: '設定內容超過 32KB 上限。',- importButton: '匯入',- importPlaceholder: '貼上 mcp.json 片段、npx/docker 指令、claude mcp add 指令、URL 或 Cursor 連結…',- importNoMatch: '貼上的文字中未識別到伺服器設定。',- importConfirm: '加入 mcp.json',- importConfirmMany: count => `將 ${count} 個伺服器加入 mcp.json`- },+ deepLinkErrorTooLarge: '設定內容超過 32KB 上限。',},model: {loading: '正在載入模型設定...',appliesDesc: '套用至新工作階段。可在輸入框的模型選擇器中臨時切換目前對話。',@@ -1557,7 +1531,6 @@ export const zhHant = defineLocale({skills: {tabSkills: '技能',tabToolsets: '工具集',- tabMcp: 'MCP',all: '全部',searchSkills: '搜尋技能...',searchToolsets: '搜尋工具集...',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex f48363cadb1..38d736467cb 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -1539,59 +1539,24 @@ export const zh = defineLocale({},mcp: {loading: '正在加载 MCP 服务器...',- failedLoad: 'MCP 配置加载失败',- nameRequiredTitle: '需要名称',- nameRequiredMessage: '请为此 MCP 服务器提供配置键。',- objectRequired: '服务器配置必须是 JSON 对象',invalidJson: 'MCP JSON 无效',saveFailed: '保存失败',removeFailed: '移除失败',- gatewayUnavailableTitle: '网关不可用',- gatewayUnavailableMessage: '重新加载 MCP 前请先重连网关。',- reloadedTitle: 'MCP 工具已重新加载',- reloadedMessage: '新的工具 schema 将应用到后续回合。',reloadFailed: 'MCP 重新加载失败',savedTitle: 'MCP 服务器已保存',savedMessage: name => `${name} 会在 MCP 重新加载后生效。`,- newServer: '新服务器',- reload: '重新加载 MCP',- reloading: '重新加载中...',- emptyTitle: '没有 MCP 服务器',- emptyDesc: '添加 stdio 或 HTTP 服务器以暴露 MCP 工具。',disabled: '已禁用',- editServer: '编辑服务器',name: '名称',serverJson: '服务器 JSON',remove: '移除',- saveServer: '保存服务器',test: '测试连接',- testing: '测试中…',- testOk: count => `已连接 — ${count} 个工具可用`,- testFailed: '连接失败',- enableServer: name => `启用 ${name}`,- disableServer: name => `禁用 ${name}`,- serverEnabled: name => `${name} 已启用 — 对新会话生效。`,- serverDisabled: name => `${name} 已禁用 — 对新会话生效。`,- toggleFailed: (name, enabled) => `${enabled ? '开启' : '关闭'} ${name} 失败`,- tabServers: '服务器',- tabCatalog: '目录',catalogLoading: '正在加载 MCP 目录…',- catalogLoadFailed: 'MCP 目录加载失败',- catalogEmpty: '没有可用的目录条目。',- catalogInstalled: '已安装',- catalogEnabled: '已启用',- catalogNeedsInstall: '需要构建',- catalogInstall: '安装',- catalogInstalling: '安装中…',- catalogInstallStarted: name => `正在安装 ${name}… 完成后对新会话生效。`,catalogInstallFailed: name => `安装 ${name} 失败`,- catalogEnvPrompt: name => `${name} 需要凭据`,catalogEnvRequired: '安装前请填写必需的值。',capabilitySummary: (tools, prompts, resources) =>`已启用 ${[`${tools} 个工具`, ...(prompts ? [`${prompts} 个提示`] : []), ...(resources ? [`${resources} 个资源`] : [])].join('、')}`,costTokens: tokens => `每次调用约 ${tokens} token`,usage30d: uses => `30 天内 ${uses} 次调用`,- unusedPill: '未使用',statusConnecting: '连接中…',statusNeedsAuth: '需要认证',statusError: '错误',@@ -1599,11 +1564,7 @@ export const zh = defineLocale({allServers: '所有服务器',authenticatedTitle: '已认证',authenticatedMessage: (server, count) => `${server}:${count} 个工具`,- waitingForBrowser: '等待浏览器…',authenticate: '认证',- unsavedConnect: '未保存 — 保存 mcp.json 以连接。',- enableTool: tool => `启用 ${tool}`,- disableTool: tool => `禁用 ${tool}`,noOutput: '暂无输出。',deepLinkTitle: '添加 MCP 服务器?',deepLinkDescription:@@ -1617,13 +1578,7 @@ export const zh = defineLocale({deepLinkErrorConfig: '链接中的配置不是有效的 base64 编码 JSON。',deepLinkErrorShape: '配置必须是包含字符串 `url` 或 `command` 字段的 JSON 对象。',deepLinkErrorUrl: '仅允许 http:// 和 https:// 服务器地址。',- deepLinkErrorTooLarge: '配置负载超过 32KB 上限。',- importButton: '导入',- importPlaceholder: '粘贴 mcp.json 片段、npx/docker 命令、claude mcp add 命令、URL 或 Cursor 链接…',- importNoMatch: '粘贴的文本中未识别到服务器配置。',- importConfirm: '添加到 mcp.json',- importConfirmMany: count => `添加 ${count} 个服务器到 mcp.json`- },+ deepLinkErrorTooLarge: '配置负载超过 32KB 上限。',},model: {loading: '正在加载模型配置...',appliesDesc: '应用于新会话。可在输入框的模型选择器中临时切换当前对话。',@@ -1945,7 +1900,6 @@ export const zh = defineLocale({tabSkills: '技能',tabToolsets: '工具集',configuringProfile: '正在配置:',- tabMcp: 'MCP',all: '全部',searchSkills: '搜索技能…',searchToolsets: '搜索工具集…',diff --git a/apps/desktop/src/plugins/hermes-bots/legacy-sdk-compat.test.ts b/apps/desktop/src/plugins/hermes-bots/legacy-sdk-compat.test.tsindex 673364158ac..0b1cafbbc65 100644--- a/apps/desktop/src/plugins/hermes-bots/legacy-sdk-compat.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/legacy-sdk-compat.test.ts@@ -1,7 +1,7 @@/*** Bot Mode has to keep linking against an OLDER desktop SDK.*- * `McpTab`, `ToolsetConfigPanel` and `CapabilitiesView` are capability exports: the+ * `ConnectorsTab`, `ToolsetConfigPanel` and `CapabilitiesView` are capability exports: the* shell that hosts the plugin may predate any of them. Every use site is* therefore guarded, and the plugin module graph must evaluate — and still* hand back a registrable plugin — when all three are missing. A bare@@ -12,7 +12,7 @@import { describe, expect, it, vi } from 'vitest'/** Names an older SDK is allowed not to export. */-const OPTIONAL_CAPABILITY_EXPORTS = new Set(['McpTab', 'CapabilitiesView', 'ToolsetConfigPanel'])+const OPTIONAL_CAPABILITY_EXPORTS = new Set(['ConnectorsTab', 'CapabilitiesView', 'ToolsetConfigPanel'])vi.mock('@hermes/plugin-sdk', async () => {const { atom } = await import('nanostores')diff --git a/apps/desktop/src/plugins/hermes-bots/profile-config-capabilities.test.tsx b/apps/desktop/src/plugins/hermes-bots/profile-config-capabilities.test.tsxindex 226d1a59cb4..f0e2ee43ba0 100644--- a/apps/desktop/src/plugins/hermes-bots/profile-config-capabilities.test.tsx+++ b/apps/desktop/src/plugins/hermes-bots/profile-config-capabilities.test.tsx@@ -1,7 +1,7 @@/*** The bot editor's Advanced section renders the REAL core Capabilities* surfaces — CapabilitiesView (installed skills + hub installs + detail),- * ToolsetConfigPanel (per-toolset env/keys/model/post-setup) and McpTab+ * ToolsetConfigPanel (per-toolset env/keys/model/post-setup) and ConnectorsTab* (per-server enable + OAuth + API keys) — pinned to the bot's own profile,* instead of bare checkbox stand-ins.*@@ -33,7 +33,7 @@ interface StubProps {/** The optional SDK exports, swapped per test to model each desktop build. */const sdk = vi.hoisted(() => {- const seen: Record<string, StubProps[]> = { McpTab: [], CapabilitiesView: [], ToolsetConfigPanel: [] }+ const seen: Record<string, StubProps[]> = { ConnectorsTab: [], CapabilitiesView: [], ToolsetConfigPanel: [] }const spy = (name: string) => {const Stub = (props: StubProps) => {@@ -77,7 +77,7 @@ vi.mock('@hermes/plugin-sdk', async importOriginal => {usePluginI18n: () => translateBots}- for (const name of ['McpTab', 'CapabilitiesView', 'ToolsetConfigPanel']) {+ for (const name of ['ConnectorsTab', 'CapabilitiesView', 'ToolsetConfigPanel']) {Object.defineProperty(mocked, name, { configurable: true, enumerable: true, get: () => sdk.exports[name] })}@@ -180,7 +180,7 @@ afterEach(() => {describe('a build whose CapabilitiesView cannot route connections', () => {const oldBuild = () => ({- McpTab: sdk.spy('McpTab'),+ ConnectorsTab: sdk.spy('ConnectorsTab'),CapabilitiesView: sdk.spy('CapabilitiesView'),ToolsetConfigPanel: sdk.spy('ToolsetConfigPanel')})@@ -192,7 +192,7 @@ describe('a build whose CapabilitiesView cannot route connections', () => {expect(await screen.findByText('Provider')).toBeTruthy()expect(screen.getByText(/Remote capabilities require a newer desktop/)).toBeTruthy()expect(sdk.seen.CapabilitiesView).toHaveLength(0)- expect(sdk.seen.McpTab).toHaveLength(0)+ expect(sdk.seen.ConnectorsTab).toHaveLength(0)expect(sdk.seen.ToolsetConfigPanel).toHaveLength(0)expect(screen.queryByText('Skills Hub')).toBeNull()expect(screen.queryByRole('button', { name: /Set up/ })).toBeNull()@@ -220,7 +220,7 @@ describe('a build whose CapabilitiesView cannot route connections', () => {profile: { connectionId: 'local', profile: 'default' },toolset: 'local-tools'})- expect(sdk.seen.McpTab[0]).toEqual({+ expect(sdk.seen.ConnectorsTab[0]).toEqual({gateway: 'ambient-gateway',profile: { connectionId: 'local', profile: 'default' }})@@ -259,7 +259,7 @@ describe('a connection-aware CapabilitiesView', () => {})describe('a build with no Capabilities exports at all', () => {- const bareBuild = { McpTab: undefined, CapabilitiesView: undefined, ToolsetConfigPanel: undefined }+ const bareBuild = { ConnectorsTab: undefined, CapabilitiesView: undefined, ToolsetConfigPanel: undefined }it('keeps the checkbox MCP list with its inline setup button', async () => {await renderEditor(bareBuild, localBot)diff --git a/apps/desktop/src/plugins/hermes-bots/profile-config.test.ts b/apps/desktop/src/plugins/hermes-bots/profile-config.test.tsindex 34e7f0fdf70..4c3a556460a 100644--- a/apps/desktop/src/plugins/hermes-bots/profile-config.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/profile-config.test.ts@@ -56,7 +56,7 @@ vi.mock('@hermes/plugin-sdk', async () => {GlyphSpinner: () => null,host: hostMock,Input: () => null,- McpTab: undefined,+ ConnectorsTab: undefined,queryClient: { invalidateQueries: invalidateMock },ScrollArea: () => null,Select: () => null,diff --git a/apps/desktop/src/plugins/hermes-bots/profile-config.tsx b/apps/desktop/src/plugins/hermes-bots/profile-config.tsxindex 45f1e6fb769..cd7b31a8681 100644--- a/apps/desktop/src/plugins/hermes-bots/profile-config.tsx+++ b/apps/desktop/src/plugins/hermes-bots/profile-config.tsx@@ -33,7 +33,7 @@ import type { RosterRow } from './types'// Keep optional exports feature-detected; test harnesses may strip the SDK namespace.// The Partial is the point: both are guarded at every use site because an older// build (or a stripped harness namespace) simply doesn't export them.-const { McpTab, ToolsetConfigPanel }: Partial<Pick<typeof sdk, 'McpTab' | 'ToolsetConfigPanel'>> = sdk+const { ConnectorsTab, ToolsetConfigPanel }: Partial<Pick<typeof sdk, 'ConnectorsTab' | 'ToolsetConfigPanel'>> = sdkexport const CapabilitiesView = typeof sdk === 'undefined' ? undefined : sdk.CapabilitiesView// TRUE only on builds whose CapabilitiesView routes `fixedConnection` to the pinned// registry connection's backend. Older builds export CapabilitiesView WITHOUT the@@ -433,14 +433,15 @@ export function AdvancedProfileConfig({ bot, state, setState }: AdvancedProfileC{labeled('MCP servers',<div className="overflow-hidden rounded-md border border-(--ui-stroke-secondary)">- {McpTab && typeof host.getGateway === 'function' ? (+ {ConnectorsTab && typeof host.getGateway === 'function' ? (<div+ className="overflow-y-auto overscroll-contain"style={{minHeight: 220,maxHeight: 360}}>- <McpTab gateway={host.getGateway()} profile={backendScope} />+ <ConnectorsTab gateway={host.getGateway()} profile={backendScope} /></div>) : mcpList.length === 0 ? (<div className="px-1 py-2 text-center text-xs text-(--ui-text-tertiary)">{b.tools.noMcpServers}</div>diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.tsindex fc96d934ddf..bd3becc6699 100644--- a/apps/desktop/src/sdk/index.ts+++ b/apps/desktop/src/sdk/index.ts@@ -1550,7 +1550,7 @@ export const host = {/** The LIVE gateway instance for the active profile (null before the first* socket opens). Most plugins want `host.request`; this exists for SDK- * components that take a `HermesGateway` prop directly (e.g. `McpTab`),+ * components that take a `HermesGateway` prop directly (e.g. `ConnectorsTab`),* which need the instance, not just a JSON-RPC door. Re-read per use — the* active instance changes on a profile swap. */getGateway: (): HermesGateway | null => $gateway.get()@@ -1571,11 +1571,12 @@ export { CapabilitiesView } from '@/app/capabilities'// -- ui: the design language ---------------------------------------------------/** THE full MCP tab core Settings renders — per-server enable + OAuth sign-in- * + API-key setup + live probes, not a checkbox list. Route-decoupled so it- * renders anywhere (a plugin dialog); pass a live `gateway` (see- * `host.getGateway()`) and an optional `profile` to scope it to one bot. */-export { McpTab } from '@/app/capabilities/mcp/mcp-tab'+/** THE Connectors tab core Capabilities renders — managed apps, the user's+ * own MCP servers, plugin servers and the catalog, with per-server enable,+ * sign-in and live probes. Renders anywhere under the app router (a plugin+ * dialog); pass a live `gateway` (see `host.getGateway()`) and the `profile`+ * to scope it to one bot. */+export { ConnectorsTab } from '@/app/capabilities/connectors/connectors-tab'// Every contribution surface, plugin-reachable: register keybinds, palette// commands, routes, themes, panes, composer extensions, and bar items with// the same area ids + payload types core uses.@@ -1767,7 +1768,7 @@ export { Contribute, type ContributeProps } from '@/contrib/react/contribute'// -- contracts ----------------------------------------------------------------export type { Contribution } from '@/contrib/types'-/** The live gateway instance type — for typing the `gateway` prop `McpTab`+/** The live gateway instance type — for typing the `gateway` prop `ConnectorsTab`* takes; obtain the instance from `host.getGateway()`. */export type { HermesGateway } from '@/hermes'/** Grab-to-pan for overflow containers (boards, timelines, wide tables) —