* Generates a markdown summary of mcp-scripts logs * @param {Array } logEntries - Parsed log entries * @returns {string} Markdown summary
(logEntries)
| 289 | * @returns {string} Markdown summary |
| 290 | */ |
| 291 | function generateMCPScriptsSummary(logEntries) { |
| 292 | const summary = []; |
| 293 | |
| 294 | // Count events by type |
| 295 | const eventCounts = { |
| 296 | startup: 0, |
| 297 | toolRegistration: 0, |
| 298 | toolExecution: 0, |
| 299 | errors: 0, |
| 300 | other: 0, |
| 301 | }; |
| 302 | |
| 303 | const errors = []; |
| 304 | const toolCalls = []; |
| 305 | |
| 306 | for (const entry of logEntries) { |
| 307 | const msg = entry.message.toLowerCase(); |
| 308 | |
| 309 | // Categorize log entries |
| 310 | if (msg.includes("starting mcp-scripts") || msg.includes("server started")) { |
| 311 | eventCounts.startup++; |
| 312 | } else if (msg.includes("registering tool") || msg.includes("tool registration")) { |
| 313 | eventCounts.toolRegistration++; |
| 314 | } else if (msg.includes("calling handler") || msg.includes("handler returned")) { |
| 315 | eventCounts.toolExecution++; |
| 316 | if (msg.includes("calling handler")) { |
| 317 | // Extract tool name from message like "Calling handler for tool: my-tool" |
| 318 | const toolMatch = entry.message.match(/tool:\s*(\S+)/i); |
| 319 | if (toolMatch) { |
| 320 | toolCalls.push({ |
| 321 | tool: toolMatch[1], |
| 322 | timestamp: entry.timestamp, |
| 323 | }); |
| 324 | } |
| 325 | } |
| 326 | } else if (msg.includes("error") || msg.includes("failed")) { |
| 327 | eventCounts.errors++; |
| 328 | errors.push(entry); |
| 329 | } else { |
| 330 | eventCounts.other++; |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | // Wrap entire section in a details tag |
| 335 | summary.push("<details>"); |
| 336 | summary.push("<summary>MCP Scripts Server Logs</summary>\n"); |
| 337 | |
| 338 | // Statistics |
| 339 | summary.push("**Statistics**\n"); |
| 340 | summary.push("| Metric | Count |"); |
| 341 | summary.push("|--------|-------|"); |
| 342 | summary.push(`| Total Log Entries | ${logEntries.length} |`); |
| 343 | summary.push(`| Startup Events | ${eventCounts.startup} |`); |
| 344 | summary.push(`| Tool Registrations | ${eventCounts.toolRegistration} |`); |
| 345 | summary.push(`| Tool Executions | ${eventCounts.toolExecution} |`); |
| 346 | summary.push(`| Errors | ${eventCounts.errors} |`); |
| 347 | summary.push(`| Other Events | ${eventCounts.other} |`); |
| 348 | summary.push(""); |
no outgoing calls
no test coverage detected