( tool: ToolDefinition | DefinedPageTool, serverArgs: ReturnType<typeof parseArguments>, )
| 72 | } |
| 73 | |
| 74 | function getToolStatusInfo( |
| 75 | tool: ToolDefinition | DefinedPageTool, |
| 76 | serverArgs: ReturnType<typeof parseArguments>, |
| 77 | ): {disabled: boolean; reason?: string} { |
| 78 | const category = tool.annotations.category; |
| 79 | const categoryCheck = getCategoryStatus(category, serverArgs); |
| 80 | |
| 81 | if (category && categoryCheck.disabled) { |
| 82 | if (!categoryCheck.categoryFlag) { |
| 83 | throw new Error( |
| 84 | 'when the category is disabled there should always be a flag set', |
| 85 | ); |
| 86 | } |
| 87 | |
| 88 | return { |
| 89 | disabled: true, |
| 90 | reason: buildDisabledMessage( |
| 91 | tool.name, |
| 92 | `--${categoryCheck.categoryFlag}`, |
| 93 | labels[category!], |
| 94 | ), |
| 95 | }; |
| 96 | } |
| 97 | |
| 98 | for (const condition of tool.annotations.conditions || []) { |
| 99 | const conditionCheck = getConditionStatus(condition, serverArgs); |
| 100 | if (conditionCheck.disabled) { |
| 101 | if (!conditionCheck.conditionFlag) { |
| 102 | throw new Error( |
| 103 | 'when the condition is disabled there should always be a flag set', |
| 104 | ); |
| 105 | } |
| 106 | |
| 107 | return { |
| 108 | disabled: true, |
| 109 | reason: buildDisabledMessage( |
| 110 | tool.name, |
| 111 | `--${conditionCheck.conditionFlag}`, |
| 112 | ), |
| 113 | }; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | return {disabled: false}; |
| 118 | } |
| 119 | |
| 120 | function isPageScopedTool( |
| 121 | tool: ToolDefinition | DefinedPageTool, |
no test coverage detected