Skip to main content
Glama

stop_sim_log_cap

Ends an active simulator log capture session and retrieves the collected logs by providing the session ID. Use to efficiently manage and analyze simulation data.

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 that validates the logSessionId input, calls the stopLogCapture utility, handles errors, and returns formatted tool response including the captured logs.
    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}`, ), ], }; }
  • Zod schema defining the input parameter logSessionId for the stop_sim_log_cap tool.
    const schema = { logSessionId: z.string().describe('The session ID returned by start_sim_log_cap.'), };
  • Registration of the stop_sim_log_cap tool on the MCP server, linking name, description, schema, and handler.
    registerTool( server, 'stop_sim_log_cap', 'Stops an active simulator log capture session and returns the captured logs.', schema, handler, );
  • Supporting utility function that stops the log capture processes for the given session ID, reads the accumulated log file content, cleans up the session, and returns the logs or error.
    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