-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathexport-tools.mjs
More file actions
46 lines (38 loc) · 1.16 KB
/
export-tools.mjs
File metadata and controls
46 lines (38 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env node
/**
* 导出所有 MCP Tools 为 JSON 文件
* 用法: node export-tools.mjs [输出文件路径]
*/
import { defaultToolsetManager } from './dist/common/toolsetManager.js';
import { writeFileSync } from 'fs';
import { resolve } from 'path';
// 获取所有 tools
const tools = defaultToolsetManager.getAllTools();
// 构建输出数据
const output = {
total: tools.length,
generatedAt: new Date().toISOString(),
tools: tools.map(tool => ({
name: tool.name,
description: tool.description,
inputSchema: tool.inputSchema
}))
};
// 确定输出路径
const outputPath = process.argv[2] || 'tools.json';
const fullPath = resolve(outputPath);
// 写入文件
writeFileSync(fullPath, JSON.stringify(output, null, 2), 'utf-8');
console.log(`✅ 成功导出 ${tools.length} 个 tools 到: ${fullPath}`);
console.log(`\n工具分类统计:`);
// 按前缀分组统计
const groups = {};
tools.forEach(tool => {
const prefix = tool.name.split('_')[0];
groups[prefix] = (groups[prefix] || 0) + 1;
});
Object.entries(groups)
.sort((a, b) => b[1] - a[1])
.forEach(([prefix, count]) => {
console.log(` ${prefix}: ${count} 个`);
});