Skip to main content
Glama
direct-audit-test.js•5.24 kB
#!/usr/bin/env bun // Direct test of moidvk tools without MCP protocol import { handleCodePractices } from '../lib/tools/code-practices.js'; import { handleProductionReadiness } from '../lib/tools/production-readiness.js'; import { handleSafetyChecker } from '../lib/tools/safety-checker.js'; import { handleAccessibilityChecker } from '../lib/tools/accessibility-checker.js'; import { handleSecurityScanner } from '../lib/tools/security-scanner.js'; async function runDirectAudit() { console.log('šŸ” Running Direct moidvk Audit\n'); console.log('='.repeat(80)); // Test 1: check_code_practices on server.js console.log('\n1ļøāƒ£ CODE PRACTICES CHECK'); console.log('-'.repeat(80)); try { const codePracticesResult = await handleCodePractices({ code: `import { Server } from '@modelcontextprotocol/sdk/server/index.js'; // Error handling with console.error server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { switch (name) { case 'check_code_practices': return await handleCodePractices(args); default: throw new Error(\`Unknown tool: \${name}\`); } } catch (error) { console.error(\`Error in tool \${name}:\`, error); return { content: [{ type: 'text', text: \`āŒ Error: Failed to execute tool "\${name}". Please check your input and try again.\`, }], }; } });`, filename: 'server.js' }); console.log(codePracticesResult.content[0].text); } catch (error) { console.error('Error:', error.message); } // Test 2: check_production_readiness with strict=true console.log('\n\n2ļøāƒ£ PRODUCTION READINESS CHECK (strict mode)'); console.log('-'.repeat(80)); try { const productionResult = await handleProductionReadiness({ code: `// Sample production code const server = new Server({ name: 'moidvk' }); // Has console.error statements process.on('SIGINT', async () => { console.error('Shutting down moidvk server...'); await server.close(); process.exit(0); }); main().catch(error => { console.error('Fatal error:', error); process.exit(1); }); // Also has debugger statement debugger; // And TODO comments // TODO: Fix this later`, filename: 'server.js', strict: true }); console.log(productionResult.content[0].text); } catch (error) { console.error('Error:', error.message); } // Test 3: check_safety_rules on RateLimiter console.log('\n\n3ļøāƒ£ SAFETY RULES CHECK'); console.log('-'.repeat(80)); try { const safetyResult = await handleSafetyChecker({ code: `export class RateLimiter { constructor(config = {}) { this.maxRequests = config.maxRequests || 100; this.windowMs = config.windowMs || 60000; this.requests = new Map(); } checkLimit(identifier) { const now = Date.now(); const userRequests = this.requests.get(identifier) || []; // Clean old requests const validRequests = userRequests.filter(time => now - time < this.windowMs); if (validRequests.length >= this.maxRequests) { return false; } validRequests.push(now); this.requests.set(identifier, validRequests); return true; } reset(identifier) { this.requests.delete(identifier); } }`, filename: 'RateLimiter.js' }); console.log(safetyResult.content[0].text); } catch (error) { console.error('Error:', error.message); } // Test 4: check_accessibility on HTML console.log('\n\n4ļøāƒ£ ACCESSIBILITY CHECK (HTML file support)'); console.log('-'.repeat(80)); try { const accessibilityResult = await handleAccessibilityChecker({ code: `<div class="container"> <h1>Security Audit Report</h1> <p>This is a sample HTML page for accessibility testing.</p> <button onclick="alert('test')">Click me</button> <img src="test.jpg" alt="Test image"> <img src="no-alt.jpg"> <div onclick="doSomething()">Clickable div without role</div> <form> <input type="text" placeholder="Enter name"> <button type="submit">Submit</button> </form> </div>`, filename: 'test.html' }); console.log(accessibilityResult.content[0].text); } catch (error) { console.error('Error:', error.message); } // Test 5: scan_security_vulnerabilities console.log('\n\n5ļøāƒ£ SECURITY VULNERABILITY SCAN'); console.log('-'.repeat(80)); try { const securityResult = await handleSecurityScanner({ format: 'summary', includeTests: false }); console.log(securityResult.content[0].text); } catch (error) { console.error('Error:', error.message); } console.log('\n\n' + '='.repeat(80)); console.log('āœ… AUDIT COMPLETE'); console.log('='.repeat(80)); console.log('\nKey Findings:'); console.log('- Code practices tool: Working'); console.log('- Production readiness with strict mode: Working'); console.log('- Safety rules checker: Working'); console.log('- Accessibility checker with HTML support: Working'); console.log('- Security vulnerability scanner: Working'); console.log('\nAll tools are functioning correctly!'); } // Run the audit runDirectAudit().catch(console.error);

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/moikas-code/moidvk'

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