diff --git a/frontend/src/lib/components/mcp/McpNotIncludedCard.svelte b/frontend/src/lib/components/mcp/McpNotIncludedCard.svelte
new file mode 100644
index 0000000000..df950b6636
--- /dev/null
+++ b/frontend/src/lib/components/mcp/McpNotIncludedCard.svelte
@@ -0,0 +1,103 @@
+
+
+{#if workspaces.length > 0}
+
+
(open = !open)}
+ >
+ {one ? 'Workspace' : 'Workspaces'}
+ {workspaces.map((w) => w.name).join(', ')}
+ {onTheirOwn
+ ? one
+ ? 'connects on its own'
+ : 'connect on their own'
+ : one
+ ? 'is not included'
+ : 'are not included'}
+
+ {#if open && readOnly}
+
+ {one ? 'Its role offers' : 'Their roles offer'} only scripts and flows as tools, which a read-only
+ client cannot run.
+
+ {:else if open}
+
{explanation}
+ {#if showUrl || onSelect}
+
+ {#each workspaces as w (w.id)}
+
+ {#if !one}
+
{w.name}
+ {/if}
+
+ {#if showUrl}
+ copyToClipboard(workspaceMcpUrl(w.id), true)}
+ >
+ Copy workspace URL
+
+ {/if}
+ {#if onSelect}
+ onSelect(w.id)}>
+ Select it
+
+ {/if}
+
+
+ {/each}
+
+ {/if}
+ {/if}
+
+{/if}
diff --git a/frontend/src/lib/components/mcp/McpWorkspaceAccessList.svelte b/frontend/src/lib/components/mcp/McpWorkspaceAccessList.svelte
index 5fbf842e14..98fc1dd89c 100644
--- a/frontend/src/lib/components/mcp/McpWorkspaceAccessList.svelte
+++ b/frontend/src/lib/components/mcp/McpWorkspaceAccessList.svelte
@@ -1,44 +1,25 @@
@@ -47,9 +28,7 @@
{#if restricted && badgeFirst}
Restricted
{/if}
- {accessLabel(workspace, access)}{connectsSeparately(workspace, all, covered, access)
- ? ', connect separately'
- : ''}
+ {accessLabel(workspace, access)}
{#if restricted && !badgeFirst}
Restricted
{/if}
@@ -59,26 +38,18 @@
{#if same}
{#if named}
- In {listed.map((w) => w.name).join(', ')}:
+ In {workspaces.map((w) => w.name).join(', ')}:
{/if}
- {@render access_(listed[0], false)}
+ {@render access_(workspaces[0], false)}
- {#if connectsSeparately(listed[0], all, covered, access)}
-
- {/if}
-{:else if listed.length > 1}
+{:else if workspaces.length > 1}
diff --git a/frontend/src/lib/components/mcp/workspaceAccess.test.ts b/frontend/src/lib/components/mcp/workspaceAccess.test.ts
index 69c2bf692f..f82289d621 100644
--- a/frontend/src/lib/components/mcp/workspaceAccess.test.ts
+++ b/frontend/src/lib/components/mcp/workspaceAccess.test.ts
@@ -2,7 +2,6 @@ import { describe, expect, it } from 'vitest'
import type { McpWorkspaceAccess } from '$lib/gen'
import {
accessLabel,
- connectsSeparately,
defaultConnection,
narrows,
restriction,
@@ -79,14 +78,6 @@ it('lists one toolset per connection, trimmed only for a bound workspace', () =>
expect(connectionToolset('full', ws('a', 'runnables'))).toBeUndefined()
})
-it('tools are part of a connection to their workspace alone', () => {
- expect(connectsSeparately(ws('a', 'runnables'), false, ['a'], 'full')).toBe(false)
- expect(connectsSeparately(ws('a', 'runnables'), false, ['a', 'b'], 'full')).toBe(true)
- expect(connectsSeparately(ws('a', 'runnables'), true, [], 'full')).toBe(true)
- expect(connectsSeparately(ws('a', 'runnables'), true, [], 'read')).toBe(false)
- expect(connectsSeparately(ws('a', 'read_only'), true, [], 'full')).toBe(false)
-})
-
describe('narrows', () => {
it('flags a workspace giving less or other than the pick', () => {
expect(narrows(ws('a', 'build_and_run'), 'full')).toBe(false)
diff --git a/frontend/src/lib/components/mcp/workspaceAccess.ts b/frontend/src/lib/components/mcp/workspaceAccess.ts
index 00fc87b2de..91c6b18245 100644
--- a/frontend/src/lib/components/mcp/workspaceAccess.ts
+++ b/frontend/src/lib/components/mcp/workspaceAccess.ts
@@ -140,17 +140,6 @@ export function defaultConnection(workspaces: McpWorkspaceAccess[]): ConnectionD
return { all: false, picked: [first.id], oneEach: asTools.length > 1 }
}
-/** Whether `workspace`, set to tools, needs its own connection next to the `covered` ones. A
- * read-only connection runs nothing there either way. */
-export function connectsSeparately(
- workspace: McpWorkspaceAccess,
- all: boolean,
- covered: string[],
- picked: McpAccess
-) {
- return workspace.access === 'runnables' && picked !== 'read' && (all || covered.length > 1)
-}
-
/** What a level means in a workspace, and whether its role set it. */
export function accessHint(workspace: McpWorkspaceAccess, picked: McpAccess): string {
const level = toolsetLevel(workspace, picked)
diff --git a/frontend/src/lib/components/settings/CreateToken.svelte b/frontend/src/lib/components/settings/CreateToken.svelte
index 5e8bffac1c..bf47152631 100644
--- a/frontend/src/lib/components/settings/CreateToken.svelte
+++ b/frontend/src/lib/components/settings/CreateToken.svelte
@@ -32,7 +32,8 @@
import Select from '../select/Select.svelte'
import Section from '../Section.svelte'
import ClipboardPanel from '../details/ClipboardPanel.svelte'
- import { narrows, workspaceMcpUrl } from '../mcp/workspaceAccess'
+ import { narrows, servedOn, workspaceMcpUrl } from '../mcp/workspaceAccess'
+ import McpNotIncludedCard from '../mcp/McpNotIncludedCard.svelte'
import McpAccessPicker, { type McpAccess } from '../mcp/McpAccessPicker.svelte'
import McpWorkspaceAccessList from '../mcp/McpWorkspaceAccessList.svelte'
import MultiSelect from '../select/MultiSelect.svelte'
@@ -400,11 +401,19 @@
const signInWorkspace = $derived(homeWorkspace ?? mcpBoundWorkspace)
const mcpAsTools = $derived(asTools(signInWorkspace))
// Shown only where a workspace gives other than the picked access.
- const mcpNarrowed = $derived(
- !!mcpWorkspaceAccess.current?.some(
- (w) => (mcpAllWorkspaces || mcpWorkspaces.includes(w.id)) && narrows(w, mcpAccess)
+ const mcpCovered = $derived(
+ (mcpWorkspaceAccess.current ?? []).filter(
+ (w) => mcpAllWorkspaces || mcpWorkspaces.includes(w.id)
)
)
+ const mcpServed = $derived(servedOn(mcpCovered, mcpAllWorkspaces, mcpAccess))
+ // Left out of a token reaching several workspaces, as on the consent page.
+ const mcpLeftOut = $derived(
+ mcpAccess === 'selected'
+ ? []
+ : mcpCovered.filter((w) => w.access === 'runnables' && !mcpServed.includes(w))
+ )
+ const mcpNarrowed = $derived(mcpServed.some((w) => narrows(w, mcpAccess)))
// The home page's tab also offers the workspace's own URL where `/api/mcp` is the main one.
const workspaceUrlOffered = $derived(!!homeWorkspace && !mcpAsTools)
const urlFor = (id: string | undefined) =>
@@ -447,13 +456,23 @@
{/if}
+ {#if mcpLeftOut.length > 0}
+
+ {
+ mcpAllWorkspaces = false
+ mcpWorkspaces = [id]
+ }}
+ />
+
+ {/if}
{/snippet}
{#snippet afterAccess()}
{#if canCarryAdmin}
@@ -640,7 +659,9 @@
{:else if mcpCreationMode}
-
MCP URL
+
{workspaceUrlOffered ? 'Global MCP URL' : 'MCP URL'}
Add it to your client as a remote MCP server.
@@ -655,7 +676,7 @@
{#if workspaceUrlOffered && homeWorkspace}
-
Or only {homeWorkspace}
+
{homeWorkspace} MCP URL
The sign-in skips the workspace choice, and the client reaches no other workspace.
diff --git a/frontend/src/lib/components/settings/EditTokenScopesModal.svelte b/frontend/src/lib/components/settings/EditTokenScopesModal.svelte
index 1b741f6d53..6f16158598 100644
--- a/frontend/src/lib/components/settings/EditTokenScopesModal.svelte
+++ b/frontend/src/lib/components/settings/EditTokenScopesModal.svelte
@@ -3,7 +3,8 @@
import { McpOauthService, UserService } from '$lib/gen'
import { resource } from 'runed'
import McpWorkspaceAccessList from '$lib/components/mcp/McpWorkspaceAccessList.svelte'
- import { narrows } from '$lib/components/mcp/workspaceAccess'
+ import { narrows, servedOn } from '$lib/components/mcp/workspaceAccess'
+ import McpNotIncludedCard from '$lib/components/mcp/McpNotIncludedCard.svelte'
import { sendUserToast } from '$lib/toast'
import Button from '../common/button/Button.svelte'
import Modal from '../common/modal/Modal.svelte'
@@ -110,11 +111,16 @@
async (on) => (on ? await McpOauthService.listMcpWorkspaceAccess({}).catch(() => []) : [])
)
const mcpAccess = $derived(mcpAccessOf(mcpScopes))
- const mcpNarrowed = $derived(
- (mcpWorkspaceAccess.current ?? []).some(
- (w) => warnsFor.includes(w.id) && narrows(w, mcpAccess)
- )
+ const mcpCovered = $derived(
+ (mcpWorkspaceAccess.current ?? []).filter((w) => warnsFor.includes(w.id))
)
+ const mcpServed = $derived(servedOn(mcpCovered, false, mcpAccess))
+ const mcpLeftOut = $derived(
+ mcpAccess === 'selected'
+ ? []
+ : mcpCovered.filter((w) => w.access === 'runnables' && !mcpServed.includes(w))
+ )
+ const mcpNarrowed = $derived(mcpServed.some((w) => narrows(w, mcpAccess)))
// Carried over as is, the picker knowing nothing of them: dropping the workspace list
// would widen the token to every workspace, dropping `mcp:session` would move a sign-in
// back to the endpoint tools once it is given `mcp:all` again.
@@ -269,14 +275,20 @@
{#if mcpNarrowed}
{/if}
+ {#if mcpLeftOut.length > 0}
+
+
+
+ {/if}
{/snippet}
diff --git a/frontend/src/lib/components/settings/TokenDisplay.svelte b/frontend/src/lib/components/settings/TokenDisplay.svelte
index 8dc37a6f32..98a77dafd3 100644
--- a/frontend/src/lib/components/settings/TokenDisplay.svelte
+++ b/frontend/src/lib/components/settings/TokenDisplay.svelte
@@ -35,6 +35,9 @@
{/if}
+ {#if workspaceMcpUrl}
+
Global MCP URL
+ {/if}
{#if mcpUrl}
Add it to your AI client as a remote MCP server.
@@ -42,7 +45,7 @@
{#if workspaceMcpUrl}
- Or only {workspace}
+ {workspace} MCP URL
{/if}
diff --git a/frontend/src/routes/(root)/(logged)/oauth/mcp_authorize/+page@(root).svelte b/frontend/src/routes/(root)/(logged)/oauth/mcp_authorize/+page@(root).svelte
index 73fa02e2de..51036f0d34 100644
--- a/frontend/src/routes/(root)/(logged)/oauth/mcp_authorize/+page@(root).svelte
+++ b/frontend/src/routes/(root)/(logged)/oauth/mcp_authorize/+page@(root).svelte
@@ -18,13 +18,13 @@
type McpAccess
} from '$lib/components/mcp/McpAccessPicker.svelte'
import McpAccessSection from '$lib/components/mcp/McpAccessSection.svelte'
+ import McpNotIncludedCard from '$lib/components/mcp/McpNotIncludedCard.svelte'
import McpWorkspaceAccessList from '$lib/components/mcp/McpWorkspaceAccessList.svelte'
import {
defaultConnection,
connectionToolset,
givesAnything,
- servedOn,
- workspaceMcpUrl
+ servedOn
} from '$lib/components/mcp/workspaceAccess'
import {
McpOauthService,
@@ -36,8 +36,6 @@
import { sendUserToast } from '$lib/toast'
import { copyToClipboard } from '$lib/utils'
import Pencil from 'lucide-svelte/icons/pencil'
- import ChevronDown from 'lucide-svelte/icons/chevron-down'
- import ChevronRight from 'lucide-svelte/icons/chevron-right'
import Copy from 'lucide-svelte/icons/copy'
import Check from 'lucide-svelte/icons/check'
@@ -198,7 +196,6 @@
const connectionTools = $derived(
served.some((w) => givesAnything(w, access)) ? connectionToolset(access, bound) : undefined
)
- let leftOutOpen = $state(false)
function coverDefault() {
const initial = defaultConnection(workspaceAccess)
allWorkspaces = initial.all
@@ -589,8 +586,6 @@
{#if served.length > 0}
w.id)}
- all={false}
{access}
/>
{:else}
@@ -603,61 +598,16 @@
{/if}
{#if leftOut.length > 0}
- {@const one = leftOut.length === 1}
-
-
(leftOutOpen = !leftOutOpen)}
- >
- {one ? 'Workspace' : 'Workspaces'}
- {leftOut.map((w) => w.name).join(', ')}
- {toolsOnly
- ? one
- ? 'connects on its own'
- : 'connect on their own'
- : one
- ? 'is not included'
- : 'are not included'}
-
- {#if leftOutOpen && access === 'read'}
-
- {one ? 'Its role offers' : 'Their roles offer'} only scripts and flows as tools, which
- a read-only client cannot run.
-
- {:else if leftOutOpen}
-
- Scripts and flows as tools need a connection of their own: add {one
- ? 'its'
- : 'each'} workspace URL to your AI client, or select it here instead.
-
-
- {#each leftOut as w (w.id)}
-
- {#if !one}
-
{w.name}
- {/if}
-
- copyToClipboard(workspaceMcpUrl(w.id), true)}
- >
- Copy workspace URL
-
- connectOnly(w.id)}>
- Select it
-
-
-
- {/each}
-
- {/if}
+
+
+
+ {/if}
{/if}