Skip to main content
Glama

start_sim_log_cap

Capture structured logs from iOS simulators for app debugging and testing. Specify simulator UUID and bundle ID to start log collection.

Instructions

Starts capturing logs from a specified simulator. Returns a session ID. By default, captures only structured logs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
simulatorUuidYesUUID of the simulator to capture logs from (obtained from list_simulators).
bundleIdYesBundle identifier of the app to capture logs for.
captureConsoleNoWhether to capture console output (requires app relaunch).

Implementation Reference

  • The handler function that executes the MCP tool logic for 'start_sim_log_cap'. Validates parameters and calls the core startLogCapture helper.
    async function handler(params: {
      simulatorUuid: string;
      bundleId: string;
      captureConsole?: boolean;
    }): Promise<ToolResponse> {
      const validationResult = validateRequiredParam('simulatorUuid', params.simulatorUuid);
      if (!validationResult.isValid) {
        return validationResult.errorResponse!;
      }
    
      const { sessionId, error } = await startLogCapture(params);
      if (error) {
        return {
          content: [createTextContent(`Error starting log capture: ${error}`)],
          isError: true,
        };
      }
      return {
        content: [
          createTextContent(
            `Log capture started successfully. Session ID: ${sessionId}.\n\n${params.captureConsole ? 'Note: Your app was relaunched to capture console output.' : 'Note: Only structured logs are being captured.'}\n\nNext Steps:\n1.  Interact with your simulator and app.\n2.  Use 'stop_sim_log_cap' with session ID '${sessionId}' to stop capture and retrieve logs.`,
          ),
        ],
      };
    }
  • Zod schema defining the input parameters for the 'start_sim_log_cap' tool.
    const schema = {
      simulatorUuid: z
        .string()
        .describe('UUID of the simulator to capture logs from (obtained from list_simulators).'),
      bundleId: z.string().describe('Bundle identifier of the app to capture logs for.'),
      captureConsole: z
        .boolean()
        .optional()
        .default(false)
        .describe('Whether to capture console output (requires app relaunch).'),
    };
  • src/tools/log.ts:64-70 (registration)
    Direct registration of the 'start_sim_log_cap' tool with the MCP server using registerTool.
    registerTool(
      server,
      'start_sim_log_cap',
      'Starts capturing logs from a specified simulator. Returns a session ID. By default, captures only structured logs.',
      schema,
      handler,
    );
  • Core implementation of log capture: spawns xcrun simctl processes to stream structured logs and optional console output to a temporary file, manages active sessions.
    export async function startLogCapture(params: {
      simulatorUuid: string;
      bundleId: string;
      captureConsole?: boolean;
    }): Promise<{ sessionId: string; logFilePath: string; processes: ChildProcess[]; error?: string }> {
      // Clean up old logs before starting a new session
      await cleanOldLogs();
    
      const { simulatorUuid, bundleId, captureConsole = false } = params;
      const logSessionId = uuidv4();
      const logFileName = `${LOG_FILE_PREFIX}${logSessionId}.log`;
      const logFilePath = path.join(os.tmpdir(), logFileName);
    
      try {
        await fs.promises.mkdir(os.tmpdir(), { recursive: true });
        await fs.promises.writeFile(logFilePath, '');
        const logStream = fs.createWriteStream(logFilePath, { flags: 'a' });
        const processes: ChildProcess[] = [];
        logStream.write('\n--- Log capture for bundle ID: ' + bundleId + ' ---\n');
    
        if (captureConsole) {
          const stdoutLogProcess = spawn('xcrun', [
            'simctl',
            'launch',
            '--console-pty',
            '--terminate-running-process',
            simulatorUuid,
            bundleId,
          ]);
          stdoutLogProcess.stdout.pipe(logStream);
          stdoutLogProcess.stderr.pipe(logStream);
          processes.push(stdoutLogProcess);
        }
    
        const osLogProcess = spawn('xcrun', [
          'simctl',
          'spawn',
          simulatorUuid,
          'log',
          'stream',
          '--level=debug',
          '--predicate',
          `subsystem == "${bundleId}"`,
        ]);
        osLogProcess.stdout.pipe(logStream);
        osLogProcess.stderr.pipe(logStream);
        processes.push(osLogProcess);
    
        for (const process of processes) {
          process.on('close', (code) => {
            log('info', `A log capture process for session ${logSessionId} exited with code ${code}.`);
          });
        }
    
        activeLogSessions.set(logSessionId, {
          processes,
          logFilePath,
          simulatorUuid,
          bundleId,
        });
    
        log('info', `Log capture started with session ID: ${logSessionId}`);
        return { sessionId: logSessionId, logFilePath, processes };
      } catch (error) {
        const message = error instanceof Error ? error.message : String(error);
        log('error', `Failed to start log capture: ${message}`);
        return { sessionId: '', logFilePath: '', processes: [], error: message };
      }
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it returns a session ID (important for tracking), and it defaults to capturing only structured logs (with an option to capture console output). However, it lacks details on permissions, rate limits, or what happens if the simulator is not running.

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 action and result, followed by a default behavior note. It uses only two sentences with zero wasted words, making it highly efficient and easy to parse.

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 no annotations and no output schema, the description is moderately complete. It covers the tool's purpose, return value (session ID), and default behavior, but lacks details on error handling, session management, or how the logs are accessed after capture, which could be important for a tool with mutation implications.

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 all parameters thoroughly. The description adds minimal value beyond the schema by implying the tool's purpose involves these parameters, but it does not provide additional context or usage examples for them.

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 ('Starts capturing logs'), the target resource ('from a specified simulator'), and the scope ('By default, captures only structured logs'). It distinguishes itself from sibling tools like 'stop_sim_log_cap' by indicating it initiates the process rather than terminates it.

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 context by mentioning 'structured logs' and referencing 'list_simulators' in the schema, but it does not explicitly state when to use this tool versus alternatives like 'launch_app_logs_sim' or other logging-related tools. No exclusions or prerequisites are provided.

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/SampsonKY/XcodeBuildMCP'

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