diff --git a/frontend/src/lib/components/mcp/workspaceAccess.test.ts b/frontend/src/lib/components/mcp/workspaceAccess.test.ts
index 5e2ac529d3..4c45262798 100644
--- a/frontend/src/lib/components/mcp/workspaceAccess.test.ts
+++ b/frontend/src/lib/components/mcp/workspaceAccess.test.ts
@@ -6,6 +6,7 @@ import {
defaultConnection,
restriction,
servedOn,
+ connectionToolset,
toolsetLevel
} from './workspaceAccess'
@@ -68,6 +69,15 @@ it('lists the session tools of the lower of the picked access and the workspace
expect(toolsetLevel(ws('a', 'build_and_run'), 'selected')).toBeUndefined()
})
+it('lists one toolset per connection, trimmed only for a bound workspace', () => {
+ expect(connectionToolset('full', undefined)).toBe('full')
+ expect(connectionToolset('read_run', undefined)).toBe('read_run')
+ expect(connectionToolset('full', { ...ws('a', 'read_and_run'), limited: true })).toBe('read_run')
+ expect(connectionToolset('full', ws('a', 'read_only'))).toBe('read')
+ expect(connectionToolset('full', ws('a', 'run_and_edit'))).toBe('full')
+ 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)
diff --git a/frontend/src/lib/components/mcp/workspaceAccess.ts b/frontend/src/lib/components/mcp/workspaceAccess.ts
index 9652829db5..61ee23f384 100644
--- a/frontend/src/lib/components/mcp/workspaceAccess.ts
+++ b/frontend/src/lib/components/mcp/workspaceAccess.ts
@@ -78,6 +78,21 @@ export function toolsetLevel(
return 'full'
}
+/** The tools a connection lists. One covering several workspaces lists the picked level's, and
+ * a role refuses per call what it does not allow; one bound to a workspace lists what its role's
+ * MCP limit, or a role that cannot run, leaves. `bound` is that workspace. */
+export function connectionToolset(
+ picked: McpAccess,
+ bound: McpWorkspaceAccess | undefined
+): ToolsetLevel | undefined {
+ if (picked === 'selected') return undefined
+ if (!bound) return picked
+ if (!givesAnything(bound, picked) || bound.access === 'runnables') return undefined
+ if (bound.access === 'read_only') return 'read'
+ if (bound.limited && bound.access === 'read_and_run' && picked === 'full') return 'read_run'
+ return picked
+}
+
/** The MCP URL connecting to this workspace alone. */
export function workspaceMcpUrl(id: string): string {
return `${apiBaseUrl('mcp')}/api/mcp/w/${id}/mcp`
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 fd8d3226b0..1898273552 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
@@ -25,6 +25,7 @@
import {
accessLabel,
defaultConnection,
+ connectionToolset,
givesAnything,
restriction,
servedOn,
@@ -171,6 +172,7 @@
const coveredIds = $derived(isGateway ? pickedWorkspaces : [workspaceId])
const covered = $derived(workspaceAccess.filter((w) => coversAll || coveredIds.includes(w.id)))
const served = $derived(servedOn(covered, coversAll, access))
+ const bound = $derived(!coversAll && covered.length === 1 ? covered[0] : undefined)
const unavailable = $derived(
!coversAll && served.length > 0 && served.every((w) => !givesAnything(w, access))
)
@@ -206,7 +208,8 @@
key,
label,
ws,
- level,
+ // One list per connection: the picked level's, or what a bound workspace leaves.
+ tools: givesAnything(ws[0], access) ? connectionToolset(access, bound) : undefined,
restricted: restriction(ws[0], access),
hint: ws.every((w) => w.limited) ? `${hint} Set by your role.` : hint
}
@@ -624,8 +627,8 @@
{/if}
{group.hint}
{#if !named}{@render pen()}{/if}
- {#if group.level}
- {@const tools = open ? toolset(group.level) : undefined}
+ {#if group.tools}
+ {@const tools = open ? toolset(group.tools) : undefined}