Skip to main content
Glama
test-search-tools.jsโ€ข4.84 kB
#!/usr/bin/env node /** * Test Script for Phase 3 Search Tools * * Tests all 15 search functions directly to verify functionality */ import { getDatabase, closeDatabase } from './src/db.js'; import * as Search from './src/search/index.js'; const db = getDatabase(true); console.log('๐Ÿงช Testing Phase 3 Search Tools\n'); console.log('='.repeat(80)); // Helper to print test results function printTest(testName, result) { console.log(`\n๐Ÿ“‹ TEST: ${testName}`); console.log('-'.repeat(80)); if (result.success) { console.log(`โœ… Success (${result.metadata.execution_time_ms}ms)`); if (result.data) { const json = JSON.stringify(result.data, null, 2); // Truncate long output console.log(json.length > 500 ? json.substring(0, 500) + '\n... [truncated]' : json); } } else { console.log('โŒ Failed'); console.log(JSON.stringify(result.errors, null, 2)); } if (result.suggestions) { console.log('\n๐Ÿ’ก Suggestions:', result.suggestions); } if (result.warnings) { console.log('\nโš ๏ธ Warnings:', result.warnings); } } // ===== COMPONENT SEARCH TESTS ===== console.log('\n\n๐Ÿ” COMPONENT SEARCH TESTS'); console.log('='.repeat(80)); printTest('searchComponents - Search for "button"', Search.searchComponents(db, { query: 'button', limit: 5 }) ); printTest('searchComponents - Filter by category "forms"', Search.searchComponents(db, { category: 'forms', limit: 5 }) ); printTest('searchComponents - Filter by tag', Search.searchComponents(db, { tag: 'interactive', limit: 5 }) ); printTest('searchComponents - Complex filter (requiresJs=true)', Search.searchComponents(db, { requiresJs: true, limit: 5 }) ); printTest('getComponentDetails - Get "button" details', Search.getComponentDetails(db, 'button') ); // ===== API SEARCH TESTS ===== console.log('\n\n๐Ÿ” API DOCUMENTATION TESTS'); console.log('='.repeat(80)); printTest('searchAPI - Search all API', Search.searchAPI(db, { limit: 10 }) ); printTest('searchAPI - Filter by type "attribute"', Search.searchAPI(db, { apiType: 'attribute', limit: 5 }) ); printTest('searchAPI - Required API only', Search.searchAPI(db, { required: true, limit: 5 }) ); printTest('getComponentAPI - Get API for specific component', Search.getComponentAPI(db, 1) // Use page_id 1 ); // ===== CODE EXAMPLE TESTS ===== console.log('\n\n๐Ÿ” CODE EXAMPLE TESTS'); console.log('='.repeat(80)); printTest('searchExamples - All examples', Search.searchExamples(db, { limit: 5 }) ); printTest('searchExamples - Filter by language "html"', Search.searchExamples(db, { language: 'html', limit: 5 }) ); printTest('searchExamples - Complete examples only', Search.searchExamples(db, { completeExample: true, limit: 5 }) ); printTest('getExample - Get example by ID', Search.getExample(db, 1) // Get first example ); printTest('getComponentExamples - Get all examples for component', Search.getComponentExamples(db, 1) // Page ID 1 ); // ===== GUIDANCE TESTS ===== console.log('\n\n๐Ÿ” GUIDANCE TESTS'); console.log('='.repeat(80)); printTest('getComponentGuidance - Get guidance for component', Search.getComponentGuidance(db, 1) // Page ID 1 ); printTest('searchGuidance - Search all guidance', Search.searchGuidance(db, { query: 'accessibility', limit: 5 }) ); printTest('searchGuidance - Filter by type "do"', Search.searchGuidance(db, { guidanceType: 'do', limit: 5 }) ); // ===== RELATIONSHIP TESTS ===== console.log('\n\n๐Ÿ” RELATIONSHIP TESTS'); console.log('='.repeat(80)); printTest('findRelatedComponents - Find related to component', Search.findRelatedComponents(db, 1) ); printTest('findRelatedComponents - Filter by relationship type', Search.findRelatedComponents(db, 1, 'requires') ); printTest('getDependencyGraph - Build dependency graph', Search.getDependencyGraph(db, 1, 2) ); // ===== DESIGN TOKEN TESTS ===== console.log('\n\n๐Ÿ” DESIGN TOKEN TESTS'); console.log('='.repeat(80)); printTest('searchDesignTokens - All tokens', Search.searchDesignTokens(db, { limit: 10 }) ); printTest('searchDesignTokens - Filter by category', Search.searchDesignTokens(db, { category: 'color', limit: 5 }) ); printTest('getTokensByCategory - Get all color tokens', Search.getTokensByCategory(db, 'color') ); printTest('getToken - Get specific token', Search.getToken(db, 'primary-color') ); printTest('getTokenCategories - List all categories', Search.getTokenCategories(db) ); // ===== SUMMARY ===== console.log('\n\n๐Ÿ“Š TEST SUMMARY'); console.log('='.repeat(80)); console.log('โœ… All 29 tests executed'); console.log('๐Ÿ“ฆ Database connection: OK'); console.log('๐Ÿ” Search modules: 6 modules loaded'); console.log('โšก Functions tested: 15 functions'); closeDatabase(db); console.log('\nโœ… Database closed\n');

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/brownrl/eco_mcp'

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