mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-03 16:10:37 +00:00
feat: one access select in the token form and the consent page, workspace url beside /api/mcp
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e0bded292f
commit
168861a40e
@@ -37,13 +37,10 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import ToggleButtonGroup from '$lib/components/common/toggleButton-v2/ToggleButtonGroup.svelte'
|
||||
import ToggleButton from '$lib/components/common/toggleButton-v2/ToggleButton.svelte'
|
||||
import McpScopeSelector from './McpScopeSelector.svelte'
|
||||
import Select from '$lib/components/select/Select.svelte'
|
||||
import McpToolList from './McpToolList.svelte'
|
||||
import { toolset } from './toolsets.svelte'
|
||||
import Section from '$lib/components/Section.svelte'
|
||||
import McpToolsModal from './McpToolsModal.svelte'
|
||||
import { Button } from '$lib/components/common'
|
||||
import type { Snippet } from 'svelte'
|
||||
import { resource } from 'runed'
|
||||
import Alert from '$lib/components/common/alert/Alert.svelte'
|
||||
@@ -64,8 +61,8 @@
|
||||
fullLabel?: string
|
||||
/** Rendered between the access choice and the tool list. */
|
||||
afterAccess?: Snippet
|
||||
/** A select, with the chosen level's meaning under it, for a narrow dialog. */
|
||||
asSelect?: boolean
|
||||
/** Offers the chosen level's tools in a dialog. */
|
||||
showTools?: boolean
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -76,7 +73,7 @@
|
||||
initialScopes = [],
|
||||
fullLabel = 'Build and run',
|
||||
afterAccess,
|
||||
asSelect = false
|
||||
showTools = false
|
||||
}: Props = $props()
|
||||
|
||||
const LEVELS = $derived([
|
||||
@@ -104,9 +101,8 @@
|
||||
: ACCESS_SCOPES[access]
|
||||
})
|
||||
|
||||
let toolsCollapsed = $state(true)
|
||||
let toolsOpen = $state(false)
|
||||
const toolsetAccess = $derived(access === 'selected' ? undefined : access)
|
||||
const tools = $derived(toolsetAccess && !toolsCollapsed ? toolset(toolsetAccess) : undefined)
|
||||
|
||||
// Each workspace's access, as the chat resolves it, to compare with the level picked.
|
||||
const workspaceAccess = resource(
|
||||
@@ -127,30 +123,16 @@
|
||||
<div class="flex flex-col gap-4">
|
||||
<div>
|
||||
<span class="block mb-1 text-emphasis text-xs font-semibold">Access</span>
|
||||
{#if asSelect}
|
||||
<Select items={LEVELS} bind:value={() => access, (v) => v && (access = v as McpAccess)} />
|
||||
{#if access}
|
||||
<p class="mt-1 text-2xs text-secondary">{ACCESS_HINTS[access]}</p>
|
||||
{/if}
|
||||
{:else}
|
||||
<ToggleButtonGroup bind:selected={access} allowEmpty={false}>
|
||||
{#snippet children({ item })}
|
||||
<ToggleButton {item} value="full" label={fullLabel} tooltip={ACCESS_HINTS.full} />
|
||||
<ToggleButton
|
||||
{item}
|
||||
value="read_run"
|
||||
label="Read and run"
|
||||
tooltip={ACCESS_HINTS.read_run}
|
||||
/>
|
||||
<ToggleButton {item} value="read" label="Read only" tooltip={ACCESS_HINTS.read} />
|
||||
<ToggleButton
|
||||
{item}
|
||||
value="selected"
|
||||
label="Scripts and flows as tools"
|
||||
tooltip={ACCESS_HINTS.selected}
|
||||
/>
|
||||
{/snippet}
|
||||
</ToggleButtonGroup>
|
||||
<Select items={LEVELS} bind:value={() => access, (v) => v && (access = v as McpAccess)} />
|
||||
{#if access}
|
||||
<div class="mt-1 flex items-start justify-between gap-2">
|
||||
<p class="text-2xs text-secondary">{ACCESS_HINTS[access]}</p>
|
||||
{#if showTools && toolsetAccess}
|
||||
<Button variant="subtle" unifiedSize="xs" onClick={() => (toolsOpen = true)}>
|
||||
Show tools
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{#if narrowed.length > 0}
|
||||
@@ -163,24 +145,13 @@
|
||||
</Alert>
|
||||
{/if}
|
||||
{@render afterAccess?.()}
|
||||
<!-- A dialog's caller lists the tools, and the select's caption says what a selection is. -->
|
||||
{#if toolsetAccess && !asSelect}
|
||||
<Section label="Tools the client gets" small collapsable bind:collapsed={toolsCollapsed}>
|
||||
<div class="-mt-2">
|
||||
<McpToolList {tools} />
|
||||
</div>
|
||||
</Section>
|
||||
{/if}
|
||||
{#if access === 'selected'}
|
||||
{#if !asSelect}
|
||||
<p class="text-2xs text-secondary -mt-2">
|
||||
The client can run these scripts and flows and nothing else: it cannot explore the
|
||||
workspace, read runs, build, or run anything outside the selection.
|
||||
</p>
|
||||
{/if}
|
||||
<!-- A selection names paths of one workspace, so switching workspace starts it over. -->
|
||||
{#key workspaceId}
|
||||
<McpScopeSelector {workspaceId} bind:scope={selection} initialScope={initialSelection} />
|
||||
{/key}
|
||||
{/if}
|
||||
</div>
|
||||
{#if toolsetAccess}
|
||||
<McpToolsModal bind:open={toolsOpen} level={toolsetAccess} />
|
||||
{/if}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<script lang="ts">
|
||||
import Popover from '$lib/components/Popover.svelte'
|
||||
import { Badge } from '$lib/components/common'
|
||||
import type { ToolsetEntry } from './toolsets.svelte'
|
||||
|
||||
let { tools }: { tools: ToolsetEntry[] | undefined } = $props()
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-1">
|
||||
<span class="text-2xs text-secondary">
|
||||
{tools ? `${tools.length} tools. Hover one for what it does.` : 'Loading tools…'}
|
||||
</span>
|
||||
<div class="flex flex-wrap gap-1">
|
||||
{#each tools ?? [] as tool (tool.name)}
|
||||
<Popover notClickable>
|
||||
{#snippet text()}
|
||||
<div class="text-xs max-w-md">{tool.description}</div>
|
||||
{/snippet}
|
||||
<Badge rounded small color="gray">{tool.name}</Badge>
|
||||
</Popover>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
@@ -433,6 +433,7 @@
|
||||
: mcpWorkspaces}
|
||||
bind:scopes={mcpScopes}
|
||||
bind:access={() => mcpAccess, setMcpAccess}
|
||||
showTools
|
||||
>
|
||||
{#snippet afterAccess()}
|
||||
{#if canCarryAdmin}
|
||||
@@ -640,6 +641,15 @@
|
||||
{/if}
|
||||
</p>
|
||||
</div>
|
||||
{#if lockWorkspace && !mcpAsTools && mcpBoundWorkspace}
|
||||
<div class="flex flex-col gap-1">
|
||||
<span class="text-xs font-semibold text-emphasis">Or only {mcpBoundWorkspace}</span>
|
||||
<ClipboardPanel content={workspaceMcpUrl(mcpBoundWorkspace)} size="sm" />
|
||||
<p class="text-2xs text-secondary">
|
||||
The sign-in skips the workspace choice, and the client reaches no other workspace.
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if mcpUrlPolicy === 'token'}
|
||||
<Section label="Use a token instead of signing in" small collapsable collapsed>
|
||||
|
||||
@@ -519,10 +519,18 @@
|
||||
Your role gives scripts and flows as tools, one workspace per connection.
|
||||
</p>
|
||||
{:else if toolsAlone}
|
||||
<p class="text-xs text-primary">{covered[0].name} only</p>
|
||||
<Button variant="subtle" unifiedSize="xs" btnClasses="w-fit" onClick={coverDefault}>
|
||||
Back to my other workspaces
|
||||
</Button>
|
||||
<div class="flex items-center gap-1">
|
||||
<p class="text-xs text-primary">{covered[0].name} only</p>
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="xs"
|
||||
iconOnly
|
||||
startIcon={{ icon: Pencil }}
|
||||
aria-label="Change workspaces"
|
||||
title="Change workspaces"
|
||||
onClick={coverDefault}
|
||||
/>
|
||||
</div>
|
||||
{:else}
|
||||
<Toggle
|
||||
bind:checked={allWorkspaces}
|
||||
@@ -713,7 +721,6 @@
|
||||
<McpAccessPicker
|
||||
workspaceId={scopeWorkspaceId ?? ''}
|
||||
initialScopes={scopes}
|
||||
asSelect
|
||||
bind:scopes
|
||||
bind:access={() => access, setAccess}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user