Skip to content

fix(ui-rewrite): fetch tools and activate mcp server after OAuth, add…#5076

Open
marekdano wants to merge 1 commit into
epic/ui-rewritefrom
5026-fetch-tools-and-activate-automatically
Open

fix(ui-rewrite): fetch tools and activate mcp server after OAuth, add…#5076
marekdano wants to merge 1 commit into
epic/ui-rewritefrom
5026-fetch-tools-and-activate-automatically

Conversation

@marekdano
Copy link
Copy Markdown
Collaborator

Summary

Fixes three related gaps in the OAuth MCP server creation flow.

Closes #5026.

  • Tools not fetched after OAuth: ExposeComponentsForm now refetches
    tools/resources/prompts when oauthNotification transitions to "success", using a
    useEffect that calls refetchTools, refetchResources, and refetchPrompts. The backend
    /oauth/fetch-tools/{id} endpoint is called immediately after OAuth completes and its
    result surfaced as a fetchToolsNotification banner.
  • Server not activated after OAuth: useMCPServerForm now calls toggleEnabled(id, true)
    immediately after a successful OAuth handshake, so the gateway is active before
    ExposeComponentsForm renders.
  • Missing Activate / Deactivate in overflow menu: ServerActionsMenu gains an optional
    onToggleEnabled prop. When provided it renders "Deactivate" for an enabled server and
    "Activate" for a disabled one. The handler lives in Servers.tsx and calls the new
    serversApi.toggleEnabled API helper, then refetches the server list.

Additional changes made while addressing the above:

  • InlineNotification component (new): Extracts the repeated notification markup from
    ExposeComponentsForm and MCPServerForm into a single reusable component with correct
    ARIA roles (role="alert" / role="status"), decorative icons, and an accessible dismiss
    button. Accepts an optional dismissLabel prop so stacked notifications have distinct
    accessible names for screen readers.
  • parseApiError utility: Extended to handle {"detail":{"message":"...","success":false}}
    in addition to plain-string detail and validation-error arrays. All inline error extraction
    in useMCPServerForm is replaced with calls to parseApiError.
  • useQuery.refetch stability: refetch is now wrapped in useCallback so its reference
    is stable across re-renders, preventing unnecessary useEffect re-runs in consumers that
    list refetch as a dependency.
  • Security: sanitizeError is applied to the activation-failure log in useMCPServerForm,
    consistent with the rest of the codebase.

Changed files

File Change
client/src/api/servers.ts Add toggleEnabled and fetchToolsAfterOAuth API methods
client/src/components/ui/inline-notification.tsx New reusable notification component
client/src/components/gateways/ExposeComponentsForm.tsx Wire fetchToolsNotification, add refetch useEffect, use InlineNotification
client/src/components/mcp-servers/MCPServerForm.tsx Surface fetchToolsNotification, use InlineNotification
client/src/components/servers/ServerActionsMenu.tsx Add onToggleEnabled prop and menu item
client/src/components/servers/ServersTable.tsx Pass onToggleEnabled through to ServerActionsMenu
client/src/pages/Servers.tsx Add handleToggleEnabled handler
client/src/hooks/useMCPServerForm.ts Auto-activate gateway and fetch tools after OAuth; parseApiError; fetchToolsNotification state
client/src/hooks/useQuery.ts Stabilise refetch reference with useCallback
client/src/lib/errorUtils.ts Handle detail as an object with a message property

Test coverage

New and updated tests across six files (450 passing, 2 skipped):

  • inline-notification.test.tsx — ARIA roles, colour classes, dismiss button, custom dismissLabel
  • useQuery.test.ts — stable refetch reference, GET success/error, enabled: false, manual execute
  • errorUtils.test.ts — all parseApiError branches including the new object-detail case
  • servers.test.tstoggleEnabled, fetchToolsAfterOAuth, triggerOAuthAuthorization (popup, postMessage, cancellation, foreign-source filtering)
  • ServerActionsMenu.test.tsx — Activate/Deactivate item rendering and callbacks
  • useMCPServerForm.test.tsfetchToolsNotification lifecycle (success, nested-detail error, plain-string error, clear); handleSubmit error parsing for create and update

… activate/deactivate menu action

Signed-off-by: Marek Dano <Marek.Dano@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant