my-project-repo_get_operation_logs
Retrieve operation logs for Git repository management to track batch commits, pushes, and synchronization activities across multiple repositories.
Instructions
[My Awesome Project] Get operation logs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Limit count, default 50 | |
| offset | No | Offset, default 0 |
Implementation Reference
- src/server-final.js:344-367 (handler)Handler function that implements the core logic of 'my-project-repo_get_operation_logs' tool. It validates input parameters (limit, offset), slices the operationLogs array accordingly, and returns paginated logs with metadata.// Get operation logs async get_operation_logs(params) { const { limit = 50, offset = 0 } = params || {}; // Validate parameters if (typeof limit !== 'number' || limit < 1 || limit > 1000) { throw new Error('limit parameter must be between 1-1000'); } if (typeof offset !== 'number' || offset < 0) { throw new Error('offset parameter must be greater than or equal to 0'); } // Return logs from memory const logs = operationLogs.slice(offset, offset + limit); return { logs: logs, total: operationLogs.length, limit: limit, offset: offset, hasMore: offset + limit < operationLogs.length }; }
- src/server-final.js:498-515 (registration)Registration of the tool in the 'tools/list' MCP method. Dynamically constructs the tool name as 'my-project-repo_get_operation_logs' using REPO_NAME prefix via getToolName, includes description and input schema.// Add get_operation_logs tool tools.push({ name: getToolName('get_operation_logs'), description: getToolDescription('Get operation logs'), inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Limit count, default 50' }, offset: { type: 'number', description: 'Offset, default 0' } } } });
- src/server-final.js:502-514 (schema)JSON schema for tool inputs, defining optional pagination parameters 'limit' (1-1000) and 'offset' (>=0). Used in registration and validation.inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Limit count, default 50' }, offset: { type: 'number', description: 'Offset, default 0' } } }
- src/server-final.js:61-86 (helper)Utility function that records all tool calls (including this one) to in-memory operationLogs array and file log. Called after every tool execution.const logRequest = (method, params, result, error = null) => { const logEntry = { id: Date.now(), method, params: JSON.stringify(params), result: result ? JSON.stringify(result) : null, error: error ? error.toString() : null, created_at: new Date().toISOString() }; operationLogs.unshift(logEntry); if (operationLogs.length > MAX_LOGS) { operationLogs.splice(MAX_LOGS); } // Record request and response data const logLine = `${logEntry.created_at} | ${method} | ${logEntry.params} | ${error || 'SUCCESS'} | RESPONSE: ${logEntry.result || 'null'}\n`; try { ensureLogDir(); const { fullPath } = getLogConfig(); fs.appendFileSync(fullPath, logLine, 'utf8'); } catch (err) { console.error('Failed to write log file:', err.message); } };
- src/server-final.js:8-10 (helper)Global in-memory array storing up to 1000 recent operation logs, which the handler queries and paginates.// In-memory log storage const operationLogs = []; const MAX_LOGS = 1000;