Skip to main content
Glama

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
NameRequiredDescriptionDefault
taskIdNoTask ID to view logs for. If not provided, returns the pipeline.log.
configNoPath to config.toml file to determine output directory

Implementation Reference

  • 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, }, ], }; }
  • 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', }, }, }, },
  • 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; } }
  • 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; }
  • 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; } }

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/drewkhoury/devpipe-mcp'

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