UNPKG

christmas-mcp-image-describe

Version:

MCP server that analyzes images and provides structured metadata for website placement decisions using OpenAI GPT-4o Vision API

83 lines (66 loc) 3.17 kB
#!/usr/bin/env node // Debug script to log how the package is being called console.error('[DEBUG] Christmas MCP Debug - Entry Point Analysis'); console.error('[DEBUG] Process arguments:', process.argv); console.error('[DEBUG] Working directory:', process.cwd()); console.error('[DEBUG] __filename equivalent:', new URL(import.meta.url).pathname); console.error('[DEBUG] Environment variables:'); console.error('[DEBUG] NODE_ENV:', process.env.NODE_ENV); console.error('[DEBUG] VSCODE_PID:', process.env.VSCODE_PID); console.error('[DEBUG] TERM_PROGRAM:', process.env.TERM_PROGRAM); // Check if this is being called by VS Code const isVSCode = process.env.VSCODE_PID || process.env.TERM_PROGRAM === 'vscode'; console.error('[DEBUG] Detected VS Code execution:', isVSCode); // Check execution context import { fileURLToPath } from 'url'; import path from 'path'; const __filename = fileURLToPath(import.meta.url); const isDirectExecution = process.argv[1] && path.resolve(process.argv[1]) === path.resolve(__filename); console.error('[DEBUG] Direct execution check:', isDirectExecution); console.error('[DEBUG] process.argv[1]:', process.argv[1]); console.error('[DEBUG] __filename:', __filename); console.error('[DEBUG] Resolved process.argv[1]:', process.argv[1] ? path.resolve(process.argv[1]) : 'undefined'); console.error('[DEBUG] Resolved __filename:', path.resolve(__filename)); // If this was meant to be an MCP server, redirect to the dedicated server if (isDirectExecution && process.argv.length <= 2) { console.error('[DEBUG] No arguments provided, assuming MCP server call'); console.error('[DEBUG] Redirecting to dedicated MCP server...'); try { // Import and run the dedicated MCP server const { spawn } = await import('child_process'); const serverPath = path.join(path.dirname(__filename), 'bin', 'mcp-server.js'); console.error('[DEBUG] Server path:', serverPath); const serverProcess = spawn('node', [serverPath], { stdio: 'inherit', cwd: process.cwd() }); serverProcess.on('exit', (code) => { console.error('[DEBUG] MCP server exited with code:', code); process.exit(code); }); } catch (error) { console.error('[DEBUG] Failed to start MCP server:', error); process.exit(1); } } else { console.error('[DEBUG] Arguments detected, running CLI...'); // Show CLI help console.log(` Christmas MCP Image Describe - CLI Example Usage: node cli.js <image-path> [context] [api-key] [project-id] Arguments: image-path Path to the image file to analyze context Optional context (e.g., "homepage hero", "about section") api-key OpenAI API key (or set OPENAI_API_KEY environment variable) project-id OpenAI project ID (or set OPENAI_PROJECT environment variable) Examples: node cli.js ./sample.jpg node cli.js ./hero.png "homepage hero" node cli.js ./team.jpg "about section" sk-your-api-key Environment Variables: OPENAI_API_KEY Your OpenAI API key OPENAI_PROJECT Your OpenAI project ID (optional) `); process.exit(1); }