Skip to main content
Glama

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
NameRequiredDescriptionDefault
selectorYesCSS selector for element to click

Implementation Reference

  • 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, }, }; }
  • 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"], }, },
  • 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,
  • 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) );
  • 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" ];

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lebrodus/mcp-playwright'

If you have feedback or need assistance with the MCP directory API, please join our Discord server