{"version":3,"sources":["../../../../src/server/mcp/tools/get-logs.ts"],"sourcesContent":["/**\n * MCP tool for getting the path to the Next.js development log file.\n *\n * This tool returns the path to the {nextConfig.distDir}/logs/next-development.log file\n * that contains browser console logs and other development information.\n */\nimport type { McpServer } from 'next/dist/compiled/@modelcontextprotocol/sdk/server/mcp'\nimport { stat } from 'fs/promises'\nimport { join } from 'path'\nimport { mcpTelemetryTracker } from '../mcp-telemetry-tracker'\n\nexport function registerGetLogsTool(server: McpServer, distDir: string) {\n  server.registerTool(\n    'get_logs',\n    {\n      description:\n        'Get the path to the Next.js development log file. Returns the file path so the agent can read the logs directly.',\n    },\n    async () => {\n      // Track telemetry\n      mcpTelemetryTracker.recordToolCall('mcp/get_logs')\n\n      try {\n        const logFilePath = join(distDir, 'logs', 'next-development.log')\n\n        // Check if the log file exists\n        try {\n          await stat(logFilePath)\n        } catch (error) {\n          return {\n            content: [\n              {\n                type: 'text',\n                text: JSON.stringify({\n                  error: `Log file not found at ${logFilePath}.`,\n                }),\n              },\n            ],\n          }\n        }\n\n        return {\n          content: [\n            {\n              type: 'text',\n              text: JSON.stringify({\n                logFilePath,\n              }),\n            },\n          ],\n        }\n      } catch (error) {\n        return {\n          content: [\n            {\n              type: 'text',\n              text: JSON.stringify({\n                error: `Error getting log file path: ${error instanceof Error ? error.message : String(error)}`,\n              }),\n            },\n          ],\n        }\n      }\n    }\n  )\n}\n"],"names":["registerGetLogsTool","server","distDir","registerTool","description","mcpTelemetryTracker","recordToolCall","logFilePath","join","stat","error","content","type","text","JSON","stringify","Error","message","String"],"mappings":"AAAA;;;;;CAKC;;;;+BAMeA;;;eAAAA;;;0BAJK;sBACA;qCACe;AAE7B,SAASA,oBAAoBC,MAAiB,EAAEC,OAAe;IACpED,OAAOE,YAAY,CACjB,YACA;QACEC,aACE;IACJ,GACA;QACE,kBAAkB;QAClBC,wCAAmB,CAACC,cAAc,CAAC;QAEnC,IAAI;YACF,MAAMC,cAAcC,IAAAA,UAAI,EAACN,SAAS,QAAQ;YAE1C,+BAA+B;YAC/B,IAAI;gBACF,MAAMO,IAAAA,cAAI,EAACF;YACb,EAAE,OAAOG,OAAO;gBACd,OAAO;oBACLC,SAAS;wBACP;4BACEC,MAAM;4BACNC,MAAMC,KAAKC,SAAS,CAAC;gCACnBL,OAAO,CAAC,sBAAsB,EAAEH,YAAY,CAAC,CAAC;4BAChD;wBACF;qBACD;gBACH;YACF;YAEA,OAAO;gBACLI,SAAS;oBACP;wBACEC,MAAM;wBACNC,MAAMC,KAAKC,SAAS,CAAC;4BACnBR;wBACF;oBACF;iBACD;YACH;QACF,EAAE,OAAOG,OAAO;YACd,OAAO;gBACLC,SAAS;oBACP;wBACEC,MAAM;wBACNC,MAAMC,KAAKC,SAAS,CAAC;4BACnBL,OAAO,CAAC,6BAA6B,EAAEA,iBAAiBM,QAAQN,MAAMO,OAAO,GAAGC,OAAOR,QAAQ;wBACjG;oBACF;iBACD;YACH;QACF;IACF;AAEJ","ignoreList":[0]}