Skip to main content
Glama

type

Enter text into labeled input fields on web pages to automate form filling and data entry tasks.

Instructions

Type text into an input field specified by its numbered label from the annotated screenshot. Optionally replace existing text first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
labelYesThe label of the input field
textYesThe text to type into the input field
replaceTextNoIf true, clears any existing text in the input field before typing the new text.

Implementation Reference

  • The handler function that implements the core logic of the 'type' tool. It selects an input element by its data-label attribute (from page annotations), optionally replaces existing text, sets the new value, and triggers input and change events to simulate user typing.
    async function handleType(page: Page, args: any): Promise<CallToolResult> {
      const { label, text, replaceText = false } = args;
      if (!label || !text) {
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: "Both label and text parameters are required for typing",
            },
          ],
        };
      }
    
      const selector = `[data-label="${label}"]`;
      try {
        await page.waitForSelector(selector, { visible: true });
      } catch {
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: `Could not find input element with label ${label}.`,
            },
          ],
        };
      }
    
      // Option A: Directly set the value & dispatch events
      if (replaceText) {
        await page.$eval(
          selector,
          (el: Element, value: string) => {
            const input = el as HTMLInputElement;
            input.value = value;
            input.dispatchEvent(new Event("input", { bubbles: true }));
            input.dispatchEvent(new Event("change", { bubbles: true }));
          },
          text
        );
      } else {
        await page.$eval(
          selector,
          (el: Element, value: string) => {
            const input = el as HTMLInputElement;
            input.value = (input.value ?? "") + value;
            input.dispatchEvent(new Event("input", { bubbles: true }));
            input.dispatchEvent(new Event("change", { bubbles: true }));
          },
          text
        );
      }
    
      // Option B (Alternative): Use page.type() to simulate typing
      // An example if you want to more accurately emulate user typing:
      //   if (replaceText) {
      //     await page.click(selector, { clickCount: 3 }); // highlights existing text
      //     await page.type(selector, text);
      //   } else {
      //     await page.type(selector, text);
      //   }
    
      return {
        isError: false,
        content: [{ type: "text", text: `Typed '${text}' into label ${label}.` }],
      };
    }
  • The tool definition including name, description, and input schema for validation of parameters: label (number), text (string, required), replaceText (boolean, optional). This is part of the TOOLS array returned by listTools.
    {
      name: "type",
      description:
        "Type text into an input field specified by its numbered label from the annotated screenshot. Optionally replace existing text first.",
      inputSchema: {
        type: "object",
        properties: {
          label: {
            type: "number",
            description: "The label of the input field",
          },
          text: {
            type: "string",
            description: "The text to type into the input field",
          },
          replaceText: {
            type: "boolean",
            description:
              "If true, clears any existing text in the input field before typing the new text.",
          },
        },
        required: ["label", "text"],
      },
    },
  • src/index.ts:925-927 (registration)
    The switch case in the main handleToolCall dispatcher that routes 'type' tool calls to the handleType function.
    case "type":
      result = await handleType(page, args);
      break;
  • src/index.ts:1069-1070 (registration)
    The handler for ListToolsRequestSchema returns the TOOLS array, which includes the 'type' tool definition, effectively registering it with the MCP server.
      tools: TOOLS,
    }));
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It explains the core action (typing text) and an optional destructive behavior (replacing existing text), but doesn't mention error handling, timing considerations, or what happens if the label doesn't exist. It provides basic context but lacks depth for a mutation tool in a UI automation context.

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

Conciseness5/5

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

The description is perfectly concise with two sentences that each earn their place: the first states the core purpose and targeting mechanism, the second adds the optional behavior. It's front-loaded with the essential information and contains zero wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a UI automation tool with 3 parameters, no annotations, and no output schema, the description is adequate but minimal. It covers the basic what and how, but doesn't address potential complexities like error scenarios, interaction with other tools, or the visual context implied by 'annotated screenshot.' Given the mutation nature and lack of structured safety hints, more behavioral context would be helpful.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds minimal value beyond the schema: it mentions the 'numbered label' context for the label parameter and hints at the replaceText functionality, but doesn't provide additional syntax, format details, or usage examples that aren't already in the schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Type text into an input field') and the resource ('specified by its numbered label from the annotated screenshot'), with the optional behavior ('Optionally replace existing text first') distinguishing it from simple text entry. It uses precise verbs and specifies the exact mechanism for targeting the input field.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool: when you need to input text into a labeled field in a screenshot-based interface. However, it doesn't explicitly state when NOT to use it or mention alternatives among the sibling tools (like 'search' or 'click'), which could be relevant for different interaction patterns.

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/steel-dev/steel-mcp-server'

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