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
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behavior: large output (>20 lines or >2KB) is automatically saved to a temporary file, which is crucial for understanding output handling. However, it lacks details on permissions, rate limits, or error conditions.

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 front-loaded with the core purpose in the first sentence and adds a critical behavioral note in the second. Both sentences earn their place by providing essential information without redundancy or fluff, making it highly efficient and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is mostly complete: it covers purpose, key behavior (file saving for large output), and parameters are fully documented in the schema. It lacks output format details, but this is acceptable without an output schema.

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, fully documenting both parameters (xcresult_path and test_id). The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline score of 3 without compensating for any gaps.

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

Purpose5/5

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

The description clearly states the specific action ('Get console output and test activities') for a specific resource ('a specific test in an XCResult file'), distinguishing it from sibling tools like xcresult_browse (general browsing) or xcresult_summary (overview). It precisely identifies what the tool does beyond just restating the name.

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 console output for a specific test, but does not explicitly state when to use this tool versus alternatives like xcresult_browse or xcresult_list_attachments. No guidance on prerequisites or exclusions is provided, leaving usage context partially inferred.

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