Skip to main content
Glama
simple-accessibility-test.jsโ€ข4.25 kB
import { spawn } from 'child_process'; /** * Simple accessibility test to verify basic functionality */ class SimpleAccessibilityTest { constructor() { this.server = null; } async start_server() { console.log('๐Ÿš€ Starting MCP server...'); this.server = spawn('bun', ['server.js'], { stdio: ['pipe', 'pipe', 'pipe'], cwd: process.cwd(), }); // Wait for server to be ready await new Promise((resolve, reject) => { const timeout = setTimeout(() => { reject(new Error('Server startup timeout')); }, 15000); this.server.stderr.on('data', (data) => { const output = data.toString(); console.log('Server output:', output); if (output.includes('server started successfully')) { clearTimeout(timeout); resolve(); } }); this.server.on('error', (error) => { clearTimeout(timeout); reject(error); }); }); console.log('โœ… Server started successfully'); } async test_simple_html() { console.log('\\n๐Ÿงช Testing: Simple HTML Accessibility'); const simple_html = ` <!DOCTYPE html> <html> <head> <title>Test</title> </head> <body> <img src="test.jpg"> <button>Click me</button> </body> </html>`; const request = { jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'check_accessibility', arguments: { code: simple_html, filename: 'test.html', standard: 'AA', environment: 'production', }, }, }; try { const response = await this.send_request(request); console.log('โœ… Accessibility check response received'); console.log('Response:', response.result.content[0].text.substring(0, 1000)); } catch (error) { console.error('โŒ Error:', error.message); } } async test_simple_jsx() { console.log('\\n๐Ÿงช Testing: Simple JSX Accessibility'); const simple_jsx = ` import React from 'react'; function TestComponent() { return ( <div> <img src="test.jpg" /> <button>Click me</button> </div> ); } export default TestComponent;`; const request = { jsonrpc: '2.0', id: 2, method: 'tools/call', params: { name: 'check_accessibility', arguments: { code: simple_jsx, filename: 'test.jsx', standard: 'AA', environment: 'production', }, }, }; try { const response = await this.send_request(request); console.log('โœ… JSX accessibility check response received'); console.log('Response:', response.result.content[0].text.substring(0, 1000)); } catch (error) { console.error('โŒ Error:', error.message); } } async send_request(request) { return new Promise((resolve, reject) => { const timeout = setTimeout(() => { reject(new Error('Request timeout')); }, 10000); const response_handler = (data) => { clearTimeout(timeout); try { const response = JSON.parse(data.toString()); resolve(response); } catch (error) { console.log('Raw response:', data.toString()); reject(new Error('Invalid JSON response: ' + error.message)); } }; this.server.stdout.once('data', response_handler); this.server.stdin.write(JSON.stringify(request) + '\\n'); }); } async stop_server() { if (this.server) { this.server.kill(); console.log('๐Ÿ›‘ Server stopped'); } } async run() { try { await this.start_server(); await this.test_simple_html(); await this.test_simple_jsx(); console.log('\\n๐ŸŽ‰ Simple accessibility tests completed!'); } catch (error) { console.error('โŒ Test failed:', error.message); console.error('Stack trace:', error.stack); } finally { await this.stop_server(); } } } // Run the test async function main() { console.log('๐Ÿงช Starting Simple Accessibility Test'); console.log('=' .repeat(50)); const test = new SimpleAccessibilityTest(); await test.run(); } main().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