playwright_click
Simulate user interaction by clicking elements on web pages using CSS selectors, enabling automated browser actions through the Playwright MCP Server.
Instructions
Click an element on the page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for element to click |
Implementation Reference
- src/toolsHandler.ts:175-197 (handler)Handler function for playwright_click tool that performs a click on the specified selector using Playwright's page.click method and returns success or error message.case "playwright_click": try { await page!.click(args.selector); return { toolResult: { content: [{ type: "text", text: `Clicked: ${args.selector}`, }], isError: false, }, }; } catch (error) { return { toolResult: { content: [{ type: "text", text: `Failed to click ${args.selector}: ${(error as Error).message}`, }], isError: true, }, }; }
- src/tools.ts:33-43 (schema)Tool definition for playwright_click including name, description, and input schema requiring a 'selector' property.{ name: "playwright_click", description: "Click an element on the page", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for element to click" }, }, required: ["selector"], }, },
- src/requestHandler.ts:59-61 (registration)Registration of the list tools handler that exposes the tool definitions, including playwright_click, to the MCP client.// List tools handler server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools,
- src/requestHandler.ts:64-67 (registration)Registration of the call tool handler that routes tool calls, including playwright_click, to the handleToolCall function.// Call tool handler server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name, request.params.arguments ?? {}, server) );
- src/tools.ts:153-160 (helper)Helper array listing browser-requiring tools, including playwright_click, used to conditionally launch the browser."playwright_navigate", "playwright_screenshot", "playwright_click", "playwright_fill", "playwright_select", "playwright_hover", "playwright_evaluate" ];