Skip to main content
Glama

Calibre RAG MCP Server

by ispyridis
debug-book-formats.js•4.61 kB
#!/usr/bin/env node const { spawn } = require('child_process'); const fs = require('fs'); const path = require('path'); // Configuration const CALIBRE_LIBRARY = 'D:\\e-library'; async function debugBookFormats() { console.log('šŸ” Debug: Checking book formats and availability...'); try { // Get book info for first few books const bookIds = [1, 2, 3, 4, 5]; for (const bookId of bookIds) { console.log(`\\nšŸ“– Checking Book ID: ${bookId}`); // Get detailed book info const command = 'calibredb'; const args = ['--library-path', CALIBRE_LIBRARY, 'list', '--fields', 'id,title,authors,formats', '--for-machine', '--search', `id:${bookId}`]; console.log(`Running: ${command} ${args.join(' ')}`); const result = await new Promise((resolve, reject) => { const child = spawn(command, args, { stdio: 'pipe', windowsHide: true }); let stdout = ''; let stderr = ''; child.stdout.on('data', (data) => stdout += data.toString()); child.stderr.on('data', (data) => stderr += data.toString()); child.on('close', (code) => { if (code === 0) { resolve(stdout); } else { reject(new Error(`Command failed: ${stderr}`)); } }); child.on('error', reject); }); if (result.trim()) { const books = JSON.parse(result); if (books.length > 0) { const book = books[0]; console.log(` Title: ${book.title}`); console.log(` Authors: ${book.authors}`); console.log(` Formats available: ${book.formats ? book.formats.length : 0}`); if (book.formats && book.formats.length > 0) { book.formats.forEach((format, idx) => { console.log(` ${idx + 1}. ${format}`); console.log(` File exists: ${fs.existsSync(format)}`); if (fs.existsSync(format)) { const ext = path.extname(format).toLowerCase(); console.log(` Extension: ${ext}`); console.log(` Size: ${Math.round(fs.statSync(format).size / 1024)} KB`); } }); // Check for text format const txtFormat = book.formats.find(f => f.endsWith('.txt')); if (txtFormat) { console.log(` āœ… Has text format: ${txtFormat}`); } else { console.log(` āš ļø No text format available`); // Check for OCR-compatible formats const pdfFormat = book.formats.find(f => f.toLowerCase().endsWith('.pdf')); const imgFormat = book.formats.find(f => { const ext = path.extname(f).toLowerCase(); return ['.jpg', '.jpeg', '.png', '.tiff', '.bmp'].includes(ext); }); if (pdfFormat) { console.log(` šŸ“„ Has PDF format: ${pdfFormat}`); } if (imgFormat) { console.log(` šŸ–¼ļø Has image format: ${imgFormat}`); } if (!pdfFormat && !imgFormat) { console.log(` āŒ No OCR-compatible formats available`); } } } else { console.log(` āŒ No formats available`); } } else { console.log(` āŒ Book not found`); } } else { console.log(` āŒ No result from calibredb`); } } } catch (error) { console.error('āŒ Debug failed:', error.message); } } debugBookFormats();

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