Skip to main content
Glama

type

Input text into specified elements on a webpage using a selector for browser automation tasks with Playwright MCP.

Instructions

Type text into an input element

Input Schema

NameRequiredDescriptionDefault
page_idNo
selectorYes
textYes

Input Schema (JSON Schema)

{ "properties": { "page_id": { "type": "string" }, "selector": { "type": "string" }, "text": { "type": "string" } }, "required": [ "selector", "text" ], "type": "object" }

Implementation Reference

  • The core handler logic for the 'type' tool. It retrieves the selector and text from arguments, validates them, gets the active page, and uses Playwright's page.fill() to type the text into the element.
    elif name == "type": selector = arguments.get("selector") text = arguments.get("text") if not selector or text is None: raise ValueError("Selector and text are required") page = get_active_page(arguments.get("page_id")) await page.fill(selector, text) return [types.TextContent(type="text", text=f"Typed '{text}' into {selector}")]
  • Registration of the 'type' tool in the handle_list_tools() function, including its name, description, and input schema.
    types.Tool( name="type", description="Type text into an input element", inputSchema={ "type": "object", "properties": { "selector": {"type": "string"}, "text": {"type": "string"}, "page_id": {"type": "string"}, }, "required": ["selector", "text"], }, ),
  • Input schema definition for the 'type' tool, specifying the required selector and text parameters, and optional page_id.
    inputSchema={ "type": "object", "properties": { "selector": {"type": "string"}, "text": {"type": "string"}, "page_id": {"type": "string"}, }, "required": ["selector", "text"], },
  • Helper function used by the 'type' handler (and others) to retrieve the Playwright Page instance based on the provided page_id or the current default.
    def get_active_page(page_id: Optional[str] = None) -> Page: """Get the active page based on page_id or current default.""" global current_page_id if page_id is None: page_id = current_page_id if page_id not in pages: raise ValueError(f"Page not found: {page_id}") return pages[page_id]

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/misanthropic-ai/playwrite-mcp'

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