Skip to content

fix(manage-ui): fix user-scoped MCP credential card refresh#2794

Merged
omar-inkeep merged 1 commit intomainfrom
fix/user-scoped-mcp-credential-refresh
Mar 20, 2026
Merged

fix(manage-ui): fix user-scoped MCP credential card refresh#2794
omar-inkeep merged 1 commit intomainfrom
fix/user-scoped-mcp-credential-refresh

Conversation

@omar-inkeep
Copy link
Contributor

@omar-inkeep omar-inkeep commented Mar 20, 2026

Summary

  • Fetch user-scoped credential server-side in page.tsx (matching the existing project-scoped pattern) instead of via a client-side React Query hook
  • router.refresh() now correctly re-fetches credential data after OAuth connect and credential delete, so the "Your Connection" card updates immediately
  • Remove dead lib/query/credentials.ts (no remaining consumers)

Test plan

  • Navigate to a user-scoped MCP server detail page
  • Click "Connect", complete OAuth — credential card should appear without manual refresh
  • Click "Delete" on the credential — Connect button should reappear without manual refresh
  • Verify project-scoped MCP server detail page still works as before

🤖 Generated with Claude Code

…ter connect/disconnect

Fetch user-scoped credential server-side in page.tsx (matching the
project-scoped pattern) instead of via a client-side React Query hook.
This ensures router.refresh() after OAuth connect or credential delete
re-fetches the credential data, so the "Your Connection" card updates
without a manual page refresh.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Mar 20, 2026

🦋 Changeset detected

Latest commit: 1ae64de

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@inkeep/agents-manage-ui Patch
@inkeep/agents-api Patch
@inkeep/agents-cli Patch
@inkeep/agents-core Patch
@inkeep/agents-email Patch
@inkeep/agents-mcp Patch
@inkeep/agents-sdk Patch
@inkeep/agents-work-apps Patch
@inkeep/ai-sdk-provider Patch
@inkeep/create-agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Mar 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agents-api Ready Ready Preview, Comment Mar 20, 2026 10:11pm
agents-docs Ready Ready Preview, Comment Mar 20, 2026 10:11pm
agents-manage-ui Ready Ready Preview, Comment Mar 20, 2026 10:11pm

Request Review

@pullfrog
Copy link
Contributor

pullfrog bot commented Mar 20, 2026

TL;DR — Fixes the user-scoped MCP credential card not updating after OAuth connect/disconnect by replacing a client-side React Query hook with server-side data fetching. The credential is now fetched in the RSC page and passed as a prop, so a router.refresh() after connect/disconnect is enough to show the updated state.

Key changes

  • Move user-scoped credential fetch from client query to server component — the page now calls fetchUserScopedCredential at the RSC level and passes the result as a userCredential prop, eliminating the stale-cache problem that prevented the card from reflecting connect/disconnect actions.
  • Delete useUserScopedCredentialQuery hook — removes the now-unused React Query wrapper in credentials.ts, along with its query keys and loading state.
  • Remove loading skeleton for credential card — since the data arrives server-side, the isLoadingCredential intermediate state and its "Checking your connection status..." text are no longer needed.

Summary | 4 files | 1 commit | base: mainfix/user-scoped-mcp-credential-refresh


Server-side credential fetching replaces client-side query

Before: The user-scoped credential was fetched client-side via a useUserScopedCredentialQuery React Query hook inside ViewMCPServerDetailsUserScope. After connecting or disconnecting OAuth, router.refresh() only re-ran the RSC — but the credential lived in client-side query cache, so the card stayed stale until a full page reload.
After: The credential is fetched server-side in the RSC MCPPage and passed as the userCredential prop. A router.refresh() now re-fetches server data and React reconciles the new prop, immediately reflecting the updated connection state.

Why not just invalidate the React Query cache? The component already calls router.refresh() after connect/disconnect, which is the idiomatic Next.js way to re-fetch server data. Keeping a parallel client-side query meant two sources of truth that could drift. Moving to a single server-side fetch is simpler and guarantees consistency.

page.tsx · view-mcp-server-details-user-scope.tsx · credentials.ts

Pullfrog  | View workflow run | Triggered by Pullfrogpullfrog.com𝕏

Copy link
Contributor

@pullfrog pullfrog bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean fix — moves the user-scoped credential fetch to the server component to match the existing project-scoped pattern, making router.refresh() work correctly for both connect and disconnect flows. The deleted query file has no remaining consumers. No issues found.

Pullfrog  | View workflow runpullfrog.com𝕏

Copy link
Contributor

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review Summary

(0) Total Issues | Risk: Low


This is a clean, well-scoped fix that aligns the user-scoped MCP credential handling with the existing project-scoped pattern. The changes are minimal and correct.

✅ What's Good

  1. Pattern consistency — User-scoped credentials now follow the same server-side fetch pattern used by project-scoped credentials in ViewMCPServerDetailsProjectScope

  2. Correct router.refresh() usage — Server components re-fetch data on router.refresh(), which is exactly why the old client-side React Query hook didn't work with this pattern. The fix correctly moves the fetch server-side.

  3. Dead code removallib/query/credentials.ts (38 lines) was removed with no remaining consumers. Verified via grep.

  4. Loading state removal is appropriate — Server-side fetching completes before render, so the "Checking your connection status..." loading state is no longer needed. The page will show a skeleton/suspense boundary if needed at a higher level.


✅ APPROVE

Summary: This is a straightforward and correct fix. The server-side fetching pattern ensures router.refresh() properly re-fetches credential data after OAuth connect and delete operations. Ship it! 🚀

Discarded (1)
Location Issue Reason Discarded
page.tsx:14-17 Sequential await creates waterfall Reviewer self-discarded: the second fetch (fetchUserScopedCredential) depends on tool.id from the first fetch, so they cannot be parallelized. Pattern is appropriate for this use case.
Reviewers (2)
Reviewer Returned Main Findings Consider While You're Here Inline Comments Pending Recs Discarded
pr-review-frontend 1 0 0 0 0 0 1
pr-review-standards 0 0 0 0 0 0 0
Total 1 0 0 0 0 0 1

@github-actions github-actions bot deleted a comment from claude bot Mar 20, 2026
@omar-inkeep omar-inkeep added this pull request to the merge queue Mar 20, 2026
Merged via the queue into main with commit 0b4669f Mar 20, 2026
19 of 20 checks passed
@omar-inkeep omar-inkeep deleted the fix/user-scoped-mcp-credential-refresh branch March 20, 2026 22:36
dimaMachina pushed a commit that referenced this pull request Mar 20, 2026
…ter connect/disconnect (#2794)

Fetch user-scoped credential server-side in page.tsx (matching the
project-scoped pattern) instead of via a client-side React Query hook.
This ensures router.refresh() after OAuth connect or credential delete
re-fetches the credential data, so the "Your Connection" card updates
without a manual page refresh.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.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