From 4909044831ffd73e7cfd2bef63b21f944449bc47 Mon Sep 17 00:00:00 2001 From: "Nolann B." <100787331+nolannbiron@users.noreply.github.com> Date: Mon, 30 Mar 2026 09:55:45 +0200 Subject: [PATCH] Add Claude Code and Codex connect actions (#4145) --- .changeset/fifty-birds-win.md | 5 ++ .../components/PageActions/PageActions.tsx | 48 +++++++++++++++++++ .../PageActions/PageActionsDropdown.tsx | 13 +++++ packages/gitbook/src/intl/translations/de.ts | 5 +- packages/gitbook/src/intl/translations/en.ts | 5 +- packages/gitbook/src/intl/translations/es.ts | 5 +- packages/gitbook/src/intl/translations/fr.ts | 5 +- packages/gitbook/src/intl/translations/it.ts | 5 +- packages/gitbook/src/intl/translations/ja.ts | 5 +- packages/gitbook/src/intl/translations/ko.ts | 5 +- packages/gitbook/src/intl/translations/nl.ts | 5 +- packages/gitbook/src/intl/translations/no.ts | 5 +- .../gitbook/src/intl/translations/pt-br.ts | 5 +- packages/gitbook/src/intl/translations/ru.ts | 5 +- packages/gitbook/src/intl/translations/zh.ts | 5 +- 15 files changed, 102 insertions(+), 24 deletions(-) create mode 100644 .changeset/fifty-birds-win.md diff --git a/.changeset/fifty-birds-win.md b/.changeset/fifty-birds-win.md new file mode 100644 index 000000000..49eb80f0c --- /dev/null +++ b/.changeset/fifty-birds-win.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Add Claude Code and Codex connect actions diff --git a/packages/gitbook/src/components/PageActions/PageActions.tsx b/packages/gitbook/src/components/PageActions/PageActions.tsx index c778c1839..980beecf6 100644 --- a/packages/gitbook/src/components/PageActions/PageActions.tsx +++ b/packages/gitbook/src/components/PageActions/PageActions.tsx @@ -271,6 +271,54 @@ export function ActionOpenMCP(props: { ); } +/** + * Action to copy the MCP install command for a CLI-based provider. + */ +export function ActionCopyMCPCommand(props: { + siteTitle: string; + mcpURL: string; + provider: 'claude-code' | 'codex'; + type: PageActionType; +}) { + const { siteTitle, provider, mcpURL, type } = props; + const language = useLanguage(); + + const slug = + siteTitle + .toLowerCase() + .replace(/[^a-z0-9]+/g, '-') + .replace(/^-|-$/g, '') || 'docs'; + + const providerInfo = React.useMemo<{ label: string; icon: IconName; command: string }>(() => { + switch (provider) { + case 'claude-code': + return { + label: 'Claude Code', + icon: 'claude', + command: `claude mcp add ${slug} --scope user --transport http ${mcpURL}`, + }; + case 'codex': + return { + label: 'Codex', + icon: 'chatgpt', + command: `codex mcp add ${slug} --url ${mcpURL}`, + }; + default: + assertNever(provider); + } + }, [provider, slug, mcpURL]); + + return ( + + ); +} + /** * Action to view the page as a PDF. */ diff --git a/packages/gitbook/src/components/PageActions/PageActionsDropdown.tsx b/packages/gitbook/src/components/PageActions/PageActionsDropdown.tsx index 2a041ea74..cf29c1495 100644 --- a/packages/gitbook/src/components/PageActions/PageActionsDropdown.tsx +++ b/packages/gitbook/src/components/PageActions/PageActionsDropdown.tsx @@ -8,6 +8,7 @@ import React, { useRef } from 'react'; import { useAI } from '../AI'; import { ToggleChevron } from '../primitives'; import { + ActionCopyMCPCommand, ActionCopyMCPURL, ActionCopyMarkdown, ActionOpenAssistant, @@ -121,6 +122,18 @@ function getPageDropdownActions(props: PageActionsDropdownProps): React.ReactNod siteTitle={siteTitle} type="dropdown-menu-item" /> + + ) : null, diff --git a/packages/gitbook/src/intl/translations/de.ts b/packages/gitbook/src/intl/translations/de.ts index a6e8366cb..65b57cf51 100644 --- a/packages/gitbook/src/intl/translations/de.ts +++ b/packages/gitbook/src/intl/translations/de.ts @@ -139,9 +139,10 @@ export const de = { open_in: 'Öffnen in ${1}', open_in_llms_pre_prompt: 'Lies ${1} und beantworte Fragen zum Inhalt.', connect_mcp_to: 'Mit ${1} verbinden', - install_mcp_on: 'MCP-Server auf ${1} installieren', + install_mcp_on: 'Dieses MCP in ${1} verwenden', connect_with_mcp: 'Mit MCP verbinden', - copy_mcp_url: 'MCP-Server-URL kopieren', + copy_mcp_url: 'Dieses MCP zu jedem kompatiblen Client hinzufügen', + copy_mcp_install_command: 'Dieses MCP in ${1} verwenden', press_to_confirm: 'Drücke ${1} zum Bestätigen', tool_call_skipped: 'Übersprungen "${1}"', scroll_back: 'Zurück scrollen', diff --git a/packages/gitbook/src/intl/translations/en.ts b/packages/gitbook/src/intl/translations/en.ts index def0c138d..150bb643e 100644 --- a/packages/gitbook/src/intl/translations/en.ts +++ b/packages/gitbook/src/intl/translations/en.ts @@ -135,9 +135,10 @@ export const en = { open_in: 'Open in ${1}', open_in_llms_pre_prompt: 'Read ${1} and answer questions about the content.', connect_mcp_to: 'Connect to ${1}', - install_mcp_on: 'Install MCP Server on ${1}', + install_mcp_on: 'Use this MCP in ${1}', connect_with_mcp: 'Connect with MCP', - copy_mcp_url: 'Copy the MCP Server URL', + copy_mcp_url: 'Add this MCP to any compatible client', + copy_mcp_install_command: 'Use this MCP in ${1}', press_to_confirm: 'Press ${1} to confirm', tool_call_skipped: 'Skipped "${1}"', scroll_back: 'Scroll back', diff --git a/packages/gitbook/src/intl/translations/es.ts b/packages/gitbook/src/intl/translations/es.ts index d629b80d3..6ea376319 100644 --- a/packages/gitbook/src/intl/translations/es.ts +++ b/packages/gitbook/src/intl/translations/es.ts @@ -140,9 +140,10 @@ export const es: TranslationLanguage = { open_in: 'Abrir en ${1}', open_in_llms_pre_prompt: 'Lee ${1} y responde preguntas sobre el contenido.', connect_mcp_to: 'Conectar a ${1}', - install_mcp_on: 'Instalar servidor MCP en ${1}', + install_mcp_on: 'Usar este MCP en ${1}', connect_with_mcp: 'Conectar con MCP', - copy_mcp_url: 'Copiar URL del servidor MCP', + copy_mcp_url: 'Agregar este MCP a cualquier cliente compatible', + copy_mcp_install_command: 'Usar este MCP en ${1}', press_to_confirm: 'Presiona ${1} para confirmar', tool_call_skipped: 'Omitido "${1}"', scroll_back: 'Desplazar hacia atrás', diff --git a/packages/gitbook/src/intl/translations/fr.ts b/packages/gitbook/src/intl/translations/fr.ts index a67e8dc8d..8b6150ef7 100644 --- a/packages/gitbook/src/intl/translations/fr.ts +++ b/packages/gitbook/src/intl/translations/fr.ts @@ -135,9 +135,10 @@ export const fr = { open_in: 'Ouvrir dans ${1}', open_in_llms_pre_prompt: 'Lire ${1} et répondre aux questions sur le contenu.', connect_mcp_to: 'Se connecter à ${1}', - install_mcp_on: 'Installer le serveur MCP sur ${1}', + install_mcp_on: 'Utiliser ce MCP dans ${1}', connect_with_mcp: 'Se connecter avec MCP', - copy_mcp_url: "Copier l'URL du serveur MCP", + copy_mcp_url: 'Ajouter ce MCP à un client compatible', + copy_mcp_install_command: 'Utiliser ce MCP dans ${1}', press_to_confirm: 'Appuyez sur ${1} pour confirmer', tool_call_skipped: 'Ignoré "${1}"', scroll_back: "Défiler vers l'arrière", diff --git a/packages/gitbook/src/intl/translations/it.ts b/packages/gitbook/src/intl/translations/it.ts index 78b402011..f3cbecc5f 100644 --- a/packages/gitbook/src/intl/translations/it.ts +++ b/packages/gitbook/src/intl/translations/it.ts @@ -139,9 +139,10 @@ export const it: TranslationLanguage = { open_in: 'Apri in ${1}', open_in_llms_pre_prompt: 'Leggi ${1} e rispondi alle domande sul contenuto.', connect_mcp_to: 'Connetti a ${1}', - install_mcp_on: 'Installa il server MCP su ${1}', + install_mcp_on: 'Usa questo MCP in ${1}', connect_with_mcp: 'Connettiti con MCP', - copy_mcp_url: "Copia l'URL del server MCP", + copy_mcp_url: 'Aggiungi questo MCP a qualsiasi client compatibile', + copy_mcp_install_command: 'Usa questo MCP in ${1}', press_to_confirm: 'Premi ${1} per confermare', tool_call_skipped: 'Saltato "${1}"', scroll_back: 'Scorri indietro', diff --git a/packages/gitbook/src/intl/translations/ja.ts b/packages/gitbook/src/intl/translations/ja.ts index c65c9a2bc..63754ca87 100644 --- a/packages/gitbook/src/intl/translations/ja.ts +++ b/packages/gitbook/src/intl/translations/ja.ts @@ -138,9 +138,10 @@ export const ja: TranslationLanguage = { open_in: '${1} で開く', open_in_llms_pre_prompt: '${1} を読んで内容に関する質問に答えてください。', connect_mcp_to: '${1} に接続', - install_mcp_on: '${1} にMCPサーバーをインストール', + install_mcp_on: '${1} でこのMCPを使用', connect_with_mcp: 'MCPに接続', - copy_mcp_url: 'MCPサーバーのURLをコピー', + copy_mcp_url: '互換性のあるクライアントにこのMCPを追加', + copy_mcp_install_command: '${1} でこのMCPを使用', press_to_confirm: '確認するには${1}を押してください', tool_call_skipped: '"${1}" をスキップしました', scroll_back: '戻る', diff --git a/packages/gitbook/src/intl/translations/ko.ts b/packages/gitbook/src/intl/translations/ko.ts index ba590e349..361b8a4bc 100644 --- a/packages/gitbook/src/intl/translations/ko.ts +++ b/packages/gitbook/src/intl/translations/ko.ts @@ -137,9 +137,10 @@ export const ko: TranslationLanguage = { open_in: '${1}에서 열기', open_in_llms_pre_prompt: '${1}을(를) 읽고 콘텐츠에 대한 질문에 답하세요.', connect_mcp_to: '${1}에 연결', - install_mcp_on: '${1}에 MCP 서버 설치', + install_mcp_on: '${1}에서 이 MCP 사용', connect_with_mcp: 'MCP로 연결', - copy_mcp_url: 'MCP 서버 URL 복사', + copy_mcp_url: '호환 클라이언트에 이 MCP 추가', + copy_mcp_install_command: '${1}에서 이 MCP 사용', press_to_confirm: '확인하려면 ${1} 누르기', tool_call_skipped: '"${1}" 건너뜀', scroll_back: '뒤로 스크롤', diff --git a/packages/gitbook/src/intl/translations/nl.ts b/packages/gitbook/src/intl/translations/nl.ts index 24efc3a3a..20d18093d 100644 --- a/packages/gitbook/src/intl/translations/nl.ts +++ b/packages/gitbook/src/intl/translations/nl.ts @@ -138,9 +138,10 @@ export const nl: TranslationLanguage = { open_in: 'Open in ${1}', open_in_llms_pre_prompt: 'Lees ${1} en beantwoord vragen over de inhoud.', connect_mcp_to: 'Verbind met ${1}', - install_mcp_on: 'Installeer MCP-server op ${1}', + install_mcp_on: 'Gebruik deze MCP in ${1}', connect_with_mcp: 'Verbind met MCP', - copy_mcp_url: 'Kopieer MCP-server URL', + copy_mcp_url: 'Voeg deze MCP toe aan elke compatibele client', + copy_mcp_install_command: 'Gebruik deze MCP in ${1}', press_to_confirm: 'Druk op ${1} om te bevestigen', tool_call_skipped: '"${1}" overgeslagen', scroll_back: 'Terug scrollen', diff --git a/packages/gitbook/src/intl/translations/no.ts b/packages/gitbook/src/intl/translations/no.ts index 397ed422b..e02b74fdf 100644 --- a/packages/gitbook/src/intl/translations/no.ts +++ b/packages/gitbook/src/intl/translations/no.ts @@ -138,9 +138,10 @@ export const no: TranslationLanguage = { open_in: 'Åpne i ${1}', open_in_llms_pre_prompt: 'Les ${1} og besvar spørsmål om innholdet.', connect_mcp_to: 'Koble til ${1}', - install_mcp_on: 'Installer MCP-server på ${1}', + install_mcp_on: 'Bruk denne MCP i ${1}', connect_with_mcp: 'Koble til MCP', - copy_mcp_url: 'Kopier MCP-server URL', + copy_mcp_url: 'Legg til denne MCP i enhver kompatibel klient', + copy_mcp_install_command: 'Bruk denne MCP i ${1}', press_to_confirm: 'Trykk ${1} for å bekrefte', tool_call_skipped: 'Hoppet over "${1}"', scroll_back: 'Rull tilbake', diff --git a/packages/gitbook/src/intl/translations/pt-br.ts b/packages/gitbook/src/intl/translations/pt-br.ts index 9d83a104b..927e7fcfd 100644 --- a/packages/gitbook/src/intl/translations/pt-br.ts +++ b/packages/gitbook/src/intl/translations/pt-br.ts @@ -138,9 +138,10 @@ export const pt_br = { open_in: 'Abrir no ${1}', open_in_llms_pre_prompt: 'Leia ${1} e responda perguntas sobre o conteúdo.', connect_mcp_to: 'Conectar a ${1}', - install_mcp_on: 'Instalar servidor MCP em ${1}', + install_mcp_on: 'Usar este MCP no ${1}', connect_with_mcp: 'Conectar com MCP', - copy_mcp_url: 'Copiar URL do servidor MCP', + copy_mcp_url: 'Adicionar este MCP a qualquer cliente compatível', + copy_mcp_install_command: 'Usar este MCP no ${1}', press_to_confirm: 'Pressione ${1} para confirmar', tool_call_skipped: 'Pulado "${1}"', scroll_back: 'Rolar para trás', diff --git a/packages/gitbook/src/intl/translations/ru.ts b/packages/gitbook/src/intl/translations/ru.ts index cc9bddcd6..a008081ef 100644 --- a/packages/gitbook/src/intl/translations/ru.ts +++ b/packages/gitbook/src/intl/translations/ru.ts @@ -137,9 +137,10 @@ export const ru = { open_in: 'Открыть в ${1}', open_in_llms_pre_prompt: 'Прочитай ${1} и ответь на вопросы о содержимом.', connect_mcp_to: 'Подключиться к ${1}', - install_mcp_on: 'Установить MCP-сервер на ${1}', + install_mcp_on: 'Использовать этот MCP в ${1}', connect_with_mcp: 'Подключиться к MCP', - copy_mcp_url: 'Скопировать URL MCP-сервера', + copy_mcp_url: 'Добавить этот MCP в любой совместимый клиент', + copy_mcp_install_command: 'Использовать этот MCP в ${1}', press_to_confirm: 'Нажмите ${1} для подтверждения', tool_call_skipped: 'Пропущен "${1}"', scroll_back: 'Прокрутить назад', diff --git a/packages/gitbook/src/intl/translations/zh.ts b/packages/gitbook/src/intl/translations/zh.ts index 4fae0ff3f..f528cbbea 100644 --- a/packages/gitbook/src/intl/translations/zh.ts +++ b/packages/gitbook/src/intl/translations/zh.ts @@ -134,9 +134,10 @@ export const zh: TranslationLanguage = { open_in: '在 ${1} 中打开', open_in_llms_pre_prompt: '阅读 ${1} 并回答内容相关的问题。', connect_mcp_to: '连接到 ${1}', - install_mcp_on: '在 ${1} 上安装 MCP 服务器', + install_mcp_on: '在 ${1} 中使用此 MCP', connect_with_mcp: '连接 MCP', - copy_mcp_url: '复制 MCP 服务器 URL', + copy_mcp_url: '将此 MCP 添加到任何兼容客户端', + copy_mcp_install_command: '在 ${1} 中使用此 MCP', press_to_confirm: '按 ${1} 确认', tool_call_skipped: '已跳过 "${1}"', scroll_back: '向后滚动',