Skip to main content
Glama
random-robbie

MCP Web Browser Server

input_text

Enter text into web page elements using CSS selectors for automated form filling or content input in browser automation workflows.

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

TableJSON Schema
NameRequiredDescriptionDefault
selectorYes
textYes
contextNo

Implementation Reference

  • The `input_text` tool handler: inputs text into a form element on the current page using Playwright's `fill` method. Requires a prior `browse_to` call to load a page. Registered via `@mcp.tool()` decorator.
    @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}")

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