Skip to main content
Glama
allegiant

MQScript MCP Server

by allegiant

mqscript_element_gettext

Extract text content from mobile UI elements using element IDs or selectors for automation testing and data retrieval in mobile applications.

Instructions

Get text from UI element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
elementIdYesElement ID or selector
resultVariableNoVariable name to store resultelementText

Implementation Reference

  • The handler function that implements the tool logic. It takes elementId and optional resultVariable, generates an MQScript command to retrieve text from the UI element, and returns a formatted response with the generated script.
    handler: async (args: { elementId: string; resultVariable?: string }) => {
      const { elementId, resultVariable = 'elementText' } = args;
      const script = `${resultVariable} = Element.GetText("${elementId}")`;
      return {
        content: [
          {
            type: 'text',
            text: `Generated MQScript get element text command:\n\`\`\`\n${script}\n\`\`\`\n\nThis gets text from element "${elementId}" and stores it in variable "${resultVariable}".`
          }
        ]
      };
    }
  • The input schema defining the parameters for the tool: required elementId (string) and optional resultVariable (string, default 'elementText').
    inputSchema: {
      type: 'object' as const,
      properties: {
        elementId: {
          type: 'string',
          description: 'Element ID or selector'
        },
        resultVariable: {
          type: 'string',
          description: 'Variable name to store result',
          default: 'elementText'
        }
      },
      required: ['elementId']
    },
  • src/index.ts:32-61 (registration)
    The tool is registered by spreading ElementCommands into the ALL_TOOLS object, which is then used in listTools and callTool handlers to provide and execute the tools.
    const ALL_TOOLS = {
      // Basic Commands - 基础命令
      ...TouchCommands,
      ...ControlCommands,
      ...ColorCommands,
      ...OtherCommands,
      
      // Standard Library - 标准库函数
      ...MathFunctions,
      ...StringFunctions,
      ...TypeConversionFunctions,
      ...ArrayFunctions,
      
      // UI Commands - 界面命令
      ...UIControlCommands,
      ...UIPropertyCommands,
      ...FloatingWindowCommands,
      
      // Extension Commands - 扩展命令
      ...ElementCommands,
      ...DeviceCommands,
      ...PhoneCommands,
      ...SysCommands,
      
      // Plugin Commands - 插件命令
      ...CJsonCommands,
      ...DateTimeCommands,
      ...FileCommands,
      ...TuringCommands,
    };
  • src/index.ts:15-15 (registration)
    Import of ElementCommands containing the mqscript_element_gettext tool definition.
    import { ElementCommands, DeviceCommands, PhoneCommands, SysCommands } from './tools/extension-commands.js';
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('Get text') but doesn't explain what happens if the element isn't found, if the text is empty, or how the result is stored (e.g., in a variable as implied by the schema). It also omits details like whether this is a read-only operation (implied but not stated), potential errors, or performance considerations, leaving significant gaps in understanding the tool's behavior.

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 a single, efficient sentence ('Get text from UI element') that is front-loaded and wastes no words. It directly conveys the core action without unnecessary elaboration, making it easy to parse quickly. Every part of the sentence earns its place by specifying what is being retrieved and from where.

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 complexity of interacting with UI elements and the lack of annotations and output schema, the description is incomplete. It doesn't explain the return value (e.g., the text content as a string), error conditions, or dependencies on other tools (e.g., needing to identify elements first). For a tool that likely involves dynamic UI state, this leaves critical context gaps for an agent to use it effectively.

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?

The input schema has 100% description coverage, with clear documentation for both parameters ('elementId' and 'resultVariable'). The description adds no additional meaning beyond the schema, such as examples of valid element IDs or how the result variable is used. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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

Purpose3/5

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

The description 'Get text from UI element' clearly states the verb ('Get') and resource ('text from UI element'), making the purpose understandable. However, it doesn't distinguish this tool from its sibling 'mqscript_element_settext' (which sets text) or other text-related tools like 'mqscript_cstr' or 'mqscript_inputtext', leaving room for ambiguity about when to choose this specific tool.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a UI element to be visible or accessible), compare it to siblings like 'mqscript_element_settext' for text manipulation, or suggest other tools for related tasks such as 'mqscript_inputtext' for user input. This lack of context makes it harder for an agent to decide when this tool is appropriate.

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/allegiant/MQScript_MCP'

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