From fab3e9832a614ca26b91c0a0884ca5c19cdc6f04 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 30 Sep 2026 12:47:45 +0800 Subject: [PATCH] feat(ui): run MCP check from the MCP page A Check button next to Backups runs the check only when clicked, so the page never does DNS or PATH lookups on load. The result note sits above the unmanaged-servers note, and each server row with findings gets a count tag and a fold listing them. The component tests land here with the locale strings they assert on, since the parity-checked locale files belong to this commit. --- ui/src/components/mcp/MCPCheck.test.tsx | 49 +++++++++++++++++++++++++ ui/src/components/mcp/MCPServerList.tsx | 8 +++- ui/src/i18n/locales/de.json | 17 +++++++++ ui/src/i18n/locales/en.json | 17 +++++++++ ui/src/i18n/locales/es.json | 17 +++++++++ ui/src/i18n/locales/fa.json | 17 +++++++++ ui/src/i18n/locales/fr.json | 17 +++++++++ ui/src/i18n/locales/id.json | 17 +++++++++ ui/src/i18n/locales/ja.json | 17 +++++++++ ui/src/i18n/locales/ko.json | 17 +++++++++ ui/src/i18n/locales/pt-BR.json | 17 +++++++++ ui/src/i18n/locales/zh-CN.json | 17 +++++++++ ui/src/i18n/locales/zh-TW.json | 17 +++++++++ ui/src/pages/MCPPage.tsx | 19 +++++++--- 14 files changed, 256 insertions(+), 7 deletions(-) create mode 100644 ui/src/components/mcp/MCPCheck.test.tsx diff --git a/ui/src/components/mcp/MCPCheck.test.tsx b/ui/src/components/mcp/MCPCheck.test.tsx new file mode 100644 index 000000000..57319c071 --- /dev/null +++ b/ui/src/components/mcp/MCPCheck.test.tsx @@ -0,0 +1,49 @@ +import { render, screen } from '@testing-library/react'; +import { describe, expect, it, vi } from 'vitest'; +import type { MCPCheckFinding, MCPCheckReport } from '../../api/mcpCheck'; +import { I18nProvider } from '../../i18n'; +import MCPCheckFindings, { MCPCheckTag } from './MCPCheckFindings'; +import MCPCheckNote from './MCPCheckNote'; + +const env: MCPCheckFinding = { level: 'error', check: 'env', target: '', subject: 'CLICKUP_TOKEN', message: 'bearerToken reads CLICKUP_TOKEN, which is not set' }; +const rule: MCPCheckFinding = { level: 'error', check: 'client-rule', target: 'claude-desktop', message: 'claude-desktop accepts stdio servers only' }; +const shadow: MCPCheckFinding = { level: 'warning', check: 'sync', target: 'claude', message: 'a local scope server wins' }; +const report = (servers: MCPCheckReport['servers'], errors = 0, warnings = 0): MCPCheckReport => ({ servers, summary: { errors, warnings } }); + +const note = (r: MCPCheckReport) => render(); +const rows = (findings: MCPCheckFinding[]) => render(); + +describe('MCP check note', () => { + it('counts the servers with problems and the errors and warnings', () => { + note(report([{ name: 'clickup', ok: false, findings: [env, rule] }, { name: 'figma', ok: true, findings: [shadow] }, { name: 'parked', ok: true, findings: [{ level: 'info', check: 'targets', target: '', message: 'kept' }] }], 2, 1)); + expect(screen.getByText('2 servers have problems').closest('.ss-note')).toHaveTextContent('2 error, 1 warning · checked just now'); + }); + + it('says every server is fine when there is no error or warning', () => { + note(report([{ name: 'a', ok: true, findings: [] }, { name: 'b', ok: true, findings: [{ level: 'info', check: 'sync', target: 'claude', message: 'in sync' }] }])); + expect(screen.getByText('2 servers have no problems').closest('.ss-note')).toHaveClass('inf'); + }); +}); + +describe('MCP check findings', () => { + it('shows the Agent a finding is about, and no Agent for a server-wide one', () => { + const { container } = rows([env, rule]); + const lines = container.querySelectorAll('.ss-r.fold > div'); + expect([lines[0].querySelector('.ss-at'), lines[1].querySelector('.ss-at')].map(Boolean)).toEqual([false, true]); + }); + + it('phrases a missing variable from its subject', () => { + rows([env]); + expect(screen.getByText('Reads CLICKUP_TOKEN, but this variable is not set.')).toBeInTheDocument(); + }); + + it('keeps the server message for checks without a sentence of their own', () => { + rows([rule]); + expect(screen.getByText('claude-desktop accepts stdio servers only')).toBeInTheDocument(); + }); + + it('tags a server with warnings only by its warning count', () => { + render(); + expect(screen.getByText('1 warning')).toHaveClass('warn'); + }); +}); diff --git a/ui/src/components/mcp/MCPServerList.tsx b/ui/src/components/mcp/MCPServerList.tsx index 1174c01bc..a3762fa42 100644 --- a/ui/src/components/mcp/MCPServerList.tsx +++ b/ui/src/components/mcp/MCPServerList.tsx @@ -6,6 +6,8 @@ import { mcpOffTargets } from '../../api/mcp'; import { describeEndpoint, writes, type MatrixRow } from './mcpView'; import { TargetPill, TargetToggles } from './TargetPicker'; import { useDirectToolsLabel } from './MCPProjectSettings'; +import type { MCPCheckFinding } from '../../api/mcpCheck'; +import MCPCheckFindings, { MCPCheckTag } from './MCPCheckFindings'; interface Props { rows: MatrixRow[]; @@ -17,13 +19,15 @@ interface Props { offTargets?: readonly string[]; /** Holds the toggles while a save is on its way: each sends the revision it previewed. */ disabled?: boolean; + /** The last check's errors and warnings, by server name. */ + problems?: Record; } /** * One row per server. The agents it writes to are chips inside the row, not columns: * the list grows downwards as more CLIs gain MCP support, so it never scrolls sideways. */ -export default function MCPServerList({ rows, targets, targetsOf, onToggle, onMenu, offTargets = mcpOffTargets, disabled = false }: Props) { +export default function MCPServerList({ rows, targets, targetsOf, onToggle, onMenu, offTargets = mcpOffTargets, disabled = false, problems = {} }: Props) { const t = useT(); const [open, setOpen] = useState([]); const directToolsLabel = useDirectToolsLabel(); @@ -48,6 +52,7 @@ export default function MCPServerList({ rows, targets, targetsOf, onToggle, onMe {row.name} {row.server && Object.values(row.cells).some(writes) && {t('plugins.pending')}} {row.server && !row.server.disabled && row.server.targets?.length === 0 && {t('plugins.noAgentsYet')}} + {problems[row.name] && } {!row.server && {t('mcp.removedFromSource')}} {/* Transport and endpoint on one quiet line, the same shape as a plugin row. */} @@ -73,6 +78,7 @@ export default function MCPServerList({ rows, targets, targetsOf, onToggle, onMe )} + {problems[row.name] && } {expanded && row.server && (
onToggle(row.name, target, on)} /> diff --git a/ui/src/i18n/locales/de.json b/ui/src/i18n/locales/de.json index 545c52b23..b39e49ec0 100644 --- a/ui/src/i18n/locales/de.json +++ b/ui/src/i18n/locales/de.json @@ -54,6 +54,23 @@ "mcp.editServer": "Server bearbeiten", "mcp.importFromTarget": "Aus einem Target importieren", "mcp.backupsButton": "Backups", + "mcp.check.button": "Prüfen", + "mcp.check.running": "Wird geprüft…", + "mcp.check.problems.one": "1 Server hat Probleme", + "mcp.check.problems.other": "{count} Server haben Probleme", + "mcp.check.allGood.one": "1 Server hat keine Probleme", + "mcp.check.allGood.other": "Alle {count} Server haben keine Probleme", + "mcp.check.counts": "{errors} error, {warnings} warning", + "mcp.check.justNow": "gerade geprüft", + "mcp.check.checkedAt": "{time} geprüft", + "mcp.check.rerun": "Erneut prüfen", + "mcp.check.envNote": "Variablen werden aus dem Terminal gelesen, das skillshare ui gestartet hat; über das Dock geöffnete Apps sehen sie eventuell nicht.", + "mcp.check.finding.env": "Liest {subject}, aber diese Variable ist nicht gesetzt.", + "mcp.check.finding.command": "Befehl {subject} wurde nicht gefunden. Prüfe, ob er installiert ist und im PATH liegt.", + "mcp.check.finding.dns": "{subject} konnte nicht aufgelöst werden. Netzwerk oder URL sind eventuell falsch.", + "mcp.check.finding.notSynced": "Noch nicht synchronisiert. Wird geschrieben, sobald du „MCP synchronisieren“ drückst.", + "mcp.check.tag.error": "{count} error", + "mcp.check.tag.warning": "{count} warning", "mcp.transport": "Transport", "mcp.offHere": "In diesem Projekt aus", "mcp.offHint": "skillshare liest die Konfiguration des Agents nicht, der Name wird also nicht geprüft. Passt er zu nichts, wird er ohne Fehlermeldung ignoriert.", diff --git a/ui/src/i18n/locales/en.json b/ui/src/i18n/locales/en.json index 1908c86c3..34e035c73 100644 --- a/ui/src/i18n/locales/en.json +++ b/ui/src/i18n/locales/en.json @@ -54,6 +54,23 @@ "mcp.editServer": "Edit server", "mcp.importFromTarget": "Import from a target", "mcp.backupsButton": "Backups", + "mcp.check.button": "Check", + "mcp.check.running": "Checking…", + "mcp.check.problems.one": "1 server has problems", + "mcp.check.problems.other": "{count} servers have problems", + "mcp.check.allGood.one": "1 server has no problems", + "mcp.check.allGood.other": "{count} servers have no problems", + "mcp.check.counts": "{errors} error, {warnings} warning", + "mcp.check.justNow": "checked just now", + "mcp.check.checkedAt": "checked {time}", + "mcp.check.rerun": "Check again", + "mcp.check.envNote": "Variables are read from the terminal that started skillshare ui; apps opened from the Dock may not see them.", + "mcp.check.finding.env": "Reads {subject}, but this variable is not set.", + "mcp.check.finding.command": "Command {subject} was not found. Make sure it is installed and on PATH.", + "mcp.check.finding.dns": "Could not resolve {subject}. The network or the URL may be wrong.", + "mcp.check.finding.notSynced": "Not synced yet. It is written after you press Sync MCP.", + "mcp.check.tag.error": "{count} error", + "mcp.check.tag.warning": "{count} warning", "mcp.transport": "Transport", "mcp.offHere": "Off in this project", "mcp.offHint": "Skillshare does not read the Agent's config, so the name is not checked. One that matches nothing is ignored, with no error.", diff --git a/ui/src/i18n/locales/es.json b/ui/src/i18n/locales/es.json index 84034c82f..91bda4d3e 100644 --- a/ui/src/i18n/locales/es.json +++ b/ui/src/i18n/locales/es.json @@ -54,6 +54,23 @@ "mcp.editServer": "Editar servidor", "mcp.importFromTarget": "Importar desde un target", "mcp.backupsButton": "Copias de seguridad", + "mcp.check.button": "Comprobar", + "mcp.check.running": "Comprobando…", + "mcp.check.problems.one": "1 servidor tiene problemas", + "mcp.check.problems.other": "{count} servidores tienen problemas", + "mcp.check.allGood.one": "1 servidor no tiene problemas", + "mcp.check.allGood.other": "Ninguno de los {count} servidores tiene problemas", + "mcp.check.counts": "{errors} error, {warnings} warning", + "mcp.check.justNow": "comprobado ahora mismo", + "mcp.check.checkedAt": "comprobado {time}", + "mcp.check.rerun": "Comprobar de nuevo", + "mcp.check.envNote": "Las variables se leen de la terminal que inició skillshare ui; las apps abiertas desde el Dock quizá no las vean.", + "mcp.check.finding.env": "Lee {subject}, pero esta variable no está definida.", + "mcp.check.finding.command": "No se encontró el comando {subject}. Comprueba que está instalado y en el PATH.", + "mcp.check.finding.dns": "No se pudo resolver {subject}. Puede que la red o la URL sean incorrectas.", + "mcp.check.finding.notSynced": "Aún no está sincronizado. Se escribe al pulsar Sincronizar MCP.", + "mcp.check.tag.error": "{count} error", + "mcp.check.tag.warning": "{count} warning", "mcp.transport": "Transporte", "mcp.offHere": "Desactivado en este proyecto", "mcp.offHint": "skillshare no lee la configuración del Agent, así que no comprueba el nombre. Si no coincide con nada, se ignora sin dar error.", diff --git a/ui/src/i18n/locales/fa.json b/ui/src/i18n/locales/fa.json index afbe0e9af..724771bac 100644 --- a/ui/src/i18n/locales/fa.json +++ b/ui/src/i18n/locales/fa.json @@ -54,6 +54,23 @@ "mcp.editServer": "ویرایش سرور", "mcp.importFromTarget": "درون‌ریزی از یک target", "mcp.backupsButton": "پشتیبان‌ها", + "mcp.check.button": "بررسی", + "mcp.check.running": "در حال بررسی…", + "mcp.check.problems.one": "۱ سرور مشکل دارد", + "mcp.check.problems.other": "{count} سرور مشکل دارند", + "mcp.check.allGood.one": "۱ سرور مشکلی ندارد", + "mcp.check.allGood.other": "هیچ‌کدام از {count} سرور مشکلی ندارند", + "mcp.check.counts": "{errors} error، {warnings} warning", + "mcp.check.justNow": "همین الان بررسی شد", + "mcp.check.checkedAt": "{time} بررسی شد", + "mcp.check.rerun": "بررسی دوباره", + "mcp.check.envNote": "متغیرها از ترمینالی خوانده می‌شوند که skillshare ui را اجرا کرده است؛ برنامه‌هایی که از Dock باز می‌شوند شاید آن‌ها را نبینند.", + "mcp.check.finding.env": "{subject} را می‌خواند، اما این متغیر تنظیم نشده است.", + "mcp.check.finding.command": "دستور {subject} پیدا نشد. مطمئن شوید نصب شده و در PATH است.", + "mcp.check.finding.dns": "{subject} قابل resolve نیست. شاید شبکه یا نشانی اشتباه باشد.", + "mcp.check.finding.notSynced": "هنوز همگام‌سازی نشده است. بعد از زدن «همگام‌سازی MCP» نوشته می‌شود.", + "mcp.check.tag.error": "{count} error", + "mcp.check.tag.warning": "{count} warning", "mcp.transport": "انتقال", "mcp.offHere": "خاموش در این پروژه", "mcp.offHint": "skillshare تنظیمات Agent را نمی‌خواند، پس نام بررسی نمی‌شود. نامی که با چیزی جور نباشد بدون خطا نادیده گرفته می‌شود.", diff --git a/ui/src/i18n/locales/fr.json b/ui/src/i18n/locales/fr.json index 4c8ccf6fc..e7b6436af 100644 --- a/ui/src/i18n/locales/fr.json +++ b/ui/src/i18n/locales/fr.json @@ -54,6 +54,23 @@ "mcp.editServer": "Modifier le serveur", "mcp.importFromTarget": "Importer depuis un target", "mcp.backupsButton": "Sauvegardes", + "mcp.check.button": "Vérifier", + "mcp.check.running": "Vérification…", + "mcp.check.problems.one": "1 serveur a des problèmes", + "mcp.check.problems.other": "{count} serveurs ont des problèmes", + "mcp.check.allGood.one": "1 serveur n’a aucun problème", + "mcp.check.allGood.other": "Aucun des {count} serveurs n’a de problème", + "mcp.check.counts": "{errors} error, {warnings} warning", + "mcp.check.justNow": "vérifié à l’instant", + "mcp.check.checkedAt": "vérifié {time}", + "mcp.check.rerun": "Vérifier à nouveau", + "mcp.check.envNote": "Les variables sont lues depuis le terminal qui a lancé skillshare ui ; les apps ouvertes depuis le Dock peuvent ne pas les voir.", + "mcp.check.finding.env": "Lit {subject}, mais cette variable n’est pas définie.", + "mcp.check.finding.command": "La commande {subject} est introuvable. Vérifiez qu’elle est installée et dans le PATH.", + "mcp.check.finding.dns": "Impossible de résoudre {subject}. Le réseau ou l’URL est peut-être incorrect.", + "mcp.check.finding.notSynced": "Pas encore synchronisé. L’écriture se fait quand vous appuyez sur Synchroniser MCP.", + "mcp.check.tag.error": "{count} error", + "mcp.check.tag.warning": "{count} warning", "mcp.transport": "Transport", "mcp.offHere": "Désactivé dans ce projet", "mcp.offHint": "skillshare ne lit pas la configuration de l'Agent, le nom n'est donc pas vérifié. S'il ne correspond à rien, il est ignoré sans erreur.", diff --git a/ui/src/i18n/locales/id.json b/ui/src/i18n/locales/id.json index a739a18d8..21f504290 100644 --- a/ui/src/i18n/locales/id.json +++ b/ui/src/i18n/locales/id.json @@ -54,6 +54,23 @@ "mcp.editServer": "Edit server", "mcp.importFromTarget": "Impor dari target", "mcp.backupsButton": "Cadangan", + "mcp.check.button": "Periksa", + "mcp.check.running": "Memeriksa…", + "mcp.check.problems.one": "1 server bermasalah", + "mcp.check.problems.other": "{count} server bermasalah", + "mcp.check.allGood.one": "1 server tidak bermasalah", + "mcp.check.allGood.other": "Semua {count} server tidak bermasalah", + "mcp.check.counts": "{errors} error, {warnings} warning", + "mcp.check.justNow": "baru saja diperiksa", + "mcp.check.checkedAt": "diperiksa {time}", + "mcp.check.rerun": "Periksa lagi", + "mcp.check.envNote": "Variabel dibaca dari terminal yang menjalankan skillshare ui; aplikasi yang dibuka dari Dock mungkin tidak bisa membacanya.", + "mcp.check.finding.env": "Membaca {subject}, tetapi variabel ini belum diatur.", + "mcp.check.finding.command": "Perintah {subject} tidak ditemukan. Pastikan sudah terpasang dan ada di PATH.", + "mcp.check.finding.dns": "Tidak dapat me-resolve {subject}. Jaringan atau URL mungkin salah.", + "mcp.check.finding.notSynced": "Belum disinkronkan. Akan ditulis setelah Anda menekan Sinkronkan MCP.", + "mcp.check.tag.error": "{count} error", + "mcp.check.tag.warning": "{count} warning", "mcp.transport": "Transport", "mcp.offHere": "Mati di proyek ini", "mcp.offHint": "skillshare tidak membaca konfigurasi Agent, jadi namanya tidak diperiksa. Nama yang tidak cocok akan diabaikan tanpa pesan error.", diff --git a/ui/src/i18n/locales/ja.json b/ui/src/i18n/locales/ja.json index 0c13f8fee..388aaf51f 100644 --- a/ui/src/i18n/locales/ja.json +++ b/ui/src/i18n/locales/ja.json @@ -54,6 +54,23 @@ "mcp.editServer": "サーバーを編集", "mcp.importFromTarget": "target からインポート", "mcp.backupsButton": "バックアップ", + "mcp.check.button": "チェック", + "mcp.check.running": "チェック中…", + "mcp.check.problems.one": "1 件のサーバーに問題があります", + "mcp.check.problems.other": "{count} 件のサーバーに問題があります", + "mcp.check.allGood.one": "1 件のサーバーに問題はありません", + "mcp.check.allGood.other": "{count} 件のサーバーすべてに問題はありません", + "mcp.check.counts": "{errors} error、{warnings} warning", + "mcp.check.justNow": "たった今チェック", + "mcp.check.checkedAt": "{time}にチェック", + "mcp.check.rerun": "再チェック", + "mcp.check.envNote": "環境変数は skillshare ui を起動したターミナルのものが使われます。Dock から開いたアプリでは読めないことがあります。", + "mcp.check.finding.env": "{subject} を読み込みますが、この変数は設定されていません。", + "mcp.check.finding.command": "コマンド {subject} が見つかりません。インストールされ、PATH にあるか確認してください。", + "mcp.check.finding.dns": "{subject} を名前解決できません。ネットワークか URL が間違っている可能性があります。", + "mcp.check.finding.notSynced": "まだ同期されていません。「MCP を同期」を押すと書き込まれます。", + "mcp.check.tag.error": "{count} error", + "mcp.check.tag.warning": "{count} warning", "mcp.transport": "トランスポート", "mcp.offHere": "このプロジェクトでオフ", "mcp.offHint": "skillshare は Agent の設定を読まないため、名前は検証されません。どれにも一致しない名前は、エラーも出ずに無視されます。", diff --git a/ui/src/i18n/locales/ko.json b/ui/src/i18n/locales/ko.json index 377f7bd70..0c024d1e9 100644 --- a/ui/src/i18n/locales/ko.json +++ b/ui/src/i18n/locales/ko.json @@ -54,6 +54,23 @@ "mcp.editServer": "서버 편집", "mcp.importFromTarget": "target에서 가져오기", "mcp.backupsButton": "백업", + "mcp.check.button": "검사", + "mcp.check.running": "검사 중…", + "mcp.check.problems.one": "서버 1개에 문제가 있습니다", + "mcp.check.problems.other": "서버 {count}개에 문제가 있습니다", + "mcp.check.allGood.one": "서버 1개에 문제가 없습니다", + "mcp.check.allGood.other": "서버 {count}개 모두 문제가 없습니다", + "mcp.check.counts": "{errors} error, {warnings} warning", + "mcp.check.justNow": "방금 검사함", + "mcp.check.checkedAt": "{time} 검사함", + "mcp.check.rerun": "다시 검사", + "mcp.check.envNote": "환경 변수는 skillshare ui를 시작한 터미널 기준입니다. Dock에서 연 앱은 읽지 못할 수 있습니다.", + "mcp.check.finding.env": "{subject}을(를) 읽지만 이 변수가 설정되어 있지 않습니다.", + "mcp.check.finding.command": "명령 {subject}을(를) 찾을 수 없습니다. 설치되어 있고 PATH에 있는지 확인하세요.", + "mcp.check.finding.dns": "{subject}을(를) 확인할 수 없습니다. 네트워크나 URL이 잘못되었을 수 있습니다.", + "mcp.check.finding.notSynced": "아직 동기화되지 않았습니다. \"MCP 동기화\"를 누르면 기록됩니다.", + "mcp.check.tag.error": "{count} error", + "mcp.check.tag.warning": "{count} warning", "mcp.transport": "전송 방식", "mcp.offHere": "이 프로젝트에서 끄기", "mcp.offHint": "skillshare는 Agent 설정을 읽지 않아 이름을 검사하지 않습니다. 맞는 것이 없는 이름은 오류 없이 무시됩니다.", diff --git a/ui/src/i18n/locales/pt-BR.json b/ui/src/i18n/locales/pt-BR.json index 5bd1ae6ec..fe546bdf9 100644 --- a/ui/src/i18n/locales/pt-BR.json +++ b/ui/src/i18n/locales/pt-BR.json @@ -54,6 +54,23 @@ "mcp.editServer": "Editar servidor", "mcp.importFromTarget": "Importar de um target", "mcp.backupsButton": "Backups", + "mcp.check.button": "Verificar", + "mcp.check.running": "Verificando…", + "mcp.check.problems.one": "1 servidor tem problemas", + "mcp.check.problems.other": "{count} servidores têm problemas", + "mcp.check.allGood.one": "1 servidor não tem problemas", + "mcp.check.allGood.other": "Nenhum dos {count} servidores tem problemas", + "mcp.check.counts": "{errors} error, {warnings} warning", + "mcp.check.justNow": "verificado agora", + "mcp.check.checkedAt": "verificado {time}", + "mcp.check.rerun": "Verificar de novo", + "mcp.check.envNote": "As variáveis são lidas do terminal que iniciou o skillshare ui; apps abertos pelo Dock podem não enxergá-las.", + "mcp.check.finding.env": "Lê {subject}, mas essa variável não está definida.", + "mcp.check.finding.command": "O comando {subject} não foi encontrado. Confira se está instalado e no PATH.", + "mcp.check.finding.dns": "Não foi possível resolver {subject}. A rede ou a URL pode estar errada.", + "mcp.check.finding.notSynced": "Ainda não sincronizado. É gravado quando você clica em Sincronizar MCP.", + "mcp.check.tag.error": "{count} error", + "mcp.check.tag.warning": "{count} warning", "mcp.transport": "Transporte", "mcp.offHere": "Desligado neste projeto", "mcp.offHint": "O skillshare não lê a configuração do Agent, então o nome não é verificado. Se não corresponder a nada, é ignorado sem erro.", diff --git a/ui/src/i18n/locales/zh-CN.json b/ui/src/i18n/locales/zh-CN.json index b0280ecc1..dda233763 100644 --- a/ui/src/i18n/locales/zh-CN.json +++ b/ui/src/i18n/locales/zh-CN.json @@ -54,6 +54,23 @@ "mcp.editServer": "编辑服务器", "mcp.importFromTarget": "从 target 导入", "mcp.backupsButton": "备份", + "mcp.check.button": "检查", + "mcp.check.running": "检查中…", + "mcp.check.problems.one": "1 个服务器有问题", + "mcp.check.problems.other": "{count} 个服务器有问题", + "mcp.check.allGood.one": "1 个服务器没有问题", + "mcp.check.allGood.other": "{count} 个服务器都没有问题", + "mcp.check.counts": "{errors} error、{warnings} warning", + "mcp.check.justNow": "刚刚检查", + "mcp.check.checkedAt": "{time}检查", + "mcp.check.rerun": "重新检查", + "mcp.check.envNote": "环境变量以启动 skillshare ui 的终端为准,从 Dock 打开的 App 不一定读得到。", + "mcp.check.finding.env": "读取 {subject},但这个变量没有设置。", + "mcp.check.finding.command": "找不到命令 {subject},请确认已安装,并且在 PATH 中。", + "mcp.check.finding.dns": "无法解析 {subject},可能是网络或网址有误。", + "mcp.check.finding.notSynced": "尚未同步,点击“同步 MCP”后才会写入。", + "mcp.check.tag.error": "{count} error", + "mcp.check.tag.warning": "{count} warning", "mcp.transport": "传输方式", "mcp.offHere": "在此项目关闭", "mcp.offHint": "skillshare 不会读 Agent 的配置文件,所以不检查名称。打错不会报错,也不会生效。", diff --git a/ui/src/i18n/locales/zh-TW.json b/ui/src/i18n/locales/zh-TW.json index 0ce19816d..d8bcaf7df 100644 --- a/ui/src/i18n/locales/zh-TW.json +++ b/ui/src/i18n/locales/zh-TW.json @@ -54,6 +54,23 @@ "mcp.editServer": "編輯伺服器", "mcp.importFromTarget": "從 target 匯入", "mcp.backupsButton": "備份", + "mcp.check.button": "檢查", + "mcp.check.running": "檢查中…", + "mcp.check.problems.one": "1 個伺服器有問題", + "mcp.check.problems.other": "{count} 個伺服器有問題", + "mcp.check.allGood.one": "1 個伺服器沒有問題", + "mcp.check.allGood.other": "{count} 個伺服器都沒有問題", + "mcp.check.counts": "{errors} error、{warnings} warning", + "mcp.check.justNow": "剛剛檢查", + "mcp.check.checkedAt": "{time}檢查", + "mcp.check.rerun": "重新檢查", + "mcp.check.envNote": "環境變數以啟動 skillshare ui 的終端機為準,從 Dock 開啟的 App 不一定讀得到。", + "mcp.check.finding.env": "讀取 {subject},但這個變數沒有設定。", + "mcp.check.finding.command": "找不到指令 {subject},請確認已安裝,而且在 PATH 裡。", + "mcp.check.finding.dns": "無法解析 {subject},可能是網路或網址有誤。", + "mcp.check.finding.notSynced": "尚未同步,按「同步 MCP」後才會寫入。", + "mcp.check.tag.error": "{count} error", + "mcp.check.tag.warning": "{count} warning", "mcp.transport": "傳輸方式", "mcp.offHere": "在此專案關閉", "mcp.offHint": "skillshare 不會讀 Agent 的設定檔,所以不檢查名稱。打錯不會報錯,也不會生效。", diff --git a/ui/src/pages/MCPPage.tsx b/ui/src/pages/MCPPage.tsx index 35c1e5c40..9539e3d60 100644 --- a/ui/src/pages/MCPPage.tsx +++ b/ui/src/pages/MCPPage.tsx @@ -1,7 +1,7 @@ import { useMemo, useState } from 'react'; import { Navigate, useSearchParams } from 'react-router-dom'; import { useQueryClient } from '@tanstack/react-query'; -import { AlertCircle, Archive, ChevronDown, Copy, Download, Eye, Pencil, Plug, Plus, PowerOff, Trash2, X } from 'lucide-react'; +import { AlertCircle, Archive, ChevronDown, Copy, Download, Eye, ListChecks, Pencil, Plug, Plus, PowerOff, Trash2, X } from 'lucide-react'; import { mcpApi, type MCPMutation, type MCPPlan, type MCPSettings } from '../api/mcp'; import Button from '../components/Button'; import { useAppContext } from '../context/AppContext'; @@ -15,6 +15,8 @@ import { useToast } from '../components/Toast'; import MCPDefaults from '../components/mcp/MCPDefaults'; import MCPImportDialog from '../components/mcp/MCPImportDialog'; import MCPUnmanagedNote from '../components/mcp/MCPUnmanagedNote'; +import MCPCheckNote from '../components/mcp/MCPCheckNote'; +import { problemsByServer, useMCPCheck } from '../components/mcp/useMCPCheck'; import { projectUrl } from '../components/projects/projectView'; import MCPSyncBox from '../components/mcp/MCPSyncBox'; import MCPServerList from '../components/mcp/MCPServerList'; @@ -56,15 +58,17 @@ function mcpPageModel(data: MCPList | undefined, order: readonly string[]) { type MCPList = Awaited>; type PageModel = ReturnType; +type MCPCheck = ReturnType; type ImportRequest = { conflict?: { target: string; name: string }; from?: string; project?: string }; -function MCPHeader({ backups, isProjectMode, onBackups, onImport, onOff, onAdd }: { backups: boolean; isProjectMode: boolean; onBackups: () => void; onImport: () => void; onOff: () => void; onAdd: () => void }) { +function MCPHeader({ check, backups, isProjectMode, onBackups, onImport, onOff, onAdd }: { check: MCPCheck; backups: boolean; isProjectMode: boolean; onBackups: () => void; onImport: () => void; onOff: () => void; onAdd: () => void }) { const t = useT(); return ( + {backups ? : null} {/* Only a project file can turn off a server the Agent defines globally. */} @@ -114,9 +118,10 @@ interface ContentProps { onAdd: () => void; onSettings: (settings: MCPSettings) => void; resolve: MCPResolve; + check: MCPCheck; } -function MCPContent({ data, model, order, allFiles, onShowAll, busy, onToggle, onMenu, onImport, onAdd, onSettings, resolve }: ContentProps) { +function MCPContent({ data, model, order, allFiles, onShowAll, busy, onToggle, onMenu, onImport, onAdd, onSettings, resolve, check }: ContentProps) { const t = useT(); const { toast } = useToast(); const { rows, roots, changes, conflicts, servers, defaults, matrixTargets, files, targetsOf, showSync } = model; @@ -160,9 +165,10 @@ function MCPContent({ data, model, order, allFiles, onShowAll, busy, onToggle, o
)} + void check.run()} /> !u.project)} onImport={(from) => onImport({ from })} /> {rows.length > 0 ? ( - matrixTargets.has(x))} targetsOf={targetsOf} onToggle={onToggle} onMenu={onMenu} disabled={busy} /> + matrixTargets.has(x))} targetsOf={targetsOf} onToggle={onToggle} onMenu={onMenu} disabled={busy} problems={problemsByServer(check.report)} /> ) : ( (null); const [allFiles, setAllFiles] = useState(false); + const check = useMCPCheck(); const refresh = () => { void cache.invalidateQueries({ queryKey: queryKeys.mcp }); @@ -381,12 +388,12 @@ export default function MCPPage() { return (
- setBackupsOpen(true)} onImport={() => setImporting({})} onOff={() => { setAddingOff(true); setAddMode('form'); setEditing(''); }} onAdd={() => { setAddingOff(false); setAddMode('form'); setEditing(''); }} /> + setBackupsOpen(true)} onImport={() => setImporting({})} onOff={() => { setAddingOff(true); setAddMode('form'); setEditing(''); }} onAdd={() => { setAddingOff(false); setAddMode('form'); setEditing(''); }} /> {data && ( - setAllFiles(!allFiles)} busy={busy} onToggle={(n, x, on) => void toggle(n, x, on)} onMenu={openMenu} onImport={setImporting} onAdd={() => { setAddingOff(false); setAddMode('form'); setEditing(''); }} onSettings={(settings) => void saveSettings(settings)} resolve={resolve} /> + setAllFiles(!allFiles)} busy={busy} onToggle={(n, x, on) => void toggle(n, x, on)} onMenu={openMenu} onImport={setImporting} onAdd={() => { setAddingOff(false); setAddMode('form'); setEditing(''); }} onSettings={(settings) => void saveSettings(settings)} resolve={resolve} check={check} /> )} {editing !== null && data && ( setEditing(null)} onSaved={() => done(t('mcp.toast.saved'))} />