From 2c4d40ad97c47ff81b4150c043b60719cb4e69bc Mon Sep 17 00:00:00 2001 From: Peter White <1788320+peterwhite@users.noreply.github.com> Date: Fri, 11 Sep 2026 08:30:36 +0200 Subject: [PATCH] Expose the site MCP tools through WebMCP in published docs (#4604) --- .changeset/webmcp-published-docs.md | 5 ++ .../src/components/SiteLayout/SiteLayout.tsx | 6 +- .../gitbook/src/components/WebMCP/WebMCP.tsx | 81 +++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 .changeset/webmcp-published-docs.md create mode 100644 packages/gitbook/src/components/WebMCP/WebMCP.tsx diff --git a/.changeset/webmcp-published-docs.md b/.changeset/webmcp-published-docs.md new file mode 100644 index 000000000..57454328c --- /dev/null +++ b/.changeset/webmcp-published-docs.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Expose the site's MCP tools to browser agents through WebMCP when the MCP page action is enabled. diff --git a/packages/gitbook/src/components/SiteLayout/SiteLayout.tsx b/packages/gitbook/src/components/SiteLayout/SiteLayout.tsx index 939543b6e..156373fa0 100644 --- a/packages/gitbook/src/components/SiteLayout/SiteLayout.tsx +++ b/packages/gitbook/src/components/SiteLayout/SiteLayout.tsx @@ -3,7 +3,7 @@ import Script from 'next/script'; import React from 'react'; import * as ReactDOM from 'react-dom'; -import { CustomizationDefaultThemeMode } from '@gitbook/api'; +import { CustomizationDefaultThemeMode, CustomizationPageActionType } from '@gitbook/api'; import { AIContextProvider } from '../AI'; import { RocketLoaderDetector } from './RocketLoaderDetector'; @@ -12,6 +12,7 @@ import { AdminToolbar } from '@/components/AdminToolbar'; import { CookiesToast } from '@/components/Cookies'; import { LoadIntegrations } from '@/components/Integrations'; import { SpaceLayout } from '@/components/SpaceLayout'; +import { WebMCP } from '@/components/WebMCP/WebMCP'; import type { VisitorAuthClaims } from '@/lib/adaptive'; import { buildVersion } from '@/lib/build'; import type { GitBookSiteContext } from '@/lib/context'; @@ -117,6 +118,9 @@ export async function SiteLayout(props: { + {customization.pageActions.items.includes(CustomizationPageActionType.Mcp) ? ( + + ) : null} {scripts.map(({ script }) => isDeferrableScript(script) ? (