mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +00:00
Add support for MCP tools (#3410)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": minor
|
||||
---
|
||||
|
||||
Display MCP tool calls in AI chat.
|
||||
@@ -250,7 +250,7 @@
|
||||
"react-dom": "^19.0.0",
|
||||
},
|
||||
"catalog": {
|
||||
"@gitbook/api": "^0.123.0",
|
||||
"@gitbook/api": "^0.125.0",
|
||||
},
|
||||
"packages": {
|
||||
"@ai-sdk/provider": ["@ai-sdk/provider@1.1.0", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-0M+qjp+clUD0R1E5eWQFhxEvWLNaOtGQRUaBn8CUABnSKredagq92hUS9VjOzGsTm37xLfpaxl97AVtbeOsHew=="],
|
||||
@@ -613,7 +613,7 @@
|
||||
|
||||
"@fortawesome/fontawesome-svg-core": ["@fortawesome/fontawesome-svg-core@6.6.0", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "6.6.0" } }, "sha512-KHwPkCk6oRT4HADE7smhfsKudt9N/9lm6EJ5BVg0tD1yPA5hht837fB87F8pn15D8JfTqQOjhKTktwmLMiD7Kg=="],
|
||||
|
||||
"@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=="],
|
||||
"@gitbook/api": ["@gitbook/api@0.125.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-8WrsENzW7ehafLWbBfk0zs7xxmCJ/H8yy05BQGdZOR26TJzfMfkqMtuCLFukT8vbgjRgRrHanBoU98cCXHm1rg=="],
|
||||
|
||||
"@gitbook/cache-tags": ["@gitbook/cache-tags@workspace:packages/cache-tags"],
|
||||
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@
|
||||
"workspaces": {
|
||||
"packages": ["packages/*"],
|
||||
"catalog": {
|
||||
"@gitbook/api": "^0.123.0"
|
||||
"@gitbook/api": "^0.125.0"
|
||||
}
|
||||
},
|
||||
"patchedDependencies": {
|
||||
|
||||
@@ -8,6 +8,7 @@ import type {
|
||||
AIToolCall,
|
||||
AIToolCallGetPageContent,
|
||||
AIToolCallGetPages,
|
||||
AIToolCallMCP,
|
||||
AIToolCallSearch,
|
||||
ContentRef,
|
||||
} from '@gitbook/api';
|
||||
@@ -54,6 +55,8 @@ function getDescriptionForToolCall(toolCall: AIToolCall, context: GitBookSiteCon
|
||||
return <DescriptionForSearchToolCall toolCall={toolCall} context={context} />;
|
||||
case 'getPages':
|
||||
return <DescriptionForGetPagesToolCall toolCall={toolCall} context={context} />;
|
||||
case 'mcp':
|
||||
return <DescriptionForMCPToolCall toolCall={toolCall} context={context} />;
|
||||
default:
|
||||
return <>{toolCall.tool}</>;
|
||||
}
|
||||
@@ -89,6 +92,25 @@ function DescriptionForPageContentToolCall(props: {
|
||||
);
|
||||
}
|
||||
|
||||
function DescriptionForMCPToolCall(props: {
|
||||
toolCall: AIToolCallMCP;
|
||||
context: GitBookSiteContext;
|
||||
}) {
|
||||
const { toolCall, context } = props;
|
||||
|
||||
const language = getSpaceLanguage(context.customization);
|
||||
|
||||
return (
|
||||
<p>
|
||||
{t(
|
||||
language,
|
||||
'ai_chat_tools_mcp_tool',
|
||||
<strong>{toolCall.mcpToolTitle ?? toolCall.mcpToolName}</strong>
|
||||
)}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
async function DescriptionForSearchToolCall(props: {
|
||||
toolCall: AIToolCallSearch;
|
||||
context: GitBookSiteContext;
|
||||
|
||||
@@ -22,6 +22,7 @@ export const contentKitServerContext: ContentKitServerContext = {
|
||||
lock: (props) => <Icon icon="lock" {...props} />,
|
||||
check: (props) => <Icon icon="check" {...props} />,
|
||||
'check-circle': (props) => <Icon icon="check-circle" {...props} />,
|
||||
'eye-off': (props) => <Icon icon="eye-slash" {...props} />,
|
||||
},
|
||||
codeBlock: (props) => {
|
||||
return <PlainCodeBlock code={props.code} syntax={props.syntax} />;
|
||||
|
||||
@@ -90,4 +90,5 @@ export const de = {
|
||||
searched_for: 'Gesucht nach ${1}',
|
||||
ai_chat_tools_listed_pages: 'Docs durchsucht',
|
||||
ai_chat_tools_read_page: 'Seite ${1} gelesen',
|
||||
ai_chat_tools_mcp_tool: 'Aufgerufen ${1}',
|
||||
};
|
||||
|
||||
@@ -88,4 +88,5 @@ export const en = {
|
||||
searched_for: 'Searched for ${1}',
|
||||
ai_chat_tools_listed_pages: 'Browsed the docs',
|
||||
ai_chat_tools_read_page: 'Read page ${1}',
|
||||
ai_chat_tools_mcp_tool: 'Called ${1}',
|
||||
};
|
||||
|
||||
@@ -92,4 +92,5 @@ export const es: TranslationLanguage = {
|
||||
searched_for: 'Buscado ${1}',
|
||||
ai_chat_tools_listed_pages: 'Exploró los docs',
|
||||
ai_chat_tools_read_page: 'Leyó la página ${1}',
|
||||
ai_chat_tools_mcp_tool: 'Llamó a ${1}',
|
||||
};
|
||||
|
||||
@@ -90,4 +90,5 @@ export const fr: TranslationLanguage = {
|
||||
searched_for: 'Recherché ${1}',
|
||||
ai_chat_tools_listed_pages: 'Parcouru les docs',
|
||||
ai_chat_tools_read_page: 'Lu la page ${1}',
|
||||
ai_chat_tools_mcp_tool: 'Appelé ${1}',
|
||||
};
|
||||
|
||||
@@ -91,4 +91,5 @@ export const ja: TranslationLanguage = {
|
||||
searched_for: '${1}を検索しました',
|
||||
ai_chat_tools_listed_pages: 'ドキュメントを閲覧',
|
||||
ai_chat_tools_read_page: 'ページ ${1} を読みました',
|
||||
ai_chat_tools_mcp_tool: '${1} を呼び出しました',
|
||||
};
|
||||
|
||||
@@ -90,4 +90,5 @@ export const nl: TranslationLanguage = {
|
||||
searched_for: 'Gezocht naar ${1}',
|
||||
ai_chat_tools_listed_pages: 'Docs doorzocht',
|
||||
ai_chat_tools_read_page: 'Pagina ${1} gelezen',
|
||||
ai_chat_tools_mcp_tool: '${1} aangeroepen',
|
||||
};
|
||||
|
||||
@@ -90,4 +90,5 @@ export const no: TranslationLanguage = {
|
||||
searched_for: 'Søkte etter ${1}',
|
||||
ai_chat_tools_listed_pages: 'Bladde gjennom docs',
|
||||
ai_chat_tools_read_page: 'Leste side ${1}',
|
||||
ai_chat_tools_mcp_tool: 'Kallte ${1}',
|
||||
};
|
||||
|
||||
@@ -90,4 +90,5 @@ export const pt_br = {
|
||||
searched_for: 'Pesquisou por ${1}',
|
||||
ai_chat_tools_listed_pages: 'Navegou pelos docs',
|
||||
ai_chat_tools_read_page: 'Leu a página ${1}',
|
||||
ai_chat_tools_mcp_tool: 'Chamou ${1}',
|
||||
};
|
||||
|
||||
@@ -87,4 +87,5 @@ export const zh: TranslationLanguage = {
|
||||
searched_for: '搜索了 ${1}',
|
||||
ai_chat_tools_listed_pages: '浏览了文档',
|
||||
ai_chat_tools_read_page: '已读取页面 ${1}',
|
||||
ai_chat_tools_mcp_tool: '调用了 ${1}',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user