File size: 2,297 Bytes
c592d77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
 * MCP tool for getting the path to the Next.js development log file.
 *
 * This tool returns the path to the {nextConfig.distDir}/logs/next-development.log file
 * that contains browser console logs and other development information.
 */ "use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "registerGetLogsTool", {
    enumerable: true,
    get: function() {
        return registerGetLogsTool;
    }
});
const _promises = require("fs/promises");
const _path = require("path");
const _mcptelemetrytracker = require("../mcp-telemetry-tracker");
function registerGetLogsTool(server, distDir) {
    server.registerTool('get_logs', {
        description: 'Get the path to the Next.js development log file. Returns the file path so the agent can read the logs directly.'
    }, async ()=>{
        // Track telemetry
        _mcptelemetrytracker.mcpTelemetryTracker.recordToolCall('mcp/get_logs');
        try {
            const logFilePath = (0, _path.join)(distDir, 'logs', 'next-development.log');
            // Check if the log file exists
            try {
                await (0, _promises.stat)(logFilePath);
            } catch (error) {
                return {
                    content: [
                        {
                            type: 'text',
                            text: JSON.stringify({
                                error: `Log file not found at ${logFilePath}.`
                            })
                        }
                    ]
                };
            }
            return {
                content: [
                    {
                        type: 'text',
                        text: JSON.stringify({
                            logFilePath
                        })
                    }
                ]
            };
        } catch (error) {
            return {
                content: [
                    {
                        type: 'text',
                        text: JSON.stringify({
                            error: `Error getting log file path: ${error instanceof Error ? error.message : String(error)}`
                        })
                    }
                ]
            };
        }
    });
}

//# sourceMappingURL=get-logs.js.map