diff --git a/frontend/src/lib/components/settings/CreateToken.svelte b/frontend/src/lib/components/settings/CreateToken.svelte
index 259c7eae2e..1db9bda07b 100644
--- a/frontend/src/lib/components/settings/CreateToken.svelte
+++ b/frontend/src/lib/components/settings/CreateToken.svelte
@@ -164,12 +164,17 @@
const scopeWorkspaceId = $derived(
isAllWorkspaces ? $workspaceStore || '' : newTokenWorkspace || $workspaceStore || ''
)
+ // Undefined wherever the workspace is: `/api/mcp/w/undefined/mcp` reads like a real URL
+ // and is copyable, so the OAuth panel withholds it rather than showing a broken one. The
+ // token branch guards the same case by disabling its generate button.
const mcpUrl = $derived(
isAllWorkspaces
? `${window.location.origin}/api/mcp/gateway`
- : `${window.location.origin}/api/mcp/w/${newTokenWorkspace}/mcp`
+ : newTokenWorkspace
+ ? `${window.location.origin}/api/mcp/w/${newTokenWorkspace}/mcp`
+ : undefined
)
- const mcpBaseUrl = $derived(`${mcpUrl}?token=`)
+ const mcpBaseUrl = $derived(`${mcpUrl ?? ''}?token=`)
$effect(() => {
const requestedMcpMode = mcpOnly || openWithMcpMode
@@ -254,14 +259,18 @@
{/if}
-
Pick a workspace to get its MCP URL.
+ {/if} {#if !mcpOnly}