Skip to content

Commit f3affc3

Browse files
authored
Add support for MCP tools (#3410)
1 parent 59da30f commit f3affc3

File tree

14 files changed

+40
-3
lines changed

14 files changed

+40
-3
lines changed

.changeset/few-cars-joke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": minor
3+
---
4+
5+
Display MCP tool calls in AI chat.

bun.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
"react-dom": "^19.0.0",
251251
},
252252
"catalog": {
253-
"@gitbook/api": "^0.123.0",
253+
"@gitbook/api": "^0.125.0",
254254
},
255255
"packages": {
256256
"@ai-sdk/provider": ["@ai-sdk/[email protected]", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-0M+qjp+clUD0R1E5eWQFhxEvWLNaOtGQRUaBn8CUABnSKredagq92hUS9VjOzGsTm37xLfpaxl97AVtbeOsHew=="],
@@ -613,7 +613,7 @@
613613

614614
"@fortawesome/fontawesome-svg-core": ["@fortawesome/[email protected]", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "6.6.0" } }, "sha512-KHwPkCk6oRT4HADE7smhfsKudt9N/9lm6EJ5BVg0tD1yPA5hht837fB87F8pn15D8JfTqQOjhKTktwmLMiD7Kg=="],
615615

616-
"@gitbook/api": ["@gitbook/api@0.123.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-BszoIk4H/wWb0jnGSJPSSXSAO8tV4B4/LHwl5ygfERHqk9rOGpM/U7+yOlmbX/tnm30vE+MQ3QQ5i8hN8wVk1w=="],
616+
"@gitbook/api": ["@gitbook/api@0.125.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-8WrsENzW7ehafLWbBfk0zs7xxmCJ/H8yy05BQGdZOR26TJzfMfkqMtuCLFukT8vbgjRgRrHanBoU98cCXHm1rg=="],
617617

618618
"@gitbook/cache-tags": ["@gitbook/cache-tags@workspace:packages/cache-tags"],
619619

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"workspaces": {
3535
"packages": ["packages/*"],
3636
"catalog": {
37-
"@gitbook/api": "^0.123.0"
37+
"@gitbook/api": "^0.125.0"
3838
}
3939
},
4040
"patchedDependencies": {

packages/gitbook/src/components/AI/server-actions/AIToolCallsSummary.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type {
88
AIToolCall,
99
AIToolCallGetPageContent,
1010
AIToolCallGetPages,
11+
AIToolCallMCP,
1112
AIToolCallSearch,
1213
ContentRef,
1314
} from '@gitbook/api';
@@ -54,6 +55,8 @@ function getDescriptionForToolCall(toolCall: AIToolCall, context: GitBookSiteCon
5455
return <DescriptionForSearchToolCall toolCall={toolCall} context={context} />;
5556
case 'getPages':
5657
return <DescriptionForGetPagesToolCall toolCall={toolCall} context={context} />;
58+
case 'mcp':
59+
return <DescriptionForMCPToolCall toolCall={toolCall} context={context} />;
5760
default:
5861
return <>{toolCall.tool}</>;
5962
}
@@ -89,6 +92,25 @@ function DescriptionForPageContentToolCall(props: {
8992
);
9093
}
9194

95+
function DescriptionForMCPToolCall(props: {
96+
toolCall: AIToolCallMCP;
97+
context: GitBookSiteContext;
98+
}) {
99+
const { toolCall, context } = props;
100+
101+
const language = getSpaceLanguage(context.customization);
102+
103+
return (
104+
<p>
105+
{t(
106+
language,
107+
'ai_chat_tools_mcp_tool',
108+
<strong>{toolCall.mcpToolTitle ?? toolCall.mcpToolName}</strong>
109+
)}
110+
</p>
111+
);
112+
}
113+
92114
async function DescriptionForSearchToolCall(props: {
93115
toolCall: AIToolCallSearch;
94116
context: GitBookSiteContext;

packages/gitbook/src/components/DocumentView/Integration/contentkit.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const contentKitServerContext: ContentKitServerContext = {
2222
lock: (props) => <Icon icon="lock" {...props} />,
2323
check: (props) => <Icon icon="check" {...props} />,
2424
'check-circle': (props) => <Icon icon="check-circle" {...props} />,
25+
'eye-off': (props) => <Icon icon="eye-slash" {...props} />,
2526
},
2627
codeBlock: (props) => {
2728
return <PlainCodeBlock code={props.code} syntax={props.syntax} />;

packages/gitbook/src/intl/translations/de.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,5 @@ export const de = {
9090
searched_for: 'Gesucht nach ${1}',
9191
ai_chat_tools_listed_pages: 'Docs durchsucht',
9292
ai_chat_tools_read_page: 'Seite ${1} gelesen',
93+
ai_chat_tools_mcp_tool: 'Aufgerufen ${1}',
9394
};

packages/gitbook/src/intl/translations/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,5 @@ export const en = {
8888
searched_for: 'Searched for ${1}',
8989
ai_chat_tools_listed_pages: 'Browsed the docs',
9090
ai_chat_tools_read_page: 'Read page ${1}',
91+
ai_chat_tools_mcp_tool: 'Called ${1}',
9192
};

packages/gitbook/src/intl/translations/es.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,5 @@ export const es: TranslationLanguage = {
9292
searched_for: 'Buscado ${1}',
9393
ai_chat_tools_listed_pages: 'Exploró los docs',
9494
ai_chat_tools_read_page: 'Leyó la página ${1}',
95+
ai_chat_tools_mcp_tool: 'Llamó a ${1}',
9596
};

packages/gitbook/src/intl/translations/fr.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,5 @@ export const fr: TranslationLanguage = {
9090
searched_for: 'Recherché ${1}',
9191
ai_chat_tools_listed_pages: 'Parcouru les docs',
9292
ai_chat_tools_read_page: 'Lu la page ${1}',
93+
ai_chat_tools_mcp_tool: 'Appelé ${1}',
9394
};

packages/gitbook/src/intl/translations/ja.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,5 @@ export const ja: TranslationLanguage = {
9191
searched_for: '${1}を検索しました',
9292
ai_chat_tools_listed_pages: 'ドキュメントを閲覧',
9393
ai_chat_tools_read_page: 'ページ ${1} を読みました',
94+
ai_chat_tools_mcp_tool: '${1} を呼び出しました',
9495
};

0 commit comments

Comments
 (0)