@douyinfe/semi-mcp 1.0.5 → 1.0.6
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/index.js +39 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { CallToolRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
import { readFileSync } from "fs";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
import { dirname, join } from "path";
|
|
5
8
|
import { mkdir, writeFile } from "fs/promises";
|
|
6
|
-
import { join } from "path";
|
|
7
9
|
import { tmpdir } from "os";
|
|
8
10
|
const UNPKG_BASE_URL = 'https://unpkg.com';
|
|
9
11
|
const NPMMIRROR_BASE_URL = 'https://registry.npmmirror.com';
|
|
@@ -367,10 +369,45 @@ const tools = [
|
|
|
367
369
|
const toolHandlers = {
|
|
368
370
|
[getSemiDocumentTool.name]: handleGetSemiDocument
|
|
369
371
|
};
|
|
372
|
+
const src_filename = fileURLToPath(import.meta.url);
|
|
373
|
+
const src_dirname = dirname(src_filename);
|
|
374
|
+
let packageJson;
|
|
375
|
+
try {
|
|
376
|
+
const packageJsonPath = join(src_dirname, '../package.json');
|
|
377
|
+
packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
378
|
+
} catch {
|
|
379
|
+
try {
|
|
380
|
+
const packageJsonPath = join(src_dirname, '../../package.json');
|
|
381
|
+
packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
382
|
+
} catch {
|
|
383
|
+
packageJson = {
|
|
384
|
+
version: '1.0.0'
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
}
|
|
370
388
|
async function main() {
|
|
371
389
|
const server = new Server({
|
|
372
390
|
name: 'semi-mcp',
|
|
373
|
-
version:
|
|
391
|
+
version: packageJson.version,
|
|
392
|
+
title: 'Semi Design MCP',
|
|
393
|
+
description: 'Semi Design 组件文档和组件列表查询工具',
|
|
394
|
+
websiteUrl: 'https://semi.design',
|
|
395
|
+
icons: [
|
|
396
|
+
{
|
|
397
|
+
src: 'https://semi.design/favicon.ico',
|
|
398
|
+
mimeType: 'image/x-icon',
|
|
399
|
+
sizes: [
|
|
400
|
+
'32x32'
|
|
401
|
+
]
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
src: 'https://unpkg.com/@douyinfe/semi-icons@latest/src/svgs/semi_logo.svg',
|
|
405
|
+
mimeType: 'image/svg+xml',
|
|
406
|
+
sizes: [
|
|
407
|
+
'any'
|
|
408
|
+
]
|
|
409
|
+
}
|
|
410
|
+
]
|
|
374
411
|
}, {
|
|
375
412
|
capabilities: {
|
|
376
413
|
tools: {},
|
package/package.json
CHANGED