@ppdocs/mcp 2.8.1 → 2.8.3

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.
@@ -55,7 +55,7 @@ export function formatTreeText(tree) {
55
55
  const connector = isLast ? '└── ' : '├── ';
56
56
  const childPrefix = isLast ? ' ' : '│ ';
57
57
  const icon = node.isDir ? '📁' : '📄';
58
- const summary = node.summary ? ` - ${node.summary}` : '';
58
+ const summary = node.summary ? `(${node.summary})` : '';
59
59
  lines.push(`${prefix}${connector}${icon} ${node.name}${summary}`);
60
60
  if (node.children && node.children.length > 0) {
61
61
  lines.push(...format(node.children, prefix + childPrefix));
@@ -23,8 +23,8 @@ export function registerTools(server, projectId, _user) {
23
23
  });
24
24
  return wrap(`✅ 文档已创建: ${decoded.path}\n\n${JSON.stringify(doc, null, 2)}`);
25
25
  });
26
- // 2. 删除文档 (支持批量)
27
- server.tool('kg_delete_node', '删除文档(支持批量,根文档不可删除)', { nodeId: z.union([z.string(), z.array(z.string())]).describe('文档路径或路径数组') }, async (args) => {
26
+ // 2. 删除文档或目录 (支持批量)
27
+ server.tool('kg_delete_node', '删除文档或目录(支持批量,根不可删除,目录会递归删除)', { nodeId: z.union([z.string(), z.array(z.string())]).describe('文档路径或路径数组') }, async (args) => {
28
28
  const paths = Array.isArray(args.nodeId) ? args.nodeId : [args.nodeId];
29
29
  const results = [];
30
30
  for (const path of paths) {
@@ -42,24 +42,21 @@ export function registerTools(server, projectId, _user) {
42
42
  }
43
43
  return wrap(msg);
44
44
  });
45
- // 3. 更新文档 (支持批量)
46
- server.tool('kg_update_node', '更新文档内容(支持批量)', {
47
- nodeId: z.union([
48
- z.string(),
49
- z.array(z.string())
50
- ]).describe('文档路径或路径数组'),
51
- summary: z.string().optional().describe('一句话简介'),
52
- content: z.string().optional().describe('Markdown内容'),
45
+ // 3. 更新文档 (支持单个/批量两种模式)
46
+ server.tool('kg_update_node', '更新文档内容。【单个模式】nodeId+字段;【批量模式】仅传updates数组。两种模式二选一', {
47
+ nodeId: z.string().optional().describe('【单个模式】文档路径,如"/前端/组件/Button"'),
48
+ summary: z.string().optional().describe('【单个模式】一句话简介'),
49
+ content: z.string().optional().describe('【单个模式】Markdown内容'),
53
50
  versions: z.array(z.object({
54
51
  version: z.number(),
55
52
  date: z.string(),
56
53
  changes: z.string()
57
- })).optional().describe('版本记录'),
54
+ })).optional().describe('【单个模式】版本记录数组'),
58
55
  bugfixes: z.array(z.object({
59
56
  date: z.string(),
60
57
  issue: z.string(),
61
58
  solution: z.string()
62
- })).optional().describe('修复记录'),
59
+ })).optional().describe('【单个模式】修复记录数组'),
63
60
  updates: z.array(z.object({
64
61
  nodeId: z.string().describe('文档路径'),
65
62
  summary: z.string().optional(),
@@ -74,7 +71,7 @@ export function registerTools(server, projectId, _user) {
74
71
  issue: z.string(),
75
72
  solution: z.string()
76
73
  })).optional()
77
- })).optional().describe('批量更新数组(每项独立配置)')
74
+ })).optional().describe('【批量模式】更新数组,每项包含nodeId和要更新的字段')
78
75
  }, async (args) => {
79
76
  const decoded = decodeObjectStrings(args);
80
77
  // 批量更新模式: 使用 updates 数组
@@ -110,15 +107,17 @@ export function registerTools(server, projectId, _user) {
110
107
  }
111
108
  return wrap(msg);
112
109
  }
113
- // 单个更新模式
110
+ // 单个更新模式: 必须提供 nodeId
114
111
  const { nodeId, summary, content, versions, bugfixes } = decoded;
115
- const singleNodeId = Array.isArray(nodeId) ? nodeId[0] : nodeId;
112
+ if (!nodeId) {
113
+ return wrap('❌ 请提供 nodeId(单个模式)或 updates 数组(批量模式)');
114
+ }
116
115
  // 根文档必须使用 kg_update_root 更新
117
- if (singleNodeId === '/' || singleNodeId === '_root') {
116
+ if (nodeId === '/' || nodeId === '_root') {
118
117
  return wrap('❌ 根文档请使用 kg_update_root 方法更新');
119
118
  }
120
119
  // 获取现有文档
121
- const existing = await storage.getDoc(projectId, singleNodeId);
120
+ const existing = await storage.getDoc(projectId, nodeId);
122
121
  if (!existing) {
123
122
  return wrap('更新失败(文档不存在)');
124
123
  }
@@ -132,7 +131,7 @@ export function registerTools(server, projectId, _user) {
132
131
  updates.versions = versions;
133
132
  if (bugfixes !== undefined)
134
133
  updates.bugfixes = bugfixes;
135
- const doc = await storage.updateDoc(projectId, singleNodeId, updates);
134
+ const doc = await storage.updateDoc(projectId, nodeId, updates);
136
135
  return wrap(doc ? JSON.stringify(doc, null, 2) : '更新失败');
137
136
  });
138
137
  // 3.5 更新根文档 (项目介绍)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ppdocs/mcp",
3
- "version": "2.8.1",
3
+ "version": "2.8.3",
4
4
  "description": "ppdocs MCP Server - Knowledge Graph for Claude",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",