type
Enter text at the current cursor position in the browser, with an option to press Enter after typing.
Instructions
Type text at the current focus position
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Text to type | |
| submit | No | Press Enter after typing (default: false) |
Implementation Reference
- src/atlas_browser_mcp/browser.py:444-474 (handler)The main handler implementation for the 'type' tool. It types text at the current focus position with optional submission, validates inputs, and returns an observation result after typing.
def _type(self, text: str = None, submit: bool = False, **_) -> BrowserResult: """Type text at current focus""" if not text: return BrowserResult(success=False, error="text required") if self._page is None: return BrowserResult(success=False, error="No page open") try: self._human_type(text) if submit: if self._humanize: time.sleep(random.uniform(0.1, 0.3)) self._page.keyboard.press("Enter") try: self._page.wait_for_load_state("networkidle", timeout=5000) except: pass self._page.wait_for_timeout(1000) else: self._page.wait_for_timeout(500) return self._observe() except Exception as e: return BrowserResult( success=False, error=f"Type failed: {str(e)}" ) - Helper method that performs humanized typing with randomized delays between characters to simulate natural typing patterns.
def _human_type(self, text: str): """Humanized typing""" if not self._humanize: self._page.keyboard.type(text) return for i, char in enumerate(text): delay = random.uniform(0.05, 0.15) if random.random() < 0.1: delay += random.uniform(0.15, 0.4) if i > 0 and text[i-1] == ' ': delay += random.uniform(0.05, 0.15) self._page.keyboard.type(char) time.sleep(delay) - Tool schema definition for the 'type' tool, defining input parameters (text and optional submit boolean) and their types.
Tool( name="type", description="Type text at the current focus position", inputSchema={ "type": "object", "properties": { "text": { "type": "string", "description": "Text to type" }, "submit": { "type": "boolean", "description": "Press Enter after typing (default: false)", "default": False } }, "required": ["text"] } ), - src/atlas_browser_mcp/server.py:167-173 (registration)Tool registration handler that routes 'type' tool calls to the browser.execute method with appropriate arguments.
elif name == "type": result = await asyncio.to_thread( browser.execute, action="type", text=arguments.get("text"), submit=arguments.get("submit", False) ) - src/atlas_browser_mcp/browser.py:76-84 (registration)Action mapping that registers the 'type' action name to its handler method _type within the execute method.
actions = { "navigate": self._navigate, "observe": self._observe, "click": self._click, "multi_click": self._multi_click, "type": self._type, "scroll": self._scroll, "close": self._close }