Skip to main content
Glama

stop_sim_log_cap

Stop an active simulator log capture session and retrieve the collected logs for analysis.

Instructions

Stops an active simulator log capture session and returns the captured logs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
logSessionIdYesThe session ID returned by start_sim_log_cap.

Implementation Reference

  • Handler function for the 'stop_sim_log_cap' tool. Validates input, calls stopLogCapture utility, and formats the response with captured logs or error.
    async function handler(params: { logSessionId: string }): Promise<ToolResponse> { const validationResult = validateRequiredParam('logSessionId', params.logSessionId); if (!validationResult.isValid) { return validationResult.errorResponse!; } const { logContent, error } = await stopLogCapture(params.logSessionId); if (error) { return { content: [ createTextContent(`Error stopping log capture session ${params.logSessionId}: ${error}`), ], isError: true, }; } return { content: [ createTextContent( `Log capture session ${params.logSessionId} stopped successfully. Log content follows:\n\n${logContent}`, ), ], }; }
  • Input schema for the 'stop_sim_log_cap' tool using Zod, requiring logSessionId.
    const schema = { logSessionId: z.string().describe('The session ID returned by start_sim_log_cap.'), };
  • Registration of the 'stop_sim_log_cap' tool using registerTool on the MCP server.
    registerTool( server, 'stop_sim_log_cap', 'Stops an active simulator log capture session and returns the captured logs.', schema, handler, );
  • Core utility function stopLogCapture that terminates log capture processes, reads the log file content, and cleans up the session from activeLogSessions map.
    export async function stopLogCapture( logSessionId: string, ): Promise<{ logContent: string; error?: string }> { const session = activeLogSessions.get(logSessionId); if (!session) { log('warning', `Log session not found: ${logSessionId}`); return { logContent: '', error: `Log capture session not found: ${logSessionId}` }; } try { log('info', `Attempting to stop log capture session: ${logSessionId}`); const logFilePath = session.logFilePath; for (const process of session.processes) { if (!process.killed && process.exitCode === null) { process.kill('SIGTERM'); } } activeLogSessions.delete(logSessionId); log( 'info', `Log capture session ${logSessionId} stopped. Log file retained at: ${logFilePath}`, ); await fs.promises.access(logFilePath, fs.constants.R_OK); const fileContent = await fs.promises.readFile(logFilePath, 'utf-8'); log('info', `Successfully read log content from ${logFilePath}`); return { logContent: fileContent }; } catch (error) { const message = error instanceof Error ? error.message : String(error); log('error', `Failed to stop log capture session ${logSessionId}: ${message}`); return { logContent: '', error: message }; } }

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