(tools: any)
| 433 | |
| 434 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 435 | function getToolsAndCategories(tools: any) { |
| 436 | // Convert ToolDefinitions to ToolWithAnnotations |
| 437 | const toolsWithAnnotations: ToolWithAnnotations[] = tools |
| 438 | .filter(tool => { |
| 439 | // Skipping in_page tools as they are not launched yet |
| 440 | if (tool.annotations.category === ToolCategory.IN_PAGE) { |
| 441 | return false; |
| 442 | } |
| 443 | |
| 444 | // Skipping internal interop tools not meant for public documentation |
| 445 | const skipTools = ['get_tab_id']; |
| 446 | if (skipTools.includes(tool.name)) { |
| 447 | return false; |
| 448 | } |
| 449 | |
| 450 | return true; |
| 451 | }) |
| 452 | .map(tool => { |
| 453 | const properties: Record<string, TypeInfo> = {}; |
| 454 | const required: string[] = []; |
| 455 | |
| 456 | for (const [key, schema] of Object.entries( |
| 457 | tool.schema as unknown as Record<string, ZodSchema>, |
| 458 | )) { |
| 459 | const info = getZodTypeInfo(schema); |
| 460 | properties[key] = info; |
| 461 | if (isRequired(schema)) { |
| 462 | required.push(key); |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | return { |
| 467 | name: tool.name, |
| 468 | description: tool.description, |
| 469 | inputSchema: { |
| 470 | type: 'object', |
| 471 | properties, |
| 472 | required, |
| 473 | }, |
| 474 | annotations: tool.annotations, |
| 475 | }; |
| 476 | }); |
| 477 | // Group tools by category (based on annotations) |
| 478 | const categories: Record<string, ToolWithAnnotations[]> = {}; |
| 479 | toolsWithAnnotations.forEach((tool: ToolWithAnnotations) => { |
| 480 | const category = tool.annotations?.category || 'Uncategorized'; |
| 481 | if (!categories[category]) { |
| 482 | categories[category] = []; |
| 483 | } |
| 484 | categories[category].push(tool); |
| 485 | }); |
| 486 | |
| 487 | // Sort categories using the enum order |
| 488 | const categoryOrder = Object.values(ToolCategory); |
| 489 | const sortedCategories = Object.keys(categories).sort((a, b) => { |
| 490 | const aOff = OFF_BY_DEFAULT_CATEGORIES.includes(a as ToolCategory); |
| 491 | const bOff = OFF_BY_DEFAULT_CATEGORIES.includes(b as ToolCategory); |
| 492 |
no test coverage detected