Skip to main content
Glama

xcresult_list_attachments

List test attachments from Xcode result files to identify available files for export by name, type, and index.

Instructions

List all attachments for a specific test - shows attachment names, types, and indices for export

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xcresult_pathYesAbsolute path to the .xcresult file
test_idYesTest ID or index number to list attachments for

Implementation Reference

  • Core handler function that validates inputs, parses the XCResult file using XCResultParser, finds the test node, retrieves attachments, formats the output with indices/types/sizes, and returns formatted text response.
    public static async xcresultListAttachments(
      xcresultPath: string,
      testId: string
    ): Promise<McpResult> {
      // Validate xcresult path
      if (!existsSync(xcresultPath)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `XCResult file not found: ${xcresultPath}`
        );
      }
    
      if (!xcresultPath.endsWith('.xcresult')) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `Path must be an .xcresult file: ${xcresultPath}`
        );
      }
    
      // Check if xcresult is readable
      if (!XCResultParser.isXCResultReadable(xcresultPath)) {
        throw new McpError(
          ErrorCode.InternalError,
          `XCResult file is not readable or incomplete: ${xcresultPath}`
        );
      }
    
      if (!testId || testId.trim() === '') {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Test ID or index is required'
        );
      }
    
      try {
        const parser = new XCResultParser(xcresultPath);
        
        // First find the test node to get the actual test identifier
        const testNode = await parser.findTestNode(testId);
        if (!testNode) {
          throw new McpError(
            ErrorCode.InvalidParams,
            `Test '${testId}' not found. Run xcresult_browse "${xcresultPath}" to see all available tests`
          );
        }
    
        if (!testNode.nodeIdentifier) {
          throw new McpError(
            ErrorCode.InvalidParams,
            `Test '${testId}' does not have a valid identifier for attachment retrieval`
          );
        }
    
        // Get test attachments
        const attachments = await parser.getTestAttachments(testNode.nodeIdentifier);
        
        let output = `šŸ“Ž Attachments for test: ${testNode.name}\n`;
        output += `Found ${attachments.length} attachments\n`;
        output += '='.repeat(80) + '\n\n';
        
        if (attachments.length === 0) {
          output += 'No attachments found for this test.\n';
        } else {
          attachments.forEach((att, index) => {
            const filename = att.name || att.filename || 'unnamed';
            output += `[${index + 1}] ${filename}\n`;
            
            // Determine type from identifier or filename
            let type = att.uniform_type_identifier || att.uniformTypeIdentifier || '';
            if (!type || type === 'unknown') {
              // Infer type from filename extension or special patterns
              const ext = filename.toLowerCase().split('.').pop();
              if (ext === 'jpeg' || ext === 'jpg') type = 'public.jpeg';
              else if (ext === 'png') type = 'public.png';
              else if (ext === 'mp4') type = 'public.mpeg-4';
              else if (ext === 'mov') type = 'com.apple.quicktime-movie';
              else if (ext === 'txt') type = 'public.plain-text';
              else if (filename.toLowerCase().includes('app ui hierarchy')) type = 'ui-hierarchy';
              else if (filename.toLowerCase().includes('ui snapshot')) type = 'ui-snapshot';
              else if (filename.toLowerCase().includes('synthesized event')) type = 'synthesized-event';
              else type = 'unknown';
            }
            
            output += `    Type: ${type}\n`;
            if (att.payloadSize || att.payload_size) {
              output += `    Size: ${att.payloadSize || att.payload_size} bytes\n`;
            }
            output += '\n';
          });
          
          output += '\nšŸ’” To export a specific attachment, use xcresult_export_attachment with the attachment index.\n';
        }
        
        return { content: [{ type: 'text', text: output }] };
    
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
    
        const errorMessage = error instanceof Error ? error.message : String(error);
        
        if (errorMessage.includes('xcresulttool')) {
          throw new McpError(
            ErrorCode.InternalError,
            `XCResult parsing failed. Make sure Xcode Command Line Tools are installed: ${errorMessage}`
          );
        }
        
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to list attachments: ${errorMessage}`
        );
      }
    }
  • JSON Schema definition for the tool including input parameters: xcresult_path (required string) and test_id (required string). Used by both CLI and MCP server.
      name: 'xcresult_list_attachments',
      description: 'List all attachments for a specific test - shows attachment names, types, and indices for export',
      inputSchema: {
        type: 'object',
        properties: {
          xcresult_path: {
            type: 'string',
            description: 'Absolute path to the .xcresult file',
          },
          test_id: {
            type: 'string',
            description: 'Test ID or index number to list attachments for',
          },
        },
        required: ['xcresult_path', 'test_id'],
      },
    },
  • MCP server registration: switch case in CallToolRequestSchema handler that validates parameters and delegates to XCResultTools.xcresultListAttachments.
    case 'xcresult_list_attachments':
      if (!args.xcresult_path) {
        throw new McpError(ErrorCode.InvalidParams, `Missing required parameter: xcresult_path`);
      }
      if (!args.test_id) {
        throw new McpError(ErrorCode.InvalidParams, `Missing required parameter: test_id`);
      }
      return await XCResultTools.xcresultListAttachments(
        args.xcresult_path as string,
        args.test_id as string
      );
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool lists attachments, implying a read-only operation, but doesn't disclose behavioral traits such as whether it requires specific permissions, how it handles errors, if there are rate limits, or what the output format looks like (e.g., JSON, list structure). The mention of 'indices for export' adds some context for downstream use, but overall behavioral details are sparse.

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 description is a single, efficient sentence that front-loads the core purpose ('List all attachments for a specific test') and adds useful detail ('shows attachment names, types, and indices for export'). There's no wasted text, and it's appropriately sized for the tool's complexity, though it could be slightly more structured with bullet points for clarity.

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?

Given 2 parameters with 100% schema coverage, no annotations, and no output schema, the description is moderately complete. It covers the basic purpose and output details (attachment names, types, indices), but lacks information on behavioral aspects like error handling or output format. For a read-only listing tool, this is adequate but has clear gaps in transparency and usage guidance.

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 both parameters ('xcresult_path' and 'test_id') with clear descriptions. The description adds no additional meaning beyond what's in the schema, such as explaining how to obtain a test ID or format the path. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but doesn't need to heavily.

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 action ('List all attachments') and resource ('for a specific test'), specifying what information is shown (attachment names, types, and indices for export). It distinguishes from some siblings like 'xcresult_export_attachment' by focusing on listing rather than exporting, but doesn't explicitly differentiate from all related tools like 'xcresult_get_screenshot' or 'xcresult_get_ui_element' which might also retrieve specific attachment types.

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

Usage Guidelines3/5

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

The description implies usage when needing to list attachments for a test, but provides no explicit guidance on when to use this tool versus alternatives like 'xcresult_export_attachment' for downloading or other xcresult tools for different data. It mentions 'indices for export' which hints at a prerequisite for export operations, but lacks clear when/when-not instructions or named alternatives.

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/lapfelix/XcodeMCP'

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