Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

getForms

Extract all form elements from a webpage to analyze structure, collect data, or automate interactions during browser automation tasks.

Instructions

Get all forms from the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function getForms() in PlaywrightController class that uses page.evaluate to extract all forms, their action/method, and input fields from the current page.
    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');
      }
    }
  • The Tool schema definition for 'getForms', specifying no input parameters.
    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 tools dictionary passed to MCP server capabilities.
    getForms: GET_FORMS_TOOL,
  • src/server.ts:740-745 (registration)
    Dispatch handler in callTool request handler that invokes the getForms method and returns the JSON stringified result.
    case 'getForms': {
      const forms = await playwrightController.getForms();
      return {
        content: [{ type: "text", text: JSON.stringify(forms, null, 2) }]
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but only states what the tool does without detailing how it behaves. It lacks information on output format (e.g., structured data vs. raw text), error handling, dependencies (e.g., requires a page to be loaded), or performance considerations (e.g., speed, limitations).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that efficiently conveys the core purpose without unnecessary words. It is front-loaded and wastes no space, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is minimal but incomplete. It doesn't explain what 'forms' means in this context (e.g., HTML form elements, their attributes, or extracted data), the return value, or any behavioral nuances, leaving gaps for an AI agent to infer usage correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description doesn't add parameter details, which is appropriate here, but it could have optionally clarified implicit context (e.g., 'current page' as an implied parameter). Since the schema fully covers the absence of parameters, a baseline of 4 is justified.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and target resource ('all forms from the current page'), making the purpose immediately understandable. However, it doesn't explicitly distinguish this tool from potential sibling tools like 'getElementContent' or 'getPageText', which might also retrieve page content in different formats.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal guidance, implying usage when forms on a page are needed, but offers no explicit when-to-use rules, alternatives, or exclusions. For example, it doesn't clarify if this should be used instead of 'getElementContent' for form-specific data or how it relates to other page content tools in the sibling list.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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