Skip to main content
Glama

xcresult_browser_get_console

Retrieve console output and test activities for specific tests from XCResult files, automatically saving large outputs to temporary files for easier debugging.

Instructions

Get console output and test activities for a specific test in an XCResult file. Large output (>20 lines or >2KB) is automatically saved to a temporary file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xcresult_pathYesAbsolute path to the .xcresult file
test_idYesTest ID or index number to get console output for

Implementation Reference

  • Core handler function that implements the xcresult_browser_get_console tool: validates input, parses XCResult using XCResultParser, extracts console output and test activities for the specified test, handles large output by saving to temp file, returns McpResult.
    public static async xcresultBrowserGetConsole( 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) { return { content: [{ type: 'text', text: `❌ Test '${testId}' not found\n\nRun xcresult_browse "${xcresultPath}" to see all available tests` }] }; } let output = `📟 Console Output for: ${testNode.name}\n`; output += '='.repeat(80) + '\n\n'; // Get console output const consoleOutput = await parser.getConsoleOutput(testNode.nodeIdentifier); output += `Console Log:\n${consoleOutput}\n\n`; // Get test activities if (testNode.nodeIdentifier) { output += `🔬 Test Activities:\n`; const activities = await parser.getTestActivities(testNode.nodeIdentifier); output += activities; } // Check if output is very long and should be saved to a file const lineCount = output.split('\n').length; const charCount = output.length; // If output is longer than 20 lines or 2KB, save to file if (lineCount > 20 || charCount > 2000) { const { writeFile } = await import('fs/promises'); const { tmpdir } = await import('os'); const { join } = await import('path'); // Create a unique filename const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); const safeTestName = testNode.name.replace(/[^a-zA-Z0-9]/g, '_'); const filename = `console_output_${safeTestName}_${timestamp}.txt`; const filePath = join(tmpdir(), filename); await writeFile(filePath, output, 'utf-8'); const fileSizeKB = Math.round(charCount / 1024); return { content: [{ type: 'text', text: `📟 Console Output for: ${testNode.name}\n` + `📄 Output saved to file (${lineCount} lines, ${fileSizeKB} KB): ${filePath}\n\n` + `💡 The console output was too large to display directly. ` + `You can read the file to access the complete console log and test activities.` }] }; } return { content: [{ type: 'text', text: output }] }; } catch (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 get console output: ${errorMessage}` ); } }
  • Tool registration and parameter validation in the MCP CallToolRequestSchema handler (XcodeServer class). Delegates execution to XCResultTools.xcresultBrowserGetConsole
    case 'xcresult_browser_get_console': 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.xcresultBrowserGetConsole( args.xcresult_path as string, args.test_id as string );
  • Tool schema definition including input parameters (xcresult_path, test_id) and description, used by both MCP server and CLI.
    name: 'xcresult_browser_get_console', description: 'Get console output and test activities for a specific test in an XCResult file. Large output (>20 lines or >2KB) is automatically saved to a temporary file.', 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 get console output for', }, }, required: ['xcresult_path', 'test_id'], },
  • Duplicate tool registration in the direct callToolDirect method for CLI compatibility, with identical parameter validation and delegation.
    case 'xcresult_browser_get_console': 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.xcresultBrowserGetConsole( args.xcresult_path as string, args.test_id 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