Skip to main content
Glama
Lokii0911
by Lokii0911

type_text

Type text into a specified web element by providing a locator strategy, value, and text. Optionally clear the element first. Uses Selenium to automate input for browser testing.

Instructions

Type text into an element, optionally clearing it first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
strategyYes
valueYes
textYes
clear_firstNo
timeout_secondsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler logic: locates an element via strategy/value, optionally clears it, types the text via send_keys, and returns a summary of the element.
    def type_text(
        self,
        strategy: LocatorStrategy,
        value: str,
        text: str,
        clear_first: bool = True,
        timeout_seconds: float | None = None,
    ) -> ElementSummary:
        with self._lock:
            element = self._wait_for_element(strategy, value, timeout_seconds)
            if clear_first:
                element.clear()
            element.send_keys(text)
            return self._summarize_element(element)
  • Registers the tool via @mcp.tool() decorator, defines the public signature, docstring, and delegates to BrowserManager.type_text via the _run helper.
    @mcp.tool()
    def type_text(
        strategy: LocatorStrategy,
        value: str,
        text: str,
        clear_first: bool = True,
        timeout_seconds: float | None = None,
    ) -> dict[str, Any]:
        """Type text into an element, optionally clearing it first."""
        return _run("type_text", browser.type_text, strategy, value, text, clear_first, timeout_seconds)
  • The type_text tool uses LocatorStrategy from models (a Union type like 'id' | 'css selector' | 'xpath' | etc.) for its 'strategy' parameter.
    from selenium_mcp_server.models import LocatorStrategy
    
    logger = logging.getLogger(__name__)
    settings = get_settings()
    browser = BrowserManager(settings)
    mcp = FastMCP("selenium-mcp-server", json_response=True)
    
    
    def _as_dict(value: Any) -> Any:
        if hasattr(value, "model_dump"):
  • The _run helper wraps the handler call with error handling, converting results to dicts via _as_dict.
    def _run(action: str, func: Any, *args: Any, **kwargs: Any) -> Any:
        try:
            return _as_dict(func(*args, **kwargs))
        except BrowserError:
            logger.exception("Browser action failed: %s", action)
            raise
        except Exception as exc:
            logger.exception("Unexpected Selenium MCP error during %s", action)
            raise BrowserError(f"{action} failed: {exc}") from exc
Behavior2/5

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

With no annotations, the description must fully disclose behavior. It only mentions typing and clearing, but omits details like waiting for element visibility, timeout behavior, or effect of clear_first when false. This is a significant gap.

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

Conciseness4/5

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

The single-sentence description is concise and front-loaded with the core action. However, it could be slightly expanded without verbosity to cover key parameters.

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 complexity (5 parameters, 3 required) and the presence of an output schema, the description is too sparse. It fails to contextualize the locator strategy, timeout, or the interaction between clear_first and typing.

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

Parameters2/5

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

Schema description coverage is 0%, yet the description only clarifies 'text' and 'clear_first' meaning. It does not explain 'strategy', 'value' (locator), or 'timeout_seconds', leaving the agent to infer from schema alone.

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 tool's action: typing text into an element with an optional clear. It distinguishes from siblings like click or get_text, but could be more precise about what 'clearing' entails (e.g., selecting all and deleting).

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?

No guidance is provided on when to use this tool versus alternatives like click or execute_script. The agent receives no hints about prerequisites or exclusions.

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/Lokii0911/SeleniumMCP'

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