MCPcopy
hub / github.com/ChromeDevTools/chrome-devtools-mcp / handle

Method handle

src/ToolHandler.ts:177–305  ·  view source on GitHub ↗
(params: Record<string, unknown>)

Source from the content-addressed store, hash-verified

175 }
176
177 async handle(params: Record<string, unknown>): Promise<CallToolResult> {
178 if (this.disabledReason) {
179 return {
180 content: [
181 {
182 type: 'text',
183 text: this.disabledReason,
184 },
185 ],
186 isError: true,
187 };
188 }
189
190 const unknownArgumentNames = this.unknownArgumentNames(params);
191 if (unknownArgumentNames.length) {
192 return {
193 content: [
194 {
195 type: 'text',
196 text: buildUnknownArgumentsMessage(
197 this.tool.name,
198 unknownArgumentNames,
199 Object.keys(this.inputSchema),
200 ),
201 },
202 ],
203 isError: true,
204 };
205 }
206
207 const guard = await this.toolMutex.acquire();
208 const startTime = Date.now();
209 let success = false;
210 try {
211 logger?.(
212 `${this.tool.name} request: ${JSON.stringify(params, null, ' ')}`,
213 );
214 const context = await this.getContext();
215 logger?.(`${this.tool.name} context: resolved`);
216 await context.detectOpenDevToolsWindows();
217 const response = this.serverArgs.slim
218 ? new SlimMcpResponse(this.serverArgs)
219 : new McpResponse(this.serverArgs);
220
221 response.setRedactNetworkHeaders(this.serverArgs.redactNetworkHeaders);
222 try {
223 if (this.tool.verifyFilesSchema) {
224 for (const key of this.tool.verifyFilesSchema) {
225 const filePath = params[key];
226 await context.validatePath(filePath as string);
227 }
228 }
229 if (isPageScopedTool(this.tool)) {
230 const pageId =
231 typeof params.pageId === 'number' ? params.pageId : undefined;
232 const page =
233 this.serverArgs.experimentalPageIdRouting &&
234 pageId !== undefined &&

Callers 15

registerToolFunction · 0.95
testIncludesWebmcpToolsFunction · 0.45
McpContext.test.tsFile · 0.45
input.test.tsFile · 0.45
network.test.tsFile · 0.45
memory.test.tsFile · 0.45

Calls 15

unknownArgumentNamesMethod · 0.95
isPageScopedToolFunction · 0.85
bucketizeLatencyFunction · 0.85
keysMethod · 0.80
validatePathMethod · 0.80
getPageByIdMethod · 0.80
getSelectedMcpPageMethod · 0.80
setPageMethod · 0.80
throwIfDialogOpenMethod · 0.80

Tested by 3

testIncludesWebmcpToolsFunction · 0.36