* @param {any} tool * @returns {string[]}
(tool)
| 67 | * @returns {string[]} |
| 68 | */ |
| 69 | function formatToolForReadme(tool) { |
| 70 | const lines = /** @type {string[]} */ ([]); |
| 71 | lines.push(`<!-- NOTE: This has been generated via ${path.basename(__filename)} -->`); |
| 72 | lines.push(``); |
| 73 | lines.push(`- **${tool.name}**`); |
| 74 | lines.push(` - Title: ${tool.title}`); |
| 75 | lines.push(` - Description: ${tool.description}`); |
| 76 | |
| 77 | const inputSchema = /** @type {any} */ (tool.inputSchema ? tool.inputSchema.toJSONSchema() : {}); |
| 78 | const requiredParams = inputSchema.required || []; |
| 79 | if (inputSchema.properties && Object.keys(inputSchema.properties).length) { |
| 80 | lines.push(` - Parameters:`); |
| 81 | Object.entries(inputSchema.properties).forEach(([name, param]) => { |
| 82 | const optional = !requiredParams.includes(name); |
| 83 | const meta = /** @type {string[]} */ ([]); |
| 84 | if (param.type) |
| 85 | meta.push(param.type); |
| 86 | if (optional) |
| 87 | meta.push('optional'); |
| 88 | lines.push(` - \`${name}\` ${meta.length ? `(${meta.join(', ')})` : ''}: ${param.description}`); |
| 89 | }); |
| 90 | } else { |
| 91 | lines.push(` - Parameters: None`); |
| 92 | } |
| 93 | lines.push(` - Read-only: **${tool.type === 'readOnly'}**`); |
| 94 | lines.push(''); |
| 95 | return lines; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * @param {string} content |