click
Automate web element interaction by clicking specified page elements using CSS selectors for browser automation and testing workflows.
Instructions
Click an element on the page
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"selector": "<selector>"
},
"name": "click"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for the element to click |
Implementation Reference
- tools-playwright.js:73-87 (registration)Registration of the 'click' MCP tool, defining its name, description, input schema, and handler function that delegates to browser.click
{ name: 'click', description: 'Click an element on the page', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the element to click' } }, required: ['selector'] }, handler: async ({ selector }) => { await browser.click(selector); return { success: true, message: `Clicked element: ${selector}` }; } }, - tools-playwright.js:76-82 (schema)Input schema for the 'click' tool requiring a CSS selector
inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the element to click' } }, required: ['selector'] }, - tools-playwright.js:83-86 (handler)The handler function for the 'click' tool, which performs the click action via the browser instance and returns a success message
handler: async ({ selector }) => { await browser.click(selector); return { success: true, message: `Clicked element: ${selector}` }; } - browser.js:84-87 (helper)Helper method in SimpleBrowser class that implements the actual click using Playwright's page.click
async click(selector) { await this.ensureLaunched(); await this.page.click(selector); } - index.js:74-76 (registration)Creation of the tools array (including 'click') that is used to register tools with the MCP server request handlers
// Register all available automation tools const tools = createTools(browser);