Buckets:
| /** | |
| * 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. | |
| */ | |
| import type { McpServer } from 'next/dist/compiled/@modelcontextprotocol/sdk/server/mcp' | |
| import { stat } from 'fs/promises' | |
| import { join } from 'path' | |
| import { mcpTelemetryTracker } from '../mcp-telemetry-tracker' | |
| export function registerGetLogsTool(server: McpServer, distDir: string) { | |
| 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.recordToolCall('mcp/get_logs') | |
| try { | |
| const logFilePath = join(distDir, 'logs', 'next-development.log') | |
| // Check if the log file exists | |
| try { | |
| await 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)}`, | |
| }), | |
| }, | |
| ], | |
| } | |
| } | |
| } | |
| ) | |
| } | |
Xet Storage Details
- Size:
- 1.83 kB
- Xet hash:
- 48ca0580b342d9dd8deac31237c49882ce2ad44c0c439a861e9c283866ca38cf
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.