Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.8k
improvement(mcp): make the OAuth experience visible and verbally consistent#5829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8 ...aceId]/settings/components/mcp/components/mcp-server-form-modal/mcp-server-form-modal.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 34 additions & 50 deletions
84 apps/sim/app/workspace/[workspaceId]/settings/components/mcp/mcp.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -99,9 +99,10 @@ function ServerListItem({ | ||
| ) | ||
| // A live discovery failure whose stored status hasn't caught up yet would otherwise read as | ||
| // "0 tools"; surface it directly so a failed row reads as failed, not empty. | ||
| // Shown even when cached tools exist: a present discoveryError means the LATEST | ||
| // discovery failed, and silently showing the stale tool count would hide that. | ||
| const showDiscoveryError = | ||
| Boolean(discoveryError) && | ||
| tools.length === 0 && | ||
| server.connectionStatus !== 'error' && | ||
| server.connectionStatus !== 'disconnected' | ||
| const hasConnectionIssue = | ||
| @@ -114,38 +115,37 @@ function ServerListItem({ | ||
| <div className='flex min-w-0 flex-col justify-center gap-[1px]'> | ||
| <div className='flex items-center gap-1.5'> | ||
| <span className='max-w-[200px] truncate text-[var(--text-body)] text-sm'> | ||
| {server.name || 'Unnamed Server'} | ||
| {server.name || 'Unnamed server'} | ||
| </span> | ||
| <span className='text-[var(--text-muted)] text-caption'>({transportLabel})</span> | ||
| </div> | ||
| <p | ||
| className={cn( | ||
| 'truncate text-sm', | ||
| hasConnectionIssue ? 'text-[var(--text-error)]' : 'text-[var(--text-muted)]' | ||
| 'truncate text-caption', | ||
| hasConnectionIssue && !isConnecting | ||
| ? 'text-[var(--text-error)]' | ||
| : 'text-[var(--text-muted)]' | ||
| )} | ||
| > | ||
| {isRefreshing | ||
| ? 'Refreshing...' | ||
| : isLoadingTools && tools.length === 0 | ||
| ? 'Loading...' | ||
| : showDiscoveryError | ||
| ? discoveryError | ||
| : toolsLabel} | ||
| {isConnecting | ||
| ? 'Waiting for authorization...' | ||
| : isRefreshing | ||
| ? 'Refreshing...' | ||
| : isLoadingTools && tools.length === 0 | ||
| ? 'Loading...' | ||
| : showDiscoveryError | ||
| ? discoveryError | ||
| : toolsLabel} | ||
| </p> | ||
| </div> | ||
| <div className='flex flex-shrink-0 items-center gap-1'> | ||
| {canManage && server.authType === 'oauth' && server.connectionStatus !== 'connected' && ( | ||
| <Chip onClick={onAuthorize}>{isConnecting ? 'Reopen authorization' : 'Authorize'}</Chip> | ||
| )} | ||
| <RowActionsMenu | ||
| label='Server actions' | ||
| actions={[ | ||
| { label: 'Details', onSelect: onViewDetails }, | ||
| ...(canManage && server.authType === 'oauth' && server.connectionStatus !== 'connected' | ||
| ? [ | ||
| { | ||
| label: isConnecting ? 'Reopen authorization' : 'Authorize', | ||
| onSelect: onAuthorize, | ||
| }, | ||
| ] | ||
| : []), | ||
| ...(canManage | ||
| ? [ | ||
| { | ||
| @@ -193,11 +193,7 @@ export function MCP() { | ||
| isLoading: serversLoading, | ||
| error: serversError, | ||
| } = useMcpServers(workspaceId) | ||
| const { | ||
| data: mcpToolsData = [], | ||
| error: toolsError, | ||
| toolsStateByServer, | ||
| } = useMcpToolsQuery(workspaceId) | ||
| const { data: mcpToolsData = [], toolsStateByServer } = useMcpToolsQuery(workspaceId) | ||
| const { data: storedTools = [], refetch: refetchStoredTools } = useStoredMcpTools(workspaceId) | ||
| const forceRefreshToolsMutation = useForceRefreshMcpTools() | ||
| const forceRefreshTools = forceRefreshToolsMutation.mutate | ||
| @@ -399,15 +395,10 @@ export function MCP() { | ||
| return issues | ||
| } | ||
| // Only a failure to load the server LIST replaces the list. A tool-discovery failure | ||
| // (`toolsError`) must not blank the page — the servers still render, each row surfacing its | ||
| // own discovery state via `toolsStateByServer`, with a non-blocking notice above the list. | ||
| // Only a failure to load the server LIST replaces the list. A tool-discovery failure must | ||
| // not blank the page — the servers still render, each row surfacing its own discovery | ||
| // state via `toolsStateByServer`. | ||
| const listError = serversError | ||
| // Any per-server discovery failure — even a partial one where other servers succeeded (which | ||
| // suppresses the aggregate `toolsError`) — so the notice below still surfaces it. | ||
| const hasDiscoveryError = | ||
| Boolean(toolsError) || | ||
| Array.from(toolsStateByServer.values()).some((state) => state.error != null) | ||
| const hasServers = servers && servers.length > 0 | ||
| const showNoResults = searchTerm.trim() && filteredServers.length === 0 && servers.length > 0 | ||
| @@ -418,15 +409,13 @@ export function MCP() { | ||
| const refreshAction = getRefreshActionState({ | ||
| mutationStatus: isCurrentRefresh ? refreshServerMutation.status : 'idle', | ||
| connectionStatus: isCurrentRefresh ? refreshServerMutation.data?.status : undefined, | ||
| authType: server.authType, | ||
| error: isCurrentRefresh ? refreshServerMutation.data?.error : undefined, | ||
| workflowsUpdated: isCurrentRefresh ? refreshServerMutation.data?.workflowsUpdated : undefined, | ||
| }) | ||
| return ( | ||
| <SettingsPanel | ||
| back={{ text: 'MCP tools', icon: ArrowLeft, onSelect: handleBackToList }} | ||
| title={server.name || 'Unnamed Server'} | ||
| title={server.name || 'Unnamed server'} | ||
| actions={ | ||
| canEdit | ||
| ? [ | ||
| @@ -447,8 +436,8 @@ export function MCP() { | ||
| <SettingsSection label='Server'> | ||
| <div className='flex flex-col gap-4.5'> | ||
| <div className='flex flex-col gap-2'> | ||
| <span className='text-[var(--text-muted)] text-caption'>Server Name</span> | ||
| <p className='text-[var(--text-body)] text-sm'>{server.name || 'Unnamed Server'}</p> | ||
| <span className='text-[var(--text-muted)] text-caption'>Server name</span> | ||
| <p className='text-[var(--text-body)] text-sm'>{server.name || 'Unnamed server'}</p> | ||
| </div> | ||
| <div className='flex flex-col gap-2'> | ||
| @@ -487,9 +476,7 @@ export function MCP() { | ||
| await startOauthForServer(server.id) | ||
| }} | ||
| > | ||
| {connectingOauthServers.has(server.id) | ||
| ? 'Reopen authorization window' | ||
| : 'Connect with OAuth'} | ||
| {connectingOauthServers.has(server.id) ? 'Reopen authorization' : 'Authorize'} | ||
| </Chip> | ||
| </div> | ||
| </div> | ||
| @@ -651,7 +638,7 @@ export function MCP() { | ||
| search={{ | ||
| value: searchTerm, | ||
| onChange: setSearchTerm, | ||
| placeholder: 'Search MCPs...', | ||
| placeholder: 'Search servers...', | ||
| }} | ||
| actions={ | ||
| canEdit | ||
| @@ -669,21 +656,18 @@ export function MCP() { | ||
| > | ||
waleedlatif1 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| {listError ? ( | ||
| <div className='flex h-full flex-col items-center justify-center gap-2'> | ||
| <p className='text-[var(--text-error)] text-xs leading-tight'> | ||
| <p className='text-[var(--text-error)] text-small leading-tight'> | ||
| {getErrorMessage(listError, 'Failed to load MCP servers')} | ||
| </p> | ||
| </div> | ||
| ) : serversLoading ? null : !hasServers ? ( | ||
| ) : serversLoading ? ( | ||
| <SettingsEmptyState>Loading...</SettingsEmptyState> | ||
| ) : !hasServers ? ( | ||
| <SettingsEmptyState> | ||
| {canEdit ? 'Click "Add server" above to get started' : 'No MCP servers configured'} | ||
| </SettingsEmptyState> | ||
| ) : ( | ||
| <div className='flex flex-col gap-2'> | ||
| {hasDiscoveryError && ( | ||
| <p className='text-[var(--text-error)] text-xs leading-tight'> | ||
| {getErrorMessage(toolsError, 'Some tools could not be discovered')} | ||
| </p> | ||
| )} | ||
| {filteredServers.map((server) => { | ||
| if (!server?.id) return null | ||
| const tools = toolsByServer[server.id] || [] | ||
| @@ -749,8 +733,8 @@ export function MCP() { | ||
| onOpenChange={(open) => { | ||
| if (!open) setServerToDeleteId(null) | ||
| }} | ||
| srTitle='Delete MCP Server' | ||
| title='Delete MCP Server' | ||
| srTitle='Delete MCP server' | ||
| title='Delete MCP server' | ||
| text={[ | ||
| 'Are you sure you want to delete ', | ||
| { | ||
17 changes: 0 additions & 17 deletions
17 apps/sim/app/workspace/[workspaceId]/settings/components/mcp/refresh-action-state.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 1 addition & 14 deletions
15 apps/sim/app/workspace/[workspaceId]/settings/components/mcp/refresh-action-state.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2 apps/sim/app/workspace/[workspaceId]/settings/components/mcp/server-tools-label.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2 apps/sim/app/workspace/[workspaceId]/settings/components/mcp/server-tools-label.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.