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

Method handle

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

Source from the content-addressed store, hash-verified

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

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
acquireMethod · 0.80
setReconnectNoticeMethod · 0.80
validatePathMethod · 0.80
getPageByIdMethod · 0.80
getSelectedMcpPageMethod · 0.80
setPageMethod · 0.80

Tested by 3

testIncludesWebmcpToolsFunction · 0.36