MCPcopy Create free account
hub / github.com/echoVic/blade-code / generateToolDocs

Method generateToolDocs

src/agent/ToolComponent.ts:322–364  ·  view source on GitHub ↗

* 生成工具文档

()

Source from the content-addressed store, hash-verified

320 * 生成工具文档
321 */
322 public generateToolDocs(): string {
323 const tools = this.getTools();
324 const categories = this.getToolsByCategory();
325
326 let docs = '# 工具文档\n\n';
327 docs += `总计 ${tools.length} 个工具\n\n`;
328
329 for (const [category, categoryTools] of Object.entries(categories)) {
330 docs += `## ${category.toUpperCase()} (${categoryTools.length})\n\n`;
331
332 for (const tool of categoryTools) {
333 docs += `### ${tool.name}\n`;
334 docs += `${tool.description}\n\n`;
335
336 if (tool.version) {
337 docs += `**版本:** ${tool.version}\n`;
338 }
339
340 if (tool.tags && tool.tags.length > 0) {
341 docs += `**标签:** ${tool.tags.join(', ')}\n`;
342 }
343
344 docs += '\n**参数:**\n';
345 docs += '```\n';
346
347 for (const [paramName, paramSchema] of Object.entries(tool.parameters)) {
348 const required = tool.required?.includes(paramName) ? ' (必需)' : '';
349 const defaultValue =
350 paramSchema.default !== undefined ? ` (默认: ${paramSchema.default})` : '';
351
352 docs += `${paramName}: ${paramSchema.type}${required}${defaultValue}\n`;
353 if (paramSchema.description) {
354 docs += ` ${paramSchema.description}\n`;
355 }
356 }
357
358 docs += '```\n\n';
359 docs += '---\n\n';
360 }
361 }
362
363 return docs;
364 }
365
366 /**
367 * 记录日志

Callers

nothing calls this directly

Calls 2

getToolsMethod · 0.95
getToolsByCategoryMethod · 0.95

Tested by

no test coverage detected