Skip to main content
Glama

find_xcresults

Locate XCResult files for an Xcode project to access test results and build data with timestamps and file details.

Instructions

Find all XCResult files for a specific project with timestamps and file information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xcodeprojYesAbsolute path to the .xcodeproj file (or .xcworkspace if available) - e.g., /path/to/project.xcodeproj

Implementation Reference

  • Main handler implementation for the 'find_xcresults' tool. Validates project path, finds XCResult files using helper, formats and returns list with timestamps and sizes.
    public static async findXCResults(projectPath: string): Promise<McpResult> {
      const validationError = PathValidator.validateProjectPath(projectPath);
      if (validationError) return validationError;
    
      try {
        const xcresultFiles = await this._findXCResultFiles(projectPath);
        
        if (xcresultFiles.length === 0) {
          return { 
            content: [{ 
              type: 'text', 
              text: `No XCResult files found for project: ${projectPath}\n\nXCResult files are created when you run tests. Try running tests first with 'xcode_test'.`
            }] 
          };
        }
    
        let message = `πŸ” Found ${xcresultFiles.length} XCResult file(s) for project: ${projectPath}\n\n`;
        message += `πŸ“ XCResult Files (sorted by newest first):\n`;
        message += '='.repeat(80) + '\n';
    
        xcresultFiles.forEach((file, index) => {
          const date = new Date(file.mtime);
          const timeAgo = this._getTimeAgo(file.mtime);
          
          message += `${index + 1}. ${file.path}\n`;
          message += `   πŸ“… Created: ${date.toLocaleString()} (${timeAgo})\n`;
          message += `   πŸ“Š Size: ${this._formatFileSize(file.size || 0)}\n\n`;
        });
    
        message += `πŸ’‘ Usage:\n`;
        message += `  β€’ View results: xcresult-browse --xcresult-path "<path>"\n`;
        message += `  β€’ Get console: xcresult-browser-get-console --xcresult-path "<path>" --test-id <test-id>\n`;
        
        return { content: [{ type: 'text', text: message }] };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return { 
          content: [{ 
            type: 'text', 
            text: `Failed to find XCResult files: ${errorMessage}` 
          }] 
        };
      }
    }
  • Core helper method that searches DerivedData/Logs/Test for .xcresult bundles, collects paths with metadata, sorts by newest first.
    private static async _findXCResultFiles(projectPath: string): Promise<{ path: string; mtime: number; size?: number }[]> {
      const xcresultFiles: { path: string; mtime: number; size?: number }[] = [];
      
      try {
        // Use existing BuildLogParser logic to find the correct DerivedData directory
        const derivedData = await BuildLogParser.findProjectDerivedData(projectPath);
        
        if (derivedData) {
          // Look for xcresult files in the Test logs directory
          const testLogsDir = join(derivedData, 'Logs', 'Test');
          try {
            const files = await readdir(testLogsDir);
            const xcresultDirs = files.filter(file => file.endsWith('.xcresult'));
            
            for (const xcresultDir of xcresultDirs) {
              const fullPath = join(testLogsDir, xcresultDir);
              try {
                const stats = await stat(fullPath);
                xcresultFiles.push({
                  path: fullPath,
                  mtime: stats.mtime.getTime(),
                  size: stats.size
                });
              } catch {
                // Ignore files we can't stat
              }
            }
          } catch (error) {
            Logger.debug(`Could not read test logs directory: ${error}`);
          }
        }
      } catch (error) {
        Logger.warn(`Error finding xcresult files: ${error}`);
      }
      
      return xcresultFiles.sort((a, b) => b.mtime - a.mtime);
    }
  • Tool schema definition including input schema for xcodeproj parameter.
      name: 'find_xcresults',
      description: 'Find all XCResult files for a specific project with timestamps and file information',
      inputSchema: {
        type: 'object',
        properties: {
          xcodeproj: {
            type: 'string',
            description: preferredXcodeproj 
              ? `Absolute path to the .xcodeproj file (or .xcworkspace if available) - defaults to ${preferredXcodeproj}`
              : 'Absolute path to the .xcodeproj file (or .xcworkspace if available) - e.g., /path/to/project.xcodeproj',
          },
        },
        required: preferredXcodeproj ? [] : ['xcodeproj'],
      },
    },
  • Tool dispatch/registration in MCP server switch statement - calls BuildTools.findXCResults
    case 'find_xcresults':
      if (!args.xcodeproj) {
        throw new McpError(ErrorCode.InvalidParams, `Missing required parameter: xcodeproj`);
      }
      return await BuildTools.findXCResults(args.xcodeproj as string);

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