From 8b1a64004d4a19fa288c60453ce40839905e0f10 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Thu, 17 Sep 2026 22:46:19 +0800 Subject: [PATCH] feat(mcp): show the endpoint token as the drawer's second step The "endpoint ready, save the token" dialog stacked the token, the URL and three client snippets into one tall modal on top of the drawer. The drawer now has two steps like the embed and IM channel drawers: "Configure" and "Connect". Creating an endpoint advances to the Connect step in place, where the one-time token, the endpoint URL and the client snippets (in tabs, one visible at a time) are read; Finish closes the drawer. Rotating a token and the card's "Connection info" action open the same step, the latter with the token placeholder. The separate dialog and the "show client configuration" button are gone. Co-Authored-By: Claude Fable 5.1 --- frontend/src/i18n/locales/en-US.ts | 4 +- frontend/src/i18n/locales/ja-JP.ts | 4 +- frontend/src/i18n/locales/ko-KR.ts | 4 +- frontend/src/i18n/locales/ru-RU.ts | 4 +- frontend/src/i18n/locales/zh-CN.ts | 4 +- .../McpServerIntegrationSettings.vue | 458 +++++++++++------- 6 files changed, 311 insertions(+), 167 deletions(-) diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index 60dc07c7..7c9ff319 100755 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -6719,8 +6719,10 @@ export default { rateLimitLabel: 'Max calls per minute', rateLimitHint: 'Applies to all tool calls on this endpoint; clients get a rate-limit error above it.', sectionConnect: 'Connection', + stepConfig: 'Configure', + stepConnect: 'Connect', + snippetsLabel: 'Client configuration', connectHintExisting: 'The token was shown once at creation (current token starts with {hint}…). Rotate the token to get a new one.', - showSnippets: 'Show client configuration', tokenDialogTitle: 'Endpoint ready, save the token', connectDialogTitle: 'Connect to this endpoint', tokenOnce: 'This token is shown only once. Copy it now and store it somewhere safe.', diff --git a/frontend/src/i18n/locales/ja-JP.ts b/frontend/src/i18n/locales/ja-JP.ts index 21a8c69a..dfb15ad3 100644 --- a/frontend/src/i18n/locales/ja-JP.ts +++ b/frontend/src/i18n/locales/ja-JP.ts @@ -6719,8 +6719,10 @@ export default { rateLimitLabel: '1 分あたりの最大呼び出し数', rateLimitHint: 'このエンドポイントのすべてのツール呼び出しに適用されます。', sectionConnect: '接続情報', + stepConfig: '設定', + stepConnect: '接続', + snippetsLabel: 'クライアント設定', connectHintExisting: 'トークンは作成時に一度だけ表示されました(現在のトークンは {hint}… で始まります)。再取得するにはローテーションしてください。', - showSnippets: 'クライアント設定例を表示', tokenDialogTitle: 'エンドポイントの準備完了。トークンを保存してください', connectDialogTitle: 'このエンドポイントに接続', tokenOnce: 'このトークンは一度しか表示されません。今すぐコピーして安全に保管してください。', diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts index 69f163f2..4658d752 100755 --- a/frontend/src/i18n/locales/ko-KR.ts +++ b/frontend/src/i18n/locales/ko-KR.ts @@ -747,8 +747,10 @@ export default { rateLimitLabel: '분당 최대 호출 수', rateLimitHint: '이 엔드포인트의 모든 도구 호출에 적용되며, 초과 시 클라이언트는 제한 오류를 받습니다.', sectionConnect: '연결 정보', + stepConfig: '설정', + stepConnect: '연결', + snippetsLabel: '클라이언트 설정', connectHintExisting: '토큰은 생성 시 한 번만 표시되었습니다(현재 토큰은 {hint}…로 시작). 새 토큰이 필요하면 교체하세요.', - showSnippets: '클라이언트 설정 예시 보기', tokenDialogTitle: '엔드포인트 준비 완료, 토큰을 저장하세요', connectDialogTitle: '이 엔드포인트에 연결', tokenOnce: '이 토큰은 한 번만 표시됩니다. 지금 복사하여 안전하게 보관하세요.', diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts index 6de9098c..07724a9e 100755 --- a/frontend/src/i18n/locales/ru-RU.ts +++ b/frontend/src/i18n/locales/ru-RU.ts @@ -747,8 +747,10 @@ export default { rateLimitLabel: 'Максимум вызовов в минуту', rateLimitHint: 'Применяется ко всем вызовам инструментов этой конечной точки; при превышении клиент получает ошибку.', sectionConnect: 'Подключение', + stepConfig: 'Настройка', + stepConnect: 'Подключение', + snippetsLabel: 'Конфигурация клиента', connectHintExisting: 'Токен показывался один раз при создании (текущий начинается с {hint}…). Чтобы получить новый, выполните ротацию.', - showSnippets: 'Показать примеры конфигурации клиента', tokenDialogTitle: 'Конечная точка готова, сохраните токен', connectDialogTitle: 'Подключение к конечной точке', tokenOnce: 'Токен показывается только один раз. Скопируйте его сейчас и сохраните в надёжном месте.', diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index 767a1802..72ac4b3f 100755 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -747,8 +747,10 @@ export default { rateLimitLabel: '每分钟最多调用次数', rateLimitHint: '对该端点所有工具调用的总限制,超出后客户端会收到限流提示。', sectionConnect: '连接信息', + stepConfig: '配置', + stepConnect: '连接', + snippetsLabel: '客户端配置', connectHintExisting: '令牌只在创建时展示(当前令牌前缀 {hint}…)。如需重新获取,请轮换令牌。', - showSnippets: '查看客户端配置示例', tokenDialogTitle: '端点已就绪,请保存令牌', connectDialogTitle: '连接此端点', tokenOnce: '令牌只展示这一次,关闭后无法再次查看。请立即复制并妥善保存。', diff --git a/frontend/src/views/integrations/McpServerIntegrationSettings.vue b/frontend/src/views/integrations/McpServerIntegrationSettings.vue index 800fc2a9..1d5872fc 100644 --- a/frontend/src/views/integrations/McpServerIntegrationSettings.vue +++ b/frontend/src/views/integrations/McpServerIntegrationSettings.vue @@ -80,159 +80,175 @@ v-model:visible="showDrawer" class="mcp-endpoint-drawer" :title="editing ? $t('integrations.mcpserver.editTitle') : $t('integrations.mcpserver.createTitle')" - :description="$t('integrations.mcpserver.drawerDesc')" + :description="drawerStepDescription" icon="tools" storage-key="setting-drawer:mcp-endpoint" width="600px" :confirm-loading="saving" - :confirm-text="editing ? $t('common.save') : $t('integrations.mcpserver.create')" + :confirm-text="drawerConfirmText" :hide-footer="!isAdmin" - @confirm="saveForm" + :close-on-overlay-click="!freshToken" + @confirm="handleDrawerConfirm" @cancel="closeDrawer" > -
-

{{ $t('integrations.mcpserver.sectionBasic') }}

-
- - -
-
- - -
-
- - -
-
+ -
-

{{ $t('integrations.mcpserver.sectionScope') }}

-
- - -

{{ $t('integrations.mcpserver.kbScopeHint') }}

-
-
+
+ +
-
-

{{ $t('integrations.mcpserver.sectionTools') }}

-

{{ $t('integrations.mcpserver.toolsHint') }}

-
-
-
- {{ $t(`integrations.mcpserver.groups.${group.group}`) }} - - {{ groupAllSelected(group) ? $t('integrations.mcpserver.clearGroup') : $t('integrations.mcpserver.selectGroup') }} - -
-
-
- - - {{ $t(`integrations.mcpserver.tools.${tool.name}`) }} - {{ tool.name }} - - -

{{ $t(`integrations.mcpserver.tools.${tool.name}Desc`) }}

+ +
+
+

{{ $t('integrations.mcpserver.sectionBasic') }}

+
+ + +
+
+ + +
+
+ + +
+
+ +
+

{{ $t('integrations.mcpserver.sectionScope') }}

+
+ + +

{{ $t('integrations.mcpserver.kbScopeHint') }}

+
+
+ +
+

{{ $t('integrations.mcpserver.sectionTools') }}

+

{{ $t('integrations.mcpserver.toolsHint') }}

+
+
+
+ {{ $t(`integrations.mcpserver.groups.${group.group}`) }} + + {{ groupAllSelected(group) ? $t('integrations.mcpserver.clearGroup') : $t('integrations.mcpserver.selectGroup') }} + +
+
+
+ + + {{ $t(`integrations.mcpserver.tools.${tool.name}`) }} + {{ tool.name }} + + +

{{ $t(`integrations.mcpserver.tools.${tool.name}Desc`) }}

+
-
-

{{ $t('integrations.mcpserver.toolsRequired') }}

-
+

{{ $t('integrations.mcpserver.toolsRequired') }}

+ -
-

{{ $t('integrations.mcpserver.sectionAsk') }}

-
- - -

{{ $t('integrations.mcpserver.defaultAgentHint') }}

-
-
- -
-

{{ $t('integrations.mcpserver.sectionLimits') }}

-
- - -

{{ $t('integrations.mcpserver.rateLimitHint') }}

-
-
- -
-

{{ $t('integrations.mcpserver.sectionConnect') }}

-

{{ $t('integrations.mcpserver.connectHintExisting', { hint: editing.token_hint }) }}

-
-
{{ endpointUrl(editing) }}
- - - -
- - {{ $t('integrations.mcpserver.showSnippets') }} - -
- - - -
- -

{{ $t('integrations.mcpserver.connectPlaceholderHint') }}

- -
- -
-
{{ connectToken }}
- - - +
+

{{ $t('integrations.mcpserver.sectionAsk') }}

+
+ + +

{{ $t('integrations.mcpserver.defaultAgentHint') }}

-
+ -
- -
-
{{ connectUrl }}
- - - +
+

{{ $t('integrations.mcpserver.sectionLimits') }}

+
+ + +

{{ $t('integrations.mcpserver.rateLimitHint') }}

-
- -
- -

{{ $t(`integrations.mcpserver.snippet.${snippet.key}Desc`) }}

-
-
{{ snippet.text }}
- - - -
-
+
- + + +
+
+

{{ $t('integrations.mcpserver.sectionConnect') }}

+ +

+ {{ $t('integrations.mcpserver.connectHintExisting', { hint: editing.token_hint }) }} +

+ +
+ +
+
{{ freshToken }}
+ + + +
+
+ +
+ +
+
{{ endpointUrl(editing) }}
+ + + +
+
+ +
+ +

{{ $t('integrations.mcpserver.connectPlaceholderHint') }}

+ + +

{{ $t(`integrations.mcpserver.snippet.${snippet.key}Desc`) }}

+
+
{{ snippet.text }}
+ + + +
+
+
+
+
+
+
@@ -287,6 +303,25 @@ const agentOptions = computed(() => agents.value.map((a) => ({ label: a.name, va const showDrawer = ref(false) const saving = ref(false) const editing = ref(null) +const wizardStep = ref(0) +const snippetTab = ref('http') +// Plaintext token from the create / rotate response; shown once on step 2. +const freshToken = ref('') + +const stepTitles = computed(() => [ + t('integrations.mcpserver.stepConfig'), + t('integrations.mcpserver.stepConnect'), +]) +const drawerStepDescription = computed(() => { + if (wizardStep.value === 0) return t('integrations.mcpserver.drawerDesc') + return freshToken.value + ? t('integrations.mcpserver.tokenDialogTitle') + : t('integrations.mcpserver.connectDialogTitle') +}) +const drawerConfirmText = computed(() => { + if (wizardStep.value > 0) return t('common.finish') + return editing.value ? t('common.save') : t('integrations.mcpserver.create') +}) const form = reactive({ name: '', description: '', @@ -302,18 +337,14 @@ const selectedToolNames = computed(() => catalog.value.tools.filter((tl) => tool const selectedToolCount = computed(() => selectedToolNames.value.length) const askSelected = computed(() => toolSelections.ask === true) -const connectVisible = ref(false) -const connectToken = ref('') -const connectEndpoint = ref(null) -const connectUrl = computed(() => (connectEndpoint.value ? endpointUrl(connectEndpoint.value) : '')) const connectSnippets = computed(() => { - const ep = connectEndpoint.value + const ep = editing.value if (!ep) return [] const url = endpointUrl(ep) return [ - { key: 'http', text: buildHttpClientSnippet(ep.name, url, connectToken.value, ep.id) }, - { key: 'claudeCode', text: buildClaudeCodeCommand(ep.name, url, connectToken.value, ep.id) }, - { key: 'stdio', text: buildStdioBridgeSnippet(ep.name, url, connectToken.value, ep.id) }, + { key: 'http', text: buildHttpClientSnippet(ep.name, url, freshToken.value, ep.id) }, + { key: 'claudeCode', text: buildClaudeCodeCommand(ep.name, url, freshToken.value, ep.id) }, + { key: 'stdio', text: buildStdioBridgeSnippet(ep.name, url, freshToken.value, ep.id) }, ] }) @@ -382,20 +413,40 @@ async function loadOptions() { function openCreate() { editing.value = null + freshToken.value = '' + wizardStep.value = 0 resetForm(null) showDrawer.value = true void loadOptions() } -function openEdit(ep: McpEndpoint) { +function openEdit(ep: McpEndpoint, step: 0 | 1 = 0, token = '') { editing.value = ep + freshToken.value = token + wizardStep.value = step + snippetTab.value = 'http' resetForm(ep) showDrawer.value = true - void loadOptions() + if (step === 0) void loadOptions() +} + +function goToWizardStep(step: number) { + if (step < 0 || step >= stepTitles.value.length) return + if (step > 0 && !editing.value) return + wizardStep.value = step } function closeDrawer() { showDrawer.value = false + freshToken.value = '' +} + +function handleDrawerConfirm() { + if (wizardStep.value > 0) { + closeDrawer() + return + } + void saveForm() } function buildPayload(): McpEndpointPayload { @@ -430,9 +481,10 @@ async function saveForm() { } else { const res = await createMcpEndpoint(payload) MessagePlugin.success(t('integrations.mcpserver.created')) - showDrawer.value = false await load() - if (res?.data) openConnectDialog(res.data, res.data.token || '') + // Stay in the drawer and move to the connection step so the one-time + // token is read in place instead of in a second, taller dialog. + if (res?.data) openEdit(res.data, 1, res.data.token || '') } } catch (err: any) { MessagePlugin.error(err?.message || t('integrations.mcpserver.saveFailed')) @@ -456,7 +508,7 @@ async function rotateToken(ep: McpEndpoint) { const res = await rotateMcpEndpointToken(ep.id) MessagePlugin.success(t('integrations.mcpserver.rotated')) await load() - if (res?.data) openConnectDialog(res.data, res.data.token || '') + if (res?.data) openEdit(res.data, 1, res.data.token || '') } catch (err: any) { MessagePlugin.error(err?.message || t('integrations.mcpserver.rotateFailed')) } @@ -472,12 +524,6 @@ async function toggleEnabled(ep: McpEndpoint) { } } -function openConnectDialog(ep: McpEndpoint, token: string) { - connectEndpoint.value = ep - connectToken.value = token - connectVisible.value = true -} - function menuOptions(ep: McpEndpoint) { return [ { content: t('integrations.mcpserver.menuConnect'), value: 'connect' }, @@ -489,7 +535,7 @@ function menuOptions(ep: McpEndpoint) { function handleMenuClick(option: { value?: string | number }, ep: McpEndpoint) { switch (option?.value) { case 'connect': - openConnectDialog(ep, '') + openEdit(ep, 1) break case 'toggle': void toggleEnabled(ep) @@ -641,13 +687,101 @@ onMounted(() => { right: 6px; } -.connect-dialog { - display: flex; - flex-direction: column; - gap: 12px; +.connect-alert { + margin-bottom: 8px; } -.connect-dialog__alert { - margin-bottom: 4px; +.snippet-tabs { + margin-top: 4px; + + :deep(.t-tabs__content) { + padding-top: 8px; + } +} + +/* Step rail, aligned with the embed / IM channel drawers. */ +.im-steps { + display: flex; + gap: 8px; + margin-bottom: 16px; + border-bottom: 1px solid var(--td-component-stroke); + padding-bottom: 12px; +} + +.im-step { + display: flex; + align-items: center; + gap: 6px; + flex: 1; + min-width: 0; + font-size: 12px; + color: var(--td-text-color-placeholder); + padding: 0; + border: none; + background: transparent; + font-family: inherit; + text-align: left; + cursor: pointer; + + &:hover:not(:disabled) { + color: var(--td-text-color-secondary); + } + + &:disabled { + cursor: default; + } +} + +.im-step-title { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.im-step.active { + color: var(--td-brand-color); + font-weight: 500; +} + +.im-step.done { + color: var(--td-text-color-secondary); + font-weight: 500; +} + +.im-step-num { + flex-shrink: 0; + width: 20px; + height: 20px; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + font-size: 11px; + font-weight: 600; + border: 1px solid var(--td-component-stroke); + color: var(--td-text-color-placeholder); + background: transparent; +} + +.im-step.active .im-step-num { + background: var(--td-brand-color); + color: #fff; + border-color: var(--td-brand-color); +} + +.im-step.done .im-step-num { + background: var(--td-bg-color-secondarycontainer); + color: var(--td-brand-color); + border-color: var(--td-component-stroke); +} + +.im-step-check { + font-size: 12px; +} + +.im-step-body { + display: flex; + flex-direction: column; }