Skip to main content
Glama

input_text

Input text into a specified webpage element using a CSS selector. Designed for the MCP Web Browser Server to enable precise element interaction in headless browsing scenarios.

Instructions

Input text into a specific element on the page. Args: selector: CSS selector for the input element text: Text to input context: Optional context object for logging (ignored) Returns: Confirmation message

Input Schema

NameRequiredDescriptionDefault
contextNo
selectorYes
textYes

Input Schema (JSON Schema)

{ "properties": { "context": { "anyOf": [ {}, { "type": "null" } ], "default": null, "title": "Context" }, "selector": { "title": "Selector", "type": "string" }, "text": { "title": "Text", "type": "string" } }, "required": [ "selector", "text" ], "title": "input_textArguments", "type": "object" }

Implementation Reference

  • The handler function for the 'input_text' tool. It locates an element by CSS selector on the current page and fills it with the provided text using Playwright's fill method.
    @mcp.tool() async def input_text( selector: str, text: str, context: Optional[Any] = None ) -> str: """ Input text into a specific element on the page. Args: selector: CSS selector for the input element text: Text to input context: Optional context object for logging (ignored) Returns: Confirmation message """ global _current_page if not _current_page: raise ValueError("No page is currently loaded. Use browse_to first.") try: element = await _current_page.query_selector(selector) if not element: raise ValueError(f"No element found with selector: {selector}") await element.fill(text) print(f"Input text into element: {selector}", file=sys.stderr) return f"Successfully input text into element: {selector}" except Exception as e: print(f"Error inputting text: {e}", file=sys.stderr) raise ValueError(f"Error inputting text: {e}")

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/random-robbie/mcp-web-browser'

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