Skip to main content
Glama

Calibre RAG MCP Server

by ispyridis
find-imagemagick.js•5.01 kB
#!/usr/bin/env node const { spawn } = require('child_process'); const fs = require('fs'); const path = require('path'); async function findAndConfigureImageMagick() { console.log('šŸ” Finding and configuring ImageMagick...'); // Test if already in PATH console.log('\\n1ļøāƒ£ Testing if ImageMagick is already in PATH...'); const testCommands = ['magick', 'convert', 'identify']; let workingCommand = null; for (const cmd of testCommands) { try { await new Promise((resolve, reject) => { const child = spawn(cmd, ['--version'], { stdio: 'pipe', windowsHide: true }); let output = ''; child.stdout.on('data', data => output += data.toString()); child.stderr.on('data', data => output += data.toString()); child.on('close', (code) => { if (code === 0) { console.log(`āœ… ${cmd} command works!`); console.log(`šŸ“‹ Version: ${output.split('\\n')[0]}`); workingCommand = cmd; resolve(); } else { reject(new Error(`Command failed with code ${code}`)); } }); child.on('error', () => { reject(new Error(`Command not found`)); }); }); break; // If we get here, command worked } catch (error) { console.log(`āŒ ${cmd} command not found in PATH`); } } if (workingCommand) { console.log('\\nšŸŽ‰ ImageMagick is working! You can proceed with OCR testing.'); return workingCommand; } // Search for ImageMagick installations console.log('\\n2ļøāƒ£ Searching for ImageMagick installations...'); const searchPaths = [ 'C:\\\\Program Files\\\\ImageMagick*', 'C:\\\\Program Files (x86)\\\\ImageMagick*', process.env.LOCALAPPDATA + '\\\\Microsoft\\\\WinGet\\\\Packages\\\\ImageMagick*' ]; const foundPaths = []; for (const searchPath of searchPaths) { try { const basePath = searchPath.replace(/\\\\\*$/, ''); if (fs.existsSync(basePath)) { const items = fs.readdirSync(basePath); for (const item of items) { if (item.includes('ImageMagick')) { const fullPath = path.join(basePath, item); if (fs.statSync(fullPath).isDirectory()) { foundPaths.push(fullPath); } } } } } catch (error) { // Continue searching } } // Also try direct search const commonLocations = [ 'C:\\\\Program Files\\\\ImageMagick-7.1.1-Q16-HDRI', 'C:\\\\Program Files\\\\ImageMagick-7.1.1-Q16', 'C:\\\\Program Files\\\\ImageMagick', 'C:\\\\Program Files (x86)\\\\ImageMagick' ]; for (const location of commonLocations) { if (fs.existsSync(location) && !foundPaths.includes(location)) { foundPaths.push(location); } } if (foundPaths.length === 0) { console.log('āŒ No ImageMagick installations found.'); console.log('\\nšŸ“„ Try installing with:'); console.log(' winget install ImageMagick.ImageMagick'); console.log(' OR'); console.log(' choco install imagemagick'); return null; } console.log(`\\nāœ… Found ${foundPaths.length} ImageMagick installation(s):`); foundPaths.forEach((p, i) => { console.log(` ${i + 1}. ${p}`); // Check for magick.exe const magickExe = path.join(p, 'magick.exe'); const convertExe = path.join(p, 'convert.exe'); if (fs.existsSync(magickExe)) { console.log(` āœ… Has magick.exe`); } if (fs.existsSync(convertExe)) { console.log(` āœ… Has convert.exe`); } }); // Show how to add to PATH console.log('\\n3ļøāƒ£ To add ImageMagick to your PATH:'); console.log('\\nšŸ“‹ **Temporary (current session only):**'); foundPaths.forEach((p, i) => { console.log(` $env:PATH += ";${p}"`); }); console.log('\\nšŸ“‹ **Permanent (run as Administrator):**'); foundPaths.forEach((p, i) => { console.log(` [Environment]::SetEnvironmentVariable("Path", $env:Path + ";${p}", "Machine")`); }); console.log('\\nšŸ“‹ **GUI Method:**'); console.log(' 1. Win+R → sysdm.cpl → Environment Variables'); console.log(' 2. Edit System PATH variable'); console.log(' 3. Add New entry with path above'); console.log(' 4. Restart PowerShell'); return foundPaths[0]; } findAndConfigureImageMagick();

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ispyridis/calibre-rag-mcp-nodejs'

If you have feedback or need assistance with the MCP directory API, please join our Discord server