Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

click

Automate web interactions by clicking specific elements on a webpage using a selector. Part of the PlayMCP Browser Automation Server, designed for web scraping and testing tasks.

Instructions

Click an element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYes

Implementation Reference

  • Core implementation of the click functionality: clicks an element by CSS selector using page.click() or at current mouse position if no selector provided.
    async click(selector?: string): Promise<void> { try { if (!this.isInitialized() || !this.state.page) { throw new Error('Browser not initialized'); } if (selector) { this.log('Clicking element', selector); await this.state.page.click(selector); } else { this.log('Clicking at position', this.currentMousePosition); await this.state.page.mouse.click(this.currentMousePosition.x, this.currentMousePosition.y); } this.log('Click complete'); } catch (error: any) { console.error('Click error:', error); throw new BrowserError( 'Failed to click', selector ? 'Check if the element exists and is visible' : 'Check if mouse position is valid' ); }
  • MCP server request handler dispatch for 'click' tool: validates selector input and delegates execution to PlaywrightController.click().
    case 'click': { if (!args.selector) { return { content: [{ type: "text", text: "Selector is required" }], isError: true }; } await playwrightController.click(args.selector as string); return { content: [{ type: "text", text: "Click successful" }] }; }
  • Tool schema definition specifying name, description, and input schema requiring a 'selector' string parameter.
    const CLICK_TOOL: Tool = { name: "click", description: "Click an element", inputSchema: { type: "object", properties: { selector: { type: "string" } }, required: ["selector"] }
  • src/server.ts:514-552 (registration)
    Registration of the 'click' tool in the MCP server's tools capabilities object, referenced by CLICK_TOOL.
    const tools = { openBrowser: OPEN_BROWSER_TOOL, navigate: NAVIGATE_TOOL, type: TYPE_TOOL, click: CLICK_TOOL, moveMouse: MOVE_MOUSE_TOOL, scroll: SCROLL_TOOL, screenshot: SCREENSHOT_TOOL, getPageSource: GET_PAGE_SOURCE_TOOL, getPageText: GET_PAGE_TEXT_TOOL, getPageTitle: GET_PAGE_TITLE_TOOL, getPageUrl: GET_PAGE_URL_TOOL, getScripts: GET_SCRIPTS_TOOL, getStylesheets: GET_STYLESHEETS_TOOL, getMetaTags: GET_META_TAGS_TOOL, getLinks: GET_LINKS_TOOL, getImages: GET_IMAGES_TOOL, getForms: GET_FORMS_TOOL, getElementContent: GET_ELEMENT_CONTENT_TOOL, getElementHierarchy: GET_ELEMENT_HIERARCHY_TOOL, executeJavaScript: EXECUTE_JAVASCRIPT_TOOL, goForward: GO_FORWARD_TOOL, hover: HOVER_TOOL, dragAndDrop: DRAG_AND_DROP_TOOL, selectOption: SELECT_OPTION_TOOL, pressKey: PRESS_KEY_TOOL, waitForText: WAIT_FOR_TEXT_TOOL, waitForSelector: WAIT_FOR_SELECTOR_TOOL, resize: RESIZE_TOOL, handleDialog: HANDLE_DIALOG_TOOL, getConsoleMessages: GET_CONSOLE_MESSAGES_TOOL, getNetworkRequests: GET_NETWORK_REQUESTS_TOOL, uploadFiles: UPLOAD_FILES_TOOL, evaluateWithReturn: EVALUATE_WITH_RETURN_TOOL, takeScreenshot: TAKE_SCREENSHOT_TOOL, mouseMove: MOUSE_MOVE_TOOL, mouseClick: MOUSE_CLICK_TOOL, mouseDrag: MOUSE_DRAG_TOOL, closeBrowser: CLOSE_BROWSER_TOOL

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/jomon003/PlayMCP'

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