Consulter les logs système
task_logsView and filter system logs for monitoring task execution, debugging errors, and tracking activity in the MCP SFTP Orchestrator server.
Instructions
Affiche les logs du système MCP.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| level | No | Filtrer par niveau de log. | |
| search | No | Rechercher dans les messages. | |
| limit | No | Nombre de logs à afficher. |
Implementation Reference
- server.js:683-701 (registration)Registration of the 'task_logs' MCP tool, including title, description, input schema (Zod), and the inline handler function that calls queue.getLogs to retrieve and return system logs.
server.registerTool( "task_logs", { title: "Consulter les logs système", description: "Affiche les logs du système MCP.", inputSchema: z.object({ level: z.enum(['error', 'warn', 'info', 'debug']).optional().describe("Filtrer par niveau de log."), search: z.string().optional().describe("Rechercher dans les messages."), limit: z.number().optional().default(50).describe("Nombre de logs à afficher.") }) }, async (params) => { const logs = queue.getLogs({ level: params.level, search: params.search }).slice(-params.limit); return { content: [{ type: "text", text: JSON.stringify(logs, null, 2) }] }; } ); - queue.js:197-208 (helper)The getLogs helper function in queue.js, which filters the internal logHistory array by level, search term, or since date, and is directly called by the task_logs handler.
function getLogs(filter = {}) { if (!filter || Object.keys(filter).length === 0) { return logHistory; } return logHistory.filter(log => { if (filter.level && log.level !== filter.level) return false; if (filter.since && new Date(log.timestamp) < new Date(filter.since)) return false; if (filter.search && !log.message.toLowerCase().includes(filter.search.toLowerCase())) return false; return true; }); } - queue.js:114-133 (helper)The log utility function that creates and appends log entries to the logHistory array (with max 500 entries), which serves as the data source for the task_logs tool via getLogs.
function log(level, message) { const logEntry = { level, message, timestamp: new Date().toISOString() }; logHistory.push(logEntry); if (logHistory.length > MAX_LOGS) { logHistory.shift(); } // ✅ N'afficher les logs que si MCP_DEBUG=true if (!SILENT_MODE && ['error', 'warn', 'info'].includes(level)) { const prefix = { error: '[❌ ERROR]', warn: '[⚠️ WARN]', info: '[ℹ️ INFO]', debug: '[🔧 DEBUG]' }[level] || `[${level.toUpperCase()}]`; // ✅ TOUJOURS utiliser stderr (pas stdout) console.error(`${prefix} ${new Date().toISOString().split('T')[1].split('.')[0]} - ${message}`); } }