MCPcopy Create free account
hub / github.com/ChromeDevTools/chrome-devtools-mcp / getToolStatusInfo

Function getToolStatusInfo

src/ToolHandler.ts:73–117  ·  view source on GitHub ↗
(
  tool: ToolDefinition | DefinedPageTool,
  serverArgs: ReturnType<typeof parseArguments>,
)

Source from the content-addressed store, hash-verified

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

Callers 1

constructorMethod · 0.85

Calls 3

getCategoryStatusFunction · 0.85
buildDisabledMessageFunction · 0.85
getConditionStatusFunction · 0.85

Tested by

no test coverage detected