UNPKG

graphorama-mcp

Version:

High-performance MCP server for code validation and service orchestration

156 lines (131 loc) 5.41 kB
#!/usr/bin/env node const fs = require('fs'); const path = require('path'); const crypto = require('crypto'); // Script to create and validate Claude Desktop Extension (.dxt) package function createDxtPackage() { console.log('📦 Creating Claude Desktop Extension (.dxt)...'); console.log(''); try { const projectRoot = path.join(__dirname, '..'); const dxtPath = path.join(projectRoot, 'graphorama.dxt'); // Step 1: Validate .dxt file exists and is valid JSON console.log('🔍 Validating .dxt manifest...'); if (!fs.existsSync(dxtPath)) { throw new Error('.dxt manifest file not found'); } const dxtContent = fs.readFileSync(dxtPath, 'utf8'); let manifest; try { manifest = JSON.parse(dxtContent); } catch (error) { throw new Error(`Invalid JSON in .dxt manifest: ${error.message}`); } console.log(' ✅ .dxt manifest is valid JSON'); // Step 2: Validate required manifest fields const requiredFields = [ 'name', 'version', 'displayName', 'description', 'author', 'mcp', 'tools', 'manifest_version' ]; for (const field of requiredFields) { if (!manifest[field]) { throw new Error(`Missing required field in manifest: ${field}`); } } console.log(' ✅ All required manifest fields present'); // Step 3: Validate MCP configuration if (!manifest.mcp.server || !manifest.mcp.server.command) { throw new Error('Invalid MCP server configuration'); } console.log(' ✅ MCP server configuration valid'); // Step 4: Validate tools array if (!Array.isArray(manifest.tools) || manifest.tools.length === 0) { throw new Error('Tools array is missing or empty'); } const requiredToolFields = ['name', 'description']; for (let i = 0; i < manifest.tools.length; i++) { const tool = manifest.tools[i]; for (const field of requiredToolFields) { if (!tool[field]) { throw new Error(`Tool ${i} missing required field: ${field}`); } } } console.log(` ✅ ${manifest.tools.length} tools validated`); // Step 5: Check installation methods if (!manifest.installation || !manifest.installation.methods) { throw new Error('Installation methods not specified'); } const installMethods = manifest.installation.methods; console.log(` ✅ ${installMethods.length} installation methods available`); for (const method of installMethods) { console.log(` - ${method.type}: ${method.description}`); } // Step 6: Generate package info console.log(''); console.log('📋 Package Information:'); console.log(` Name: ${manifest.displayName}`); console.log(` Version: ${manifest.version}`); console.log(` Author: ${manifest.author}`); console.log(` License: ${manifest.license}`); console.log(` Homepage: ${manifest.homepage}`); console.log(''); console.log('🛠️ MCP Tools:'); manifest.tools.forEach((tool, index) => { console.log(` ${index + 1}. ${tool.name} - ${tool.description}`); }); console.log(''); // Step 7: Calculate manifest hash const manifestHash = crypto.createHash('sha256').update(dxtContent).digest('hex'); console.log(`🔐 Manifest SHA256: ${manifestHash.substring(0, 16)}...`); console.log(''); // Step 8: Generate installation instructions console.log('📥 Installation Instructions:'); console.log(''); console.log('For Claude Desktop users:'); console.log('1. Download the .dxt file from the releases page'); console.log('2. Open Claude Desktop'); console.log('3. Go to Extensions > Install from file'); console.log('4. Select the graphorama.dxt file'); console.log('5. Follow the installation prompts'); console.log(''); console.log('Manual MCP configuration:'); console.log('Add to your Claude Desktop config.json:'); console.log(''); console.log(JSON.stringify({ mcpServers: { graphorama: { command: "graphorama", args: ["serve", "--transport", "stdio"] } } }, null, 2)); console.log(''); // Step 9: Version compatibility check const packageJson = require('../package.json'); if (manifest.version !== packageJson.version) { console.log('⚠️ Version mismatch detected:'); console.log(` .dxt version: ${manifest.version}`); console.log(` package.json version: ${packageJson.version}`); console.log(' Consider updating versions to match'); } else { console.log('✅ Version consistency check passed'); } console.log(''); console.log('🎉 .dxt package creation complete!'); console.log(''); console.log('📤 Next Steps:'); console.log('1. Test installation: Load .dxt in Claude Desktop'); console.log('2. Upload to releases: Include in GitHub release'); console.log('3. Documentation: Update README with .dxt instructions'); console.log('4. Submit to directory: Claude Desktop Extension Directory (when available)'); } catch (error) { console.error('❌ .dxt package creation failed:', error.message); process.exit(1); } } // Main execution if (require.main === module) { createDxtPackage(); } module.exports = { createDxtPackage };