fix(frontend): use the MCP logo and hide MCP when disabled

- Replace the cube icon with the official MCP logo in the sidebar and on
  the MCP connection and consent pages.
- Show the MCP entry only when the deployment enables MCP (mcp_enabled).
- Explain that administrator write grants always need TOTP verification,
  and add MCP OAuth to the audit log auth-method filter.
- Remove the unreferenced screenshots and their .gitignore exceptions (L6).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
harukaandClaude Opus 5.5 committed 2026-10-28 09:30:23 -04:00
1 parent ee71c7f379
commit 8a34f1ecf3
16 files changed
+67 -8

No files matched your search

-2
View File
@@ -135,8 +135,6 @@ vite.config.js
docs/*
!docs/admin-api-keys.md
!docs/mcp.md
!docs/mcp-oauth-connections.png
!docs/mcp-oauth-consent.png
!docs/PAYMENT.md
!docs/PAYMENT_CN.md
!docs/ADMIN_PAYMENT_INTEGRATION_API.md
Binary file not shown.

Before

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

+5 -1
View File
@@ -132,7 +132,11 @@ const icons = {
calculator: 'M9 7h6m0 10v-3m-3 3h.01M9 17h.01M9 14h.01M12 14h.01M15 11h.01M12 11h.01M9 11h.01M7 21h10a2 2 0 002-2V5a2 2 0 00-2-2H7a2 2 0 00-2 2v14a2 2 0 002 2z',
fire: 'M17.657 18.657A8 8 0 016.343 7.343S7 9 9 10c0-2 .5-5 2.986-7C14 5 16.09 5.777 17.656 7.343A7.975 7.975 0 0120 13a7.975 7.975 0 01-2.343 5.657z',
badge: 'M9 12.75L11.25 15 15 9.75M21 12c0 1.268-.63 2.39-1.593 3.068a3.745 3.745 0 01-1.043 3.296 3.745 3.745 0 01-3.296 1.043A3.745 3.745 0 0112 21c-1.268 0-2.39-.63-3.068-1.593a3.746 3.746 0 01-3.296-1.043 3.745 3.745 0 01-1.043-3.296A3.745 3.745 0 013 12c0-1.268.63-2.39 1.593-3.068a3.745 3.745 0 011.043-3.296 3.746 3.746 0 013.296-1.043A3.746 3.746 0 0112 3c1.268 0 2.39.63 3.068 1.593a3.746 3.746 0 013.296 1.043 3.746 3.746 0 011.043 3.296A3.745 3.745 0 0121 12z',
brain: 'M9.75 3.104v5.714a2.25 2.25 0 01-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 014.5 0m0 0v5.714c0 .597.237 1.17.659 1.591L19.8 15.3M14.25 3.104c.251.023.501.05.75.082M19.8 15.3l-1.57.393A9.065 9.065 0 0112 15a9.065 9.065 0 00-6.23.693L5 14.5m0 0l-2.69 2.689c-1.232 1.232-.65 3.318 1.067 3.611A48.309 48.309 0 0012 21c2.773 0 5.491-.235 8.135-.687 1.718-.293 2.3-2.379 1.067-3.61L19.8 15.3M12 8.25a1.5 1.5 0 100-3 1.5 1.5 0 000 3zm0 0v3m-3-1.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3zm0 0h6m-3 4.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z'
brain: 'M9.75 3.104v5.714a2.25 2.25 0 01-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 014.5 0m0 0v5.714c0 .597.237 1.17.659 1.591L19.8 15.3M14.25 3.104c.251.023.501.05.75.082M19.8 15.3l-1.57.393A9.065 9.065 0 0112 15a9.065 9.065 0 00-6.23.693L5 14.5m0 0l-2.69 2.689c-1.232 1.232-.65 3.318 1.067 3.611A48.309 48.309 0 0012 21c2.773 0 5.491-.235 8.135-.687 1.718-.293 2.3-2.379 1.067-3.61L19.8 15.3M12 8.25a1.5 1.5 0 100-3 1.5 1.5 0 000 3zm0 0v3m-3-1.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3zm0 0h6m-3 4.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z',
// Brands
// Model Context Protocol logo (modelcontextprotocol.io), scaled to the 24px stroke grid.
mcp: 'M3.98 11.4L11.59 3.79C12.64 2.74 14.34 2.74 15.39 3.79C16.44 4.84 16.44 6.54 15.39 7.59L9.64 13.34M9.72 13.26L15.39 7.59C16.44 6.54 18.14 6.54 19.2 7.59L19.24 7.63C20.29 8.68 20.29 10.39 19.24 11.44L12.35 18.32C12 18.67 12 19.24 12.35 19.59L13.77 21M13.49 5.69L7.86 11.32C6.81 12.37 6.81 14.07 7.86 15.12C8.91 16.17 10.61 16.17 11.67 15.12L17.29 9.49'
} as const
const iconPath = computed(() => icons[props.name])
@@ -481,6 +481,10 @@ const PluginIcon = {
render: () => h(Icon, { name: 'cube' })
}
const MCPIcon = {
render: () => h(Icon, { name: 'mcp' })
}
const BellIcon = {
render: () =>
h(
@@ -708,6 +712,7 @@ const purchaseNavLabel = computed(() => {
const flagAffiliate = makeSidebarFlag(FeatureFlags.affiliate)
const flagRiskControl = makeSidebarFlag(FeatureFlags.riskControl)
const flagPluginManagement = makeSidebarFlag(FeatureFlags.pluginManagement)
const flagMCP = makeSidebarFlag(FeatureFlags.mcp)
const flagOpsMonitoring = () => adminSettingsStore.opsMonitoringEnabled
const flagAdminPayment = () => adminSettingsStore.paymentEnabled
const flagBatchImageAccess = () => canUseBatchImage.value
@@ -734,7 +739,7 @@ function buildSelfNavItems(withDashboard: boolean): NavItem[] {
{ path: '/redeem', label: t('nav.redeem'), icon: GiftIcon, hideInSimpleMode: true },
{ path: '/affiliate', label: t('nav.affiliate'), icon: UsersIcon, hideInSimpleMode: true, featureFlag: flagAffiliate },
{ path: '/profile', label: t('nav.profile'), icon: UserIcon },
{ path: '/settings/mcp', label: t('mcp.title'), icon: PluginIcon },
{ path: '/settings/mcp', label: t('mcp.title'), icon: MCPIcon, featureFlag: flagMCP },
...customMenuItemsForUser.value.map((item): NavItem => ({
path: `/custom/${item.id}`,
label: item.label,
@@ -846,7 +851,7 @@ const adminNavItems = computed((): NavItem[] => {
if (authStore.isSimpleMode) {
const filtered = visible.filter(item => !item.hideInSimpleMode)
filtered.push({ path: '/keys', label: t('nav.apiKeys'), icon: KeyIcon })
filtered.push({ path: '/settings/mcp', label: t('mcp.title'), icon: PluginIcon })
if (flagMCP()) filtered.push({ path: '/settings/mcp', label: t('mcp.title'), icon: MCPIcon })
filtered.push({ path: '/admin/settings', label: t('nav.settings'), icon: CogIcon })
for (const cm of customMenuItemsForAdmin.value) {
filtered.push({ path: `/custom/${cm.id}`, label: cm.label, icon: null, iconSvg: cm.icon_svg })
@@ -80,3 +80,13 @@ describe('AppSidebar subscription feature flag', () => {
expect(componentSource).toMatch(/path: '\/purchase'[^\n]*label: purchaseNavLabel\.value/)
})
})
describe('AppSidebar MCP entry', () => {
it('uses the MCP logo and shows the entry only when the deployment enables MCP', () => {
expect(componentSource).toContain("render: () => h(Icon, { name: 'mcp' })")
expect(componentSource).toContain('const flagMCP = makeSidebarFlag(FeatureFlags.mcp)')
expect(componentSource).toMatch(/path: '\/settings\/mcp'[^\n]*icon: MCPIcon, featureFlag: flagMCP/)
expect(componentSource).toMatch(/if \(flagMCP\(\)\) filtered\.push\(\{ path: '\/settings\/mcp'[^\n]*icon: MCPIcon/)
expect(componentSource).not.toMatch(/path: '\/settings\/mcp'[^\n]*PluginIcon/)
})
})
+1
View File
@@ -23,6 +23,7 @@ export default {
readWrite: 'Allow changes',
readOnlyHint: 'Expose query tools only, for analyzing usage and checking status.',
readWriteHint: 'Allow creating, updating and deleting resources within this scope, including API keys and billing entitlements. Only approve this for an application you trust.',
adminWriteHint: 'Platform write access always requires two-factor authentication (TOTP) to be enabled and verified when you approve.',
empty: 'No authorized applications yet. Start a connection from your AI client using the server URL above.',
loading: 'Loading authorized applications…',
loadFailed: 'Failed to load authorized applications. Please try again.',
+1
View File
@@ -23,6 +23,7 @@ export default {
readWrite: '允许修改',
readOnlyHint: '只开放查询工具,适合分析用量、查看状态。',
readWriteHint: '允许创建、修改和删除范围内的资源,包括 API 密钥和计费权益。请只授权给你信任的应用。',
adminWriteHint: '平台管理的修改权限始终需要你已开启两步验证(TOTP),并在授权时完成验证。',
empty: '尚未授权任何应用。请在 AI 客户端中使用上方服务地址发起连接。',
loading: '正在加载已授权应用…',
loadFailed: '加载已授权应用失败,请重试。',
+1
View File
@@ -380,6 +380,7 @@ export const useAppStore = defineStore('app', () => {
service_quota_enabled: false,
affiliate_enabled: false,
allow_user_view_error_requests: false,
mcp_enabled: false,
})
}
+2
View File
@@ -287,6 +287,8 @@ export interface PublicSettings {
service_quota_enabled: boolean
affiliate_enabled: boolean
allow_user_view_error_requests?: boolean
/** True when the deployment configures MCP_PUBLIC_URL; MCP is disabled otherwise. */
mcp_enabled?: boolean
}
export interface AuthResponse {
@@ -63,3 +63,19 @@ describe('resolveFeatureFlag', () => {
expect(isFeatureFlagEnabled(FeatureFlags.subscription)).toBe(false)
})
})
describe('FeatureFlags.mcp', () => {
beforeEach(() => {
setActivePinia(createPinia())
delete (window as any).__APP_CONFIG__
})
it('stays hidden unless the deployment explicitly enables MCP', () => {
expect(FeatureFlags.mcp.key).toBe('mcp_enabled')
expect(FeatureFlags.mcp.mode).toBe('opt-in')
expect(isFeatureFlagEnabled(FeatureFlags.mcp)).toBe(false)
expect(resolveFeatureFlag({} as PublicSettings, FeatureFlags.mcp)).toBe(false)
expect(resolveFeatureFlag({ mcp_enabled: false } as PublicSettings, FeatureFlags.mcp)).toBe(false)
expect(resolveFeatureFlag({ mcp_enabled: true } as PublicSettings, FeatureFlags.mcp)).toBe(true)
})
})
+6
View File
@@ -134,6 +134,12 @@ export const FeatureFlags = {
mode: 'opt-in',
label: 'Affiliate',
}),
// Read-only: enabled by the deployment's MCP_PUBLIC_URL, not an admin toggle.
mcp: defineFlag({
key: 'mcp_enabled',
mode: 'opt-in',
label: 'MCP',
}),
} as const
export type RegisteredFeatureFlag = keyof typeof FeatureFlags
+2 -1
View File
@@ -485,7 +485,8 @@ const methodOptions = computed(() => [
const authMethodOptions = computed(() => [
{ value: '', label: t('admin.audit.filters.all') },
{ value: 'jwt', label: 'JWT' },
{ value: 'admin_api_key', label: 'Admin API Key' }
{ value: 'admin_api_key', label: 'Admin API Key' },
{ value: 'mcp_oauth', label: 'MCP OAuth' }
])
const resultOptions = computed(() => [
@@ -2,7 +2,7 @@
<main class="min-h-screen bg-gray-50 px-4 py-8 dark:bg-dark-950 sm:py-12">
<section class="card mx-auto max-w-2xl p-5 sm:p-8" aria-labelledby="mcp-consent-title" :aria-busy="loading || submitting">
<div class="mb-6 flex items-start gap-3">
<div class="rounded-xl bg-primary-50 p-3 text-primary-600 dark:bg-primary-900/20 dark:text-primary-400"><Icon name="cube" size="lg" /></div>
<div class="rounded-xl bg-primary-50 p-3 text-primary-600 dark:bg-primary-900/20 dark:text-primary-400"><Icon name="mcp" size="lg" /></div>
<div>
<h1 id="mcp-consent-title" class="text-xl font-semibold text-gray-900 dark:text-white">{{ t('mcp.consentTitle') }}</h1>
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">{{ t('mcp.consentDescription') }}</p>
@@ -54,6 +54,7 @@
<option :value="false">{{ t('mcp.readWrite') }}</option>
</select>
<p id="mcp-permissions-hint" class="mt-2 text-xs" :class="readOnly ? 'text-gray-500 dark:text-gray-400' : 'text-amber-700 dark:text-amber-400'">{{ readOnly ? t('mcp.readOnlyHint') : t('mcp.readWriteHint') }}</p>
<p v-if="scope === 'admin' && !readOnly" data-testid="admin-write-hint" class="mt-1 text-xs text-amber-700 dark:text-amber-400">{{ t('mcp.adminWriteHint') }}</p>
</div>
<p v-if="submitError" role="alert" class="text-sm text-red-600 dark:text-red-400">{{ submitError }}</p>
<div class="flex justify-end gap-3 border-t border-gray-100 pt-5 dark:border-dark-700">
@@ -154,6 +154,19 @@ describe('MCP OAuth consent', () => {
expect(assign).toHaveBeenCalledWith(redirectURL)
})
it('explains that administrator write access always needs two-factor verification', async () => {
auth.isAdmin = true
const wrapper = render()
await flushPromises()
expect(wrapper.find('[data-testid="admin-write-hint"]').exists()).toBe(false)
await wrapper.get('#mcp-consent-permissions').setValue('false')
expect(wrapper.find('[data-testid="admin-write-hint"]').exists()).toBe(false)
await wrapper.get('#mcp-consent-scope').setValue('admin')
expect(wrapper.get('[data-testid="admin-write-hint"]').text()).toBe('mcp.adminWriteHint')
await wrapper.get('#mcp-consent-permissions').setValue('true')
expect(wrapper.find('[data-testid="admin-write-hint"]').exists()).toBe(false)
})
it('cancels admin step-up without granting access', async () => {
auth.isAdmin = true
authorize.mockRejectedValue({ reason: 'STEP_UP_REQUIRED' })
+1 -1
View File
@@ -4,7 +4,7 @@
<section class="card p-5 sm:p-6" aria-labelledby="mcp-connection-title" :aria-busy="connectionLoading">
<div class="flex items-start gap-3">
<div class="rounded-xl bg-primary-50 p-3 text-primary-600 dark:bg-primary-900/20 dark:text-primary-400">
<Icon name="cube" size="lg" />
<Icon name="mcp" size="lg" />
</div>
<div>
<h2 id="mcp-connection-title" class="text-lg font-semibold text-gray-900 dark:text-white">{{ t('mcp.connectionTitle') }}</h2>