Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

getForms

Extract all forms from a webpage using PlayMCP Browser Automation Server, enabling efficient data collection and web automation for scraping or testing tasks.

Instructions

Get all forms from the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function in PlaywrightController that extracts all forms from the current page, including action, method, and field details using browser evaluation.
    async getForms(): Promise<Array<{action?: string, method?: string, fields: Array<{name?: string, type?: string, value?: string}>}>> { try { if (!this.isInitialized()) { throw new Error('Browser not initialized'); } this.log('Getting page forms'); const forms = await this.state.page?.evaluate(() => { const formElements = Array.from(document.querySelectorAll('form')); return formElements.map(form => ({ action: form.getAttribute('action') || undefined, method: form.getAttribute('method') || undefined, fields: Array.from(form.querySelectorAll('input, select, textarea')).map(field => ({ name: field.getAttribute('name') || undefined, type: field.getAttribute('type') || field.tagName.toLowerCase(), value: (field as HTMLInputElement).value || undefined })) })); }); this.log('Forms retrieved:', forms?.length); return forms || []; } catch (error: any) { console.error('Get forms error:', error); throw new BrowserError('Failed to get forms', 'Check if the page is loaded'); } }
  • Tool schema definition specifying the name, description, and empty input schema (no parameters required) for the getForms tool.
    const GET_FORMS_TOOL: Tool = { name: "getForms", description: "Get all forms from the current page", inputSchema: { type: "object", properties: {}, required: [] } };
  • src/server.ts:531-531 (registration)
    Registration of the getForms tool in the central tools object provided to the MCP server's capabilities.
    getForms: GET_FORMS_TOOL,
  • MCP tool call dispatcher that invokes the getForms handler from the controller and formats the response as JSON.
    case 'getForms': { const forms = await playwrightController.getForms(); return { content: [{ type: "text", text: JSON.stringify(forms, null, 2) }] }; }

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