@douyinfe/semi-mcp 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/http.js +26 -5
- package/dist/index.d.ts +3 -1
- package/dist/index.js +27 -5
- package/dist/tools/get-semi-document.d.ts +6 -0
- package/package.json +10 -1
package/dist/http.js
CHANGED
|
@@ -383,13 +383,13 @@ function replaceCodeBlocksWithPlaceholders(content, componentName) {
|
|
|
383
383
|
}
|
|
384
384
|
const getSemiDocumentTool = {
|
|
385
385
|
name: 'get_semi_document',
|
|
386
|
-
description: '获取 Semi Design 组件文档、额外文档或组件列表。支持获取:1) 组件文档(如 Button、Input 等组件);2) 额外文档,包括:advanced 分类下的文档(customize-theme、dark-mode、design-source、design-to-code)、ecosystem 分类下的文档(changelog、faq、react19、tailwind、update-to-v2、web-components)、start 分类下的文档(getting-started、introduction、overview)。注意:changelog 文档较大,需要使用分页格式获取,传入 changelog-1(第1页,最新内容)、changelog-2(第2页)等格式,每页300行。对于大型文档,代码块会被替换为占位符,需要使用 get_semi_code_block 工具获取具体代码',
|
|
386
|
+
description: '获取 Semi Design 组件文档、额外文档或组件列表。支持获取:1) 组件文档(如 Button、Input 等组件);2) 额外文档,包括:advanced 分类下的文档(customize-theme、dark-mode、design-source、design-to-code)、ecosystem 分类下的文档(changelog、faq、react19、tailwind、update-to-v2、web-components)、experience 分类下的文档(accessibility、content-guidelines、internationalization)、start 分类下的文档(getting-started、introduction、overview)。注意:changelog 文档较大,需要使用分页格式获取,传入 changelog-1(第1页,最新内容)、changelog-2(第2页)等格式,每页300行。对于大型文档,代码块会被替换为占位符,需要使用 get_semi_code_block 工具获取具体代码',
|
|
387
387
|
inputSchema: {
|
|
388
388
|
type: 'object',
|
|
389
389
|
properties: {
|
|
390
390
|
componentName: {
|
|
391
391
|
type: 'string',
|
|
392
|
-
description: '组件名称或文档名称。组件名称例如:Button、Input、Table 等;额外文档名称例如:customize-theme、dark-mode、changelog-1(changelog第1页,最新)、changelog-2(changelog第2页)等、faq、react19、tailwind、update-to-v2、web-components、getting-started、introduction、overview 等。注意:changelog 必须使用分页格式(changelog-1、changelog-2等),不能直接传入 changelog。如果不提供,则返回组件列表'
|
|
392
|
+
description: '组件名称或文档名称。组件名称例如:Button、Input、Table 等;额外文档名称例如:customize-theme、dark-mode、design-source、design-to-code、changelog-1(changelog第1页,最新)、changelog-2(changelog第2页)等、faq、react19、tailwind、update-to-v2、web-components、accessibility、content-guidelines、internationalization、getting-started、introduction、overview 等。注意:changelog 必须使用分页格式(changelog-1、changelog-2等),不能直接传入 changelog。如果不提供,则返回组件列表'
|
|
393
393
|
},
|
|
394
394
|
version: {
|
|
395
395
|
type: 'string',
|
|
@@ -401,6 +401,19 @@ const getSemiDocumentTool = {
|
|
|
401
401
|
};
|
|
402
402
|
const LARGE_DOCUMENT_THRESHOLD = 888;
|
|
403
403
|
const CHANGELOG_PAGE_SIZE = 300;
|
|
404
|
+
function generateDocumentUrl(docPath) {
|
|
405
|
+
const pathParts = docPath.split('/');
|
|
406
|
+
let contentIndex = -1;
|
|
407
|
+
for(let i = 0; i < pathParts.length; i++)if ('content' === pathParts[i].toLowerCase()) {
|
|
408
|
+
contentIndex = i;
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
if (-1 === contentIndex || contentIndex + 3 >= pathParts.length) return '';
|
|
412
|
+
const category = pathParts[contentIndex + 1];
|
|
413
|
+
const componentName = pathParts[contentIndex + 2];
|
|
414
|
+
if (!category || !componentName) return '';
|
|
415
|
+
return `https://semi.design/zh-CN/${category}/${componentName}`;
|
|
416
|
+
}
|
|
404
417
|
function parseChangelogPage(componentName) {
|
|
405
418
|
const changelogMatch = componentName.match(/^(changelog)(?:-(\d+))?$/);
|
|
406
419
|
if (changelogMatch) {
|
|
@@ -492,11 +505,13 @@ async function handleGetSemiDocument(args) {
|
|
|
492
505
|
].filter(Boolean).join(',');
|
|
493
506
|
const header = `===== ${doc.name} (第 ${page}/${paginated.totalPages} 页) =====${pageHints ? `\n[提示: ${pageHints}]` : ''}`;
|
|
494
507
|
const footer = `\n\n[当前页: ${page}/${paginated.totalPages} | 总行数: ${doc.content.split('\n').length} | 每页: ${CHANGELOG_PAGE_SIZE} 行]`;
|
|
508
|
+
const url = generateDocumentUrl(doc.path);
|
|
509
|
+
const urlFooter = url ? `\n\n文档链接: ${url}` : '';
|
|
495
510
|
return {
|
|
496
511
|
content: [
|
|
497
512
|
{
|
|
498
513
|
type: 'text',
|
|
499
|
-
text: `${header}\n\n${paginated.content}${footer}`
|
|
514
|
+
text: `${header}\n\n${paginated.content}${footer}${urlFooter}`
|
|
500
515
|
}
|
|
501
516
|
]
|
|
502
517
|
};
|
|
@@ -528,7 +543,9 @@ async function handleGetSemiDocument(args) {
|
|
|
528
543
|
const docContents = processedDocs.map((doc)=>{
|
|
529
544
|
let header = `===== ${doc.name} =====`;
|
|
530
545
|
if (doc.codeBlockCount > 0) header += `\n[注意: 此文档原有 ${doc.originalLines} 行,包含 ${doc.codeBlockCount} 个代码块已被隐藏。使用 get_semi_code_block 工具查看具体代码]`;
|
|
531
|
-
|
|
546
|
+
const url = generateDocumentUrl(doc.path);
|
|
547
|
+
const urlFooter = url ? `\n\n文档链接: ${url}` : '';
|
|
548
|
+
return `${header}\n\n${doc.content}${urlFooter}`;
|
|
532
549
|
}).join('\n\n');
|
|
533
550
|
return {
|
|
534
551
|
content: [
|
|
@@ -539,7 +556,11 @@ async function handleGetSemiDocument(args) {
|
|
|
539
556
|
]
|
|
540
557
|
};
|
|
541
558
|
}
|
|
542
|
-
const docContents = result.documents.map((doc)
|
|
559
|
+
const docContents = result.documents.map((doc)=>{
|
|
560
|
+
const url = generateDocumentUrl(doc.path);
|
|
561
|
+
const urlFooter = url ? `\n\n文档链接: ${url}` : '';
|
|
562
|
+
return `===== ${doc.name} =====\n\n${doc.content}${urlFooter}`;
|
|
563
|
+
}).join('\n\n');
|
|
543
564
|
return {
|
|
544
565
|
content: [
|
|
545
566
|
{
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -382,13 +382,13 @@ function replaceCodeBlocksWithPlaceholders(content, componentName) {
|
|
|
382
382
|
}
|
|
383
383
|
const getSemiDocumentTool = {
|
|
384
384
|
name: 'get_semi_document',
|
|
385
|
-
description: '获取 Semi Design 组件文档、额外文档或组件列表。支持获取:1) 组件文档(如 Button、Input 等组件);2) 额外文档,包括:advanced 分类下的文档(customize-theme、dark-mode、design-source、design-to-code)、ecosystem 分类下的文档(changelog、faq、react19、tailwind、update-to-v2、web-components)、start 分类下的文档(getting-started、introduction、overview)。注意:changelog 文档较大,需要使用分页格式获取,传入 changelog-1(第1页,最新内容)、changelog-2(第2页)等格式,每页300行。对于大型文档,代码块会被替换为占位符,需要使用 get_semi_code_block 工具获取具体代码',
|
|
385
|
+
description: '获取 Semi Design 组件文档、额外文档或组件列表。支持获取:1) 组件文档(如 Button、Input 等组件);2) 额外文档,包括:advanced 分类下的文档(customize-theme、dark-mode、design-source、design-to-code)、ecosystem 分类下的文档(changelog、faq、react19、tailwind、update-to-v2、web-components)、experience 分类下的文档(accessibility、content-guidelines、internationalization)、start 分类下的文档(getting-started、introduction、overview)。注意:changelog 文档较大,需要使用分页格式获取,传入 changelog-1(第1页,最新内容)、changelog-2(第2页)等格式,每页300行。对于大型文档,代码块会被替换为占位符,需要使用 get_semi_code_block 工具获取具体代码',
|
|
386
386
|
inputSchema: {
|
|
387
387
|
type: 'object',
|
|
388
388
|
properties: {
|
|
389
389
|
componentName: {
|
|
390
390
|
type: 'string',
|
|
391
|
-
description: '组件名称或文档名称。组件名称例如:Button、Input、Table 等;额外文档名称例如:customize-theme、dark-mode、changelog-1(changelog第1页,最新)、changelog-2(changelog第2页)等、faq、react19、tailwind、update-to-v2、web-components、getting-started、introduction、overview 等。注意:changelog 必须使用分页格式(changelog-1、changelog-2等),不能直接传入 changelog。如果不提供,则返回组件列表'
|
|
391
|
+
description: '组件名称或文档名称。组件名称例如:Button、Input、Table 等;额外文档名称例如:customize-theme、dark-mode、design-source、design-to-code、changelog-1(changelog第1页,最新)、changelog-2(changelog第2页)等、faq、react19、tailwind、update-to-v2、web-components、accessibility、content-guidelines、internationalization、getting-started、introduction、overview 等。注意:changelog 必须使用分页格式(changelog-1、changelog-2等),不能直接传入 changelog。如果不提供,则返回组件列表'
|
|
392
392
|
},
|
|
393
393
|
version: {
|
|
394
394
|
type: 'string',
|
|
@@ -400,6 +400,19 @@ const getSemiDocumentTool = {
|
|
|
400
400
|
};
|
|
401
401
|
const LARGE_DOCUMENT_THRESHOLD = 888;
|
|
402
402
|
const CHANGELOG_PAGE_SIZE = 300;
|
|
403
|
+
function generateDocumentUrl(docPath) {
|
|
404
|
+
const pathParts = docPath.split('/');
|
|
405
|
+
let contentIndex = -1;
|
|
406
|
+
for(let i = 0; i < pathParts.length; i++)if ('content' === pathParts[i].toLowerCase()) {
|
|
407
|
+
contentIndex = i;
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
if (-1 === contentIndex || contentIndex + 3 >= pathParts.length) return '';
|
|
411
|
+
const category = pathParts[contentIndex + 1];
|
|
412
|
+
const componentName = pathParts[contentIndex + 2];
|
|
413
|
+
if (!category || !componentName) return '';
|
|
414
|
+
return `https://semi.design/zh-CN/${category}/${componentName}`;
|
|
415
|
+
}
|
|
403
416
|
function parseChangelogPage(componentName) {
|
|
404
417
|
const changelogMatch = componentName.match(/^(changelog)(?:-(\d+))?$/);
|
|
405
418
|
if (changelogMatch) {
|
|
@@ -491,11 +504,13 @@ async function handleGetSemiDocument(args) {
|
|
|
491
504
|
].filter(Boolean).join(',');
|
|
492
505
|
const header = `===== ${doc.name} (第 ${page}/${paginated.totalPages} 页) =====${pageHints ? `\n[提示: ${pageHints}]` : ''}`;
|
|
493
506
|
const footer = `\n\n[当前页: ${page}/${paginated.totalPages} | 总行数: ${doc.content.split('\n').length} | 每页: ${CHANGELOG_PAGE_SIZE} 行]`;
|
|
507
|
+
const url = generateDocumentUrl(doc.path);
|
|
508
|
+
const urlFooter = url ? `\n\n文档链接: ${url}` : '';
|
|
494
509
|
return {
|
|
495
510
|
content: [
|
|
496
511
|
{
|
|
497
512
|
type: 'text',
|
|
498
|
-
text: `${header}\n\n${paginated.content}${footer}`
|
|
513
|
+
text: `${header}\n\n${paginated.content}${footer}${urlFooter}`
|
|
499
514
|
}
|
|
500
515
|
]
|
|
501
516
|
};
|
|
@@ -527,7 +542,9 @@ async function handleGetSemiDocument(args) {
|
|
|
527
542
|
const docContents = processedDocs.map((doc)=>{
|
|
528
543
|
let header = `===== ${doc.name} =====`;
|
|
529
544
|
if (doc.codeBlockCount > 0) header += `\n[注意: 此文档原有 ${doc.originalLines} 行,包含 ${doc.codeBlockCount} 个代码块已被隐藏。使用 get_semi_code_block 工具查看具体代码]`;
|
|
530
|
-
|
|
545
|
+
const url = generateDocumentUrl(doc.path);
|
|
546
|
+
const urlFooter = url ? `\n\n文档链接: ${url}` : '';
|
|
547
|
+
return `${header}\n\n${doc.content}${urlFooter}`;
|
|
531
548
|
}).join('\n\n');
|
|
532
549
|
return {
|
|
533
550
|
content: [
|
|
@@ -538,7 +555,11 @@ async function handleGetSemiDocument(args) {
|
|
|
538
555
|
]
|
|
539
556
|
};
|
|
540
557
|
}
|
|
541
|
-
const docContents = result.documents.map((doc)
|
|
558
|
+
const docContents = result.documents.map((doc)=>{
|
|
559
|
+
const url = generateDocumentUrl(doc.path);
|
|
560
|
+
const urlFooter = url ? `\n\n文档链接: ${url}` : '';
|
|
561
|
+
return `===== ${doc.name} =====\n\n${doc.content}${urlFooter}`;
|
|
562
|
+
}).join('\n\n');
|
|
542
563
|
return {
|
|
543
564
|
content: [
|
|
544
565
|
{
|
|
@@ -1424,3 +1445,4 @@ main().catch((error)=>{
|
|
|
1424
1445
|
process.stderr.write(`Semi MCP Server (stdio) 启动失败: ${errorMessage}\n`);
|
|
1425
1446
|
process.exit(1);
|
|
1426
1447
|
});
|
|
1448
|
+
export { createMCPServer, getPackageVersion, toolHandlers, tools };
|
|
@@ -17,6 +17,12 @@ export declare function replaceCodeBlocksWithPlaceholders(content: string, compo
|
|
|
17
17
|
* 工具定义:获取 Semi Design 组件文档
|
|
18
18
|
*/
|
|
19
19
|
export declare const getSemiDocumentTool: Tool;
|
|
20
|
+
/**
|
|
21
|
+
* 从文档路径生成 URL
|
|
22
|
+
* @param docPath - 文档路径,格式:/content/{category}/{componentName}/index.md
|
|
23
|
+
* @returns URL,格式:https://semi.design/zh-CN/{category}/{componentName}
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateDocumentUrl(docPath: string): string;
|
|
20
26
|
/**
|
|
21
27
|
* 工具处理器:处理 get_semi_document 工具调用
|
|
22
28
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "Semi Design MCP Server - Model Context Protocol server for Semi Design components and documentation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,7 +16,16 @@
|
|
|
16
16
|
"./http": {
|
|
17
17
|
"types": "./dist/http.d.ts",
|
|
18
18
|
"import": "./dist/http.js"
|
|
19
|
+
},
|
|
20
|
+
"./tools": {
|
|
21
|
+
"types": "./dist/tools/index.d.ts",
|
|
22
|
+
"import": "./dist/tools/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./utils/*": {
|
|
25
|
+
"types": "./dist/utils/*.d.ts",
|
|
26
|
+
"import": "./dist/utils/*.js"
|
|
19
27
|
}
|
|
28
|
+
|
|
20
29
|
},
|
|
21
30
|
"types": "./dist/index.d.ts",
|
|
22
31
|
"files": [
|