view_run_logs
View logs from specific tasks or entire pipelines to monitor execution, debug failures, and analyze recent run outputs.
Instructions
Read logs from a specific task or the entire pipeline from the most recent run.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | No | Task ID to view logs for. If not provided, returns the pipeline.log. | |
| config | No | Path to config.toml file to determine output directory |
Implementation Reference
- src/index.ts:451-484 (handler)Main handler function that executes the view_run_logs tool. Finds the last run directory and reads either the pipeline log or a specific task log.case 'view_run_logs': { const configPath = args?.config || await findConfigFile(); if (!configPath) { throw new Error('No config.toml file found'); } const config = await parseConfig(configPath); const outputDir = getOutputDir(configPath, config); const lastRunDir = await getLastRunDir(outputDir); if (!lastRunDir) { throw new Error('No previous runs found'); } let logContent: string | null; if (args?.taskId) { logContent = await readTaskLog(lastRunDir, args.taskId as string); } else { logContent = await readPipelineLog(lastRunDir); } if (!logContent) { throw new Error(`Log not found for ${args?.taskId || 'pipeline'}`); } return { content: [ { type: 'text', text: logContent, }, ], }; }
- src/index.ts:169-185 (schema)Schema definition and registration of the view_run_logs tool, including input parameters taskId and config.{ name: 'view_run_logs', description: 'Read logs from a specific task or the entire pipeline from the most recent run.', inputSchema: { type: 'object', properties: { taskId: { type: 'string', description: 'Task ID to view logs for. If not provided, returns the pipeline.log.', }, config: { type: 'string', description: 'Path to config.toml file to determine output directory', }, }, }, },
- src/utils.ts:131-138 (helper)Helper function to read the log file for a specific task from the run directory.export async function readTaskLog(runDir: string, taskId: string): Promise<string | null> { try { const logPath = join(runDir, 'logs', `${taskId}.log`); return await readFile(logPath, 'utf-8'); } catch (error) { return null; } }
- src/utils.ts:143-149 (helper)Helper function to read the overall pipeline log from the run directory.export async function readPipelineLog(runDir: string): Promise<string | null> { try { const logPath = join(runDir, 'pipeline.log'); return await readFile(logPath, 'utf-8'); } catch (error) { return null; }
- src/utils.ts:75-100 (helper)Helper function to find the most recent run directory path, essential for locating the logs.export async function getLastRunDir(outputDir: string): Promise<string | null> { try { const runsDir = join(outputDir, 'runs'); const entries = await readdir(runsDir); // Filter for directories and sort by name (timestamp-based) const runDirs = []; for (const entry of entries) { const fullPath = join(runsDir, entry); const stats = await stat(fullPath); if (stats.isDirectory()) { runDirs.push({ name: entry, path: fullPath }); } } if (runDirs.length === 0) { return null; } // Sort descending (most recent first) runDirs.sort((a, b) => b.name.localeCompare(a.name)); return runDirs[0].path; } catch (error) { return null; } }