Skip to main content
Glama

find_elements

Search iOS Simulator UI elements by text in labels, values, or hints to locate interface components for automation tasks.

Instructions

Search the UI tree for elements whose label, value, or hint contains query text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesText to search for in labels/values/hints
udidNoSimulator UDID (optional, defaults to booted simulator)

Implementation Reference

  • Implementation of the 'find_elements' MCP tool handler.
    private async findElements(query: string, udid?: string) {
      const target = await resolveUdid(udid);
      try {
        const all = await this.fetchUiTree(target);
        const matches = findElementsByText(all, query);
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({ query, count: matches.length, elements: matches }, null, 2),
          }],
        };
      } catch (error: any) {
        throw new McpError(ErrorCode.InternalError, `Failed to find elements: ${error.message}`);
      }
    }
  • src/index.ts:446-455 (registration)
    Registration of the 'find_elements' tool with its schema definition.
    {
      name: 'find_elements',
      description: 'Search the UI tree for elements whose label, value, or hint contains query text',
      inputSchema: {
        type: 'object',
        properties: {
          query: { type: 'string', description: 'Text to search for in labels/values/hints' },
          udid: { type: 'string', description: 'Simulator UDID (optional, defaults to booted simulator)' },
        },
        required: ['query'],

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/xmuweili/app-screen-mcp'

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