Skip to main content
Glama
tcsenpai

Universal Documentation MCP Server

by tcsenpai
inspect-cache.jsโ€ข4.19 kB
#!/usr/bin/env node const fs = require('fs').promises; const path = require('path'); const { config } = require('dotenv'); // ANSI colors const colors = { green: '\x1b[32m', blue: '\x1b[34m', yellow: '\x1b[33m', cyan: '\x1b[36m', bold: '\x1b[1m', reset: '\x1b[0m' }; const { green, blue, yellow, cyan, bold, reset } = colors; async function inspectCache() { try { // Load environment variables from the binary's directory const envPath = path.join(__dirname, '..', '.env'); config({ path: envPath }); console.log(`${bold}${cyan}๐Ÿ” Cache Inspector${reset}\n`); // Import modules after config is loaded const { SQLiteStore } = await import('../dist/sqliteStore.js'); const { gitBookConfig } = await import('../dist/config.js'); if (!gitBookConfig.gitbookUrl) { console.log(`${yellow}โš ๏ธ No GITBOOK_URL configured${reset}`); process.exit(1); } console.log(`${blue}๐Ÿ“– GitBook:${reset} ${gitBookConfig.gitbookUrl}`); console.log(`${blue}๐Ÿท๏ธ Server:${reset} ${gitBookConfig.serverName}`); console.log(); // Initialize store const store = new SQLiteStore(gitBookConfig.gitbookUrl); // Get basic stats const pageCount = await store.getPageCount(); const metadata = store.getMetadata('last_updated'); const domainInfo = store.getDomainInfo(); console.log(`${bold}๐Ÿ“Š Cache Statistics${reset}`); console.log(`${green}๐Ÿ“„ Total Pages:${reset} ${pageCount}`); console.log(`${green}๐Ÿ•’ Last Updated:${reset} ${metadata ? new Date(parseInt(metadata)).toLocaleString() : 'Never'}`); console.log(`${green}๐ŸŽฏ Domain:${reset} ${domainInfo ? domainInfo.name : 'Not detected'}`); console.log(`${green}๐Ÿ”ง Tool Prefix:${reset} ${domainInfo ? domainInfo.toolPrefix : 'generic_'}`); console.log(); // Check for --sample flag const showSample = process.argv.includes('--sample') || process.argv.includes('-s'); const sampleSize = parseInt(process.argv.find(arg => arg.startsWith('--size='))?.split('=')[1]) || 5; if (showSample && pageCount > 0) { console.log(`${bold}๐ŸŽฒ Sample Records (${sampleSize} random pages)${reset}`); console.log(`${cyan}${'='.repeat(60)}${reset}`); const samplePages = await store.getSamplePages(sampleSize); for (const [index, page] of samplePages.entries()) { const contentPreview = page.content.slice(0, 100).replace(/\n/g, ' '); const lastUpdated = page.lastUpdated ? new Date(page.lastUpdated).toLocaleDateString() : 'Unknown'; console.log(`${bold}${index + 1}. ${page.path}${reset}`); console.log(` ${blue}Title:${reset} ${page.title || 'No title'}`); console.log(` ${blue}Updated:${reset} ${lastUpdated}`); console.log(` ${blue}Content:${reset} ${contentPreview}${page.content.length > 100 ? '...' : ''}`); console.log(` ${blue}Size:${reset} ${page.content.length} chars`); console.log(); } } // Storage info const dbPath = store.dbPath; try { const stats = await fs.stat(dbPath); const sizeMB = (stats.size / (1024 * 1024)).toFixed(2); console.log(`${bold}๐Ÿ’พ Storage Info${reset}`); console.log(`${green}๐Ÿ“ Database:${reset} ${dbPath}`); console.log(`${green}๐Ÿ’ฟ Size:${reset} ${sizeMB} MB`); } catch (error) { console.log(`${yellow}โš ๏ธ Database file not found: ${dbPath}${reset}`); } store.close(); console.log(`\n${bold}๐Ÿ’ก Usage Tips${reset}`); console.log(`${cyan}--sample, -s${reset} Show sample records`); console.log(`${cyan}--size=N${reset} Number of sample records (default: 5)`); console.log(`\n${blue}Examples:${reset}`); console.log(`${cyan}npm run inspect-cache --sample${reset}`); console.log(`${cyan}npm run inspect-cache --sample --size=10${reset}`); } catch (error) { console.error(`${bold}โŒ Error: ${error.message}${reset}`); process.exit(1); } } // Run inspector if this script is executed directly if (require.main === module) { inspectCache(); } module.exports = { inspectCache };

Latest Blog Posts

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/tcsenpai/mcpbook'

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