mirror of
https://github.com/hanzoai/mcp.git
synced 2026-10-15 12:30:12 +00:00
- Created complete landing page with @hanzo/ui components - Demonstrates ui tool's ability to compose complex UIs - Includes hero, features, testimonials, pricing, and CTA sections - Production-ready code with animations and dark theme - Validates dev agent can use ui tool effectively - Comprehensive testing suite for all UI tool methods - Matrix test report showing 80% success rate
146 lines
4.8 KiB
JavaScript
Executable File
146 lines
4.8 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
/**
|
|
* MATRIX TEST SUITE FOR INDIVIDUAL UI TOOLS
|
|
* Testing all UI tools with maximum parallel execution
|
|
*/
|
|
|
|
import { createMCPServer } from './dist/index.js';
|
|
|
|
const uiToolTests = [
|
|
{ name: 'ui_list_components', args: {} },
|
|
{ name: 'ui_search_components', args: { query: 'button' } },
|
|
{ name: 'ui_get_component', args: { name: 'button' } },
|
|
{ name: 'ui_list_blocks', args: {} },
|
|
{ name: 'ui_get_block', args: { name: 'sidebar-01' } },
|
|
{ name: 'ui_get_registry', args: {} },
|
|
{ name: 'ui_fetch_component', args: { name: 'button', framework: 'react' } },
|
|
{ name: 'ui_fetch_demo', args: { name: 'button' } },
|
|
{ name: 'ui_component_metadata', args: { name: 'button' } },
|
|
{ name: 'ui_github_rate_limit', args: {} }
|
|
];
|
|
|
|
async function testIndividualUITools() {
|
|
console.log('š“š ENTERING THE MATRIX - INDIVIDUAL UI TOOLS TEST\n');
|
|
console.log('ā” Testing parallel execution of all UI tools...\n');
|
|
|
|
try {
|
|
// Create server with default configuration
|
|
const server = await createMCPServer({
|
|
name: 'test-hanzo-mcp',
|
|
version: '1.0.0'
|
|
});
|
|
|
|
console.log(`ā
Server created with ${server.tools.length} tools\n`);
|
|
|
|
// Get all UI tools
|
|
const uiTools = server.tools.filter(t => t.name.startsWith('ui_'));
|
|
console.log(`šÆ Found ${uiTools.length} UI tools\n`);
|
|
|
|
// Execute all UI tool tests in parallel
|
|
const startTime = Date.now();
|
|
const results = await Promise.allSettled(
|
|
uiToolTests.map(async (test, index) => {
|
|
const tool = server.tools.find(t => t.name === test.name);
|
|
if (!tool) {
|
|
return {
|
|
index,
|
|
name: test.name,
|
|
success: false,
|
|
error: 'Tool not found',
|
|
duration: 0
|
|
};
|
|
}
|
|
|
|
const start = Date.now();
|
|
try {
|
|
const result = await tool.handler(test.args);
|
|
const duration = Date.now() - start;
|
|
return {
|
|
index,
|
|
name: test.name,
|
|
success: !result.isError,
|
|
duration,
|
|
outputLength: result.content?.[0]?.text?.length || 0
|
|
};
|
|
} catch (error) {
|
|
return {
|
|
index,
|
|
name: test.name,
|
|
success: false,
|
|
duration: Date.now() - start,
|
|
error: error.message
|
|
};
|
|
}
|
|
})
|
|
);
|
|
|
|
const totalDuration = Date.now() - startTime;
|
|
|
|
// Display results matrix style
|
|
console.log('š TEST RESULTS MATRIX:\n');
|
|
console.log('=' .repeat(70));
|
|
console.log('Tool Name | Status | Time(ms) | Output');
|
|
console.log('-' .repeat(70));
|
|
|
|
results.forEach((result) => {
|
|
if (result.status === 'fulfilled') {
|
|
const r = result.value;
|
|
const status = r.success ? 'ā
' : 'ā';
|
|
const name = r.name.padEnd(32);
|
|
const time = String(r.duration).padEnd(8);
|
|
const output = r.outputLength ? `${r.outputLength} chars` : r.error || 'No output';
|
|
console.log(`${name} | ${status} | ${time} | ${output}`);
|
|
}
|
|
});
|
|
|
|
console.log('=' .repeat(70));
|
|
|
|
// Statistics
|
|
const successCount = results.filter(r =>
|
|
r.status === 'fulfilled' && r.value.success
|
|
).length;
|
|
|
|
console.log('\nš PERFORMANCE METRICS:');
|
|
console.log(`āā Total tools tested: ${uiToolTests.length}`);
|
|
console.log(`āā Successful: ${successCount} (${Math.round(successCount * 100 / uiToolTests.length)}%)`);
|
|
console.log(`āā Failed: ${uiToolTests.length - successCount}`);
|
|
console.log(`āā Total execution time: ${totalDuration}ms`);
|
|
console.log(`āā Average per tool: ${Math.round(totalDuration / uiToolTests.length)}ms`);
|
|
|
|
// Test framework-specific tools
|
|
console.log('\nš FRAMEWORK SWITCHING TESTS:');
|
|
const frameworks = ['react', 'vue', 'svelte', 'native'];
|
|
|
|
const frameworkResults = await Promise.allSettled(
|
|
frameworks.map(async fw => {
|
|
const tool = server.tools.find(t => t.name === 'ui_fetch_component');
|
|
if (!tool) return { framework: fw, success: false, error: 'Tool not found' };
|
|
|
|
try {
|
|
const result = await tool.handler({ name: 'button', framework: fw });
|
|
return { framework: fw, success: !result.isError };
|
|
} catch (error) {
|
|
return { framework: fw, success: false, error: error.message };
|
|
}
|
|
})
|
|
);
|
|
|
|
frameworkResults.forEach(r => {
|
|
if (r.status === 'fulfilled') {
|
|
const result = r.value;
|
|
const status = result.success ? 'ā
' : 'ā';
|
|
console.log(`${status} Framework: ${result.framework}`);
|
|
}
|
|
});
|
|
|
|
console.log('\nš MATRIX TEST COMPLETE - REALITY VALIDATED');
|
|
|
|
} catch (error) {
|
|
console.error('ā Fatal matrix error:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
// Execute the test
|
|
testIndividualUITools(); |