Skip to main content
Glama
jakedx6
by jakedx6
test-prompt-to-project.js9.99 kB
#!/usr/bin/env node /** * Test script for the prompt-to-project MCP tool * This script tests both analyze and create modes */ import { spawn } from 'child_process'; import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); // Test configuration - you'll need to set these const HELIOS_API_URL = process.env.HELIOS_API_URL || 'https://helios9.app'; const HELIOS_API_KEY = process.env.HELIOS_API_KEY; if (!HELIOS_API_KEY) { console.error('❌ HELIOS_API_KEY environment variable is required'); console.error('Please set it to a valid Helios-9 MCP API key'); process.exit(1); } // Colors for console output const colors = { reset: '\x1b[0m', bright: '\x1b[1m', green: '\x1b[32m', yellow: '\x1b[33m', blue: '\x1b[34m', red: '\x1b[31m', cyan: '\x1b[36m' }; function log(message, color = colors.reset) { console.log(`${color}${message}${colors.reset}`); } class MCPTestClient { constructor() { this.requestId = 0; this.mcp = null; } async start() { return new Promise((resolve, reject) => { log('\n🚀 Starting MCP server...', colors.cyan); this.mcp = spawn('node', [join(__dirname, 'dist', 'index.js')], { env: { ...process.env, HELIOS_API_URL, HELIOS_API_KEY }, stdio: ['pipe', 'pipe', 'pipe'] }); this.mcp.on('error', (err) => { log(`❌ Failed to start MCP server: ${err.message}`, colors.red); reject(err); }); // Wait for server to be ready this.mcp.stdout.once('data', (data) => { log('✅ MCP server started successfully', colors.green); resolve(); }); // Log stderr for debugging this.mcp.stderr.on('data', (data) => { const message = data.toString(); if (message.includes('ERROR')) { log(`❌ Error: ${message}`, colors.red); } }); }); } async sendRequest(method, params = {}) { return new Promise((resolve, reject) => { const request = { jsonrpc: '2.0', method, params, id: ++this.requestId }; log(`\n📤 Sending request: ${method}`, colors.blue); // Send request this.mcp.stdin.write(JSON.stringify(request) + '\n'); // Set up response handler const handler = (data) => { const lines = data.toString().split('\n').filter(line => line.trim()); for (const line of lines) { try { const response = JSON.parse(line); if (response.id === request.id) { this.mcp.stdout.removeListener('data', handler); if (response.error) { log(`❌ Error response: ${JSON.stringify(response.error, null, 2)}`, colors.red); reject(new Error(response.error.message)); } else { log(`✅ Response received`, colors.green); resolve(response.result); } } } catch (e) { // Not JSON, might be debug output if (line.includes('ERROR')) { log(`Debug: ${line}`, colors.yellow); } } } }; this.mcp.stdout.on('data', handler); // Timeout after 30 seconds setTimeout(() => { this.mcp.stdout.removeListener('data', handler); reject(new Error('Request timeout')); }, 30000); }); } async callTool(toolName, args) { return this.sendRequest('tools/call', { name: toolName, arguments: args }); } async stop() { if (this.mcp) { log('\n🛑 Stopping MCP server...', colors.cyan); this.mcp.kill(); await new Promise(resolve => setTimeout(resolve, 1000)); log('✅ MCP server stopped', colors.green); } } } async function testPromptToProject() { const client = new MCPTestClient(); try { await client.start(); // Test 1: Analyze mode log('\n' + '='.repeat(60), colors.bright); log('TEST 1: ANALYZE MODE', colors.bright); log('='.repeat(60), colors.bright); const analyzeResult = await client.callTool('prompt_to_project', { prompt: 'Create a task management app with user authentication, project boards, and real-time collaboration features', execution_mode: 'analyze' }); log('\n📊 Analysis Result:', colors.cyan); const analysisData = JSON.parse(analyzeResult.content[0].text); log('\nGuidance:', colors.yellow); console.log(JSON.stringify(analysisData.guidance, null, 2)); log('\nTemplate Structure:', colors.yellow); console.log(`- Project: ${analysisData.template.project.name}`); console.log(`- Initiatives: ${analysisData.template.initiatives.length}`); console.log(`- Documents: ${analysisData.template.documents?.length || 0}`); log('\nRequirements Detected:', colors.yellow); console.log(JSON.stringify(analysisData.requirements, null, 2)); // Test 2: Create mode with a filled plan log('\n' + '='.repeat(60), colors.bright); log('TEST 2: CREATE MODE', colors.bright); log('='.repeat(60), colors.bright); const projectPlan = { project: { name: 'Task Management Platform', description: 'A comprehensive task management application with user authentication, project boards, and real-time collaboration capabilities.', status: 'active' }, initiatives: [ { name: 'User Authentication System', objective: 'Implement secure user authentication and authorization', description: 'Build a complete authentication system with registration, login, password reset, and role-based access control.', priority: 'high', status: 'active', tasks: [ { title: 'Design authentication database schema', description: 'Create database tables for users, sessions, and roles', priority: 'high', status: 'todo' }, { title: 'Implement JWT token generation', description: 'Set up JWT token creation and validation', priority: 'high', status: 'todo' }, { title: 'Create login and registration endpoints', description: 'Build API endpoints for user registration and login', priority: 'medium', status: 'todo' } ] }, { name: 'Project Board Feature', objective: 'Create interactive project boards for task management', description: 'Develop Kanban-style boards where users can create, organize, and track tasks.', priority: 'medium', status: 'planning', tasks: [ { title: 'Design board UI components', description: 'Create React components for boards, columns, and cards', priority: 'medium', status: 'todo' }, { title: 'Implement drag-and-drop functionality', description: 'Add drag-and-drop support for moving tasks between columns', priority: 'medium', status: 'todo' } ] } ], documents: [ { title: 'Technical Architecture', content: '# Technical Architecture\n\n## Overview\nThis document outlines the technical architecture of the Task Management Platform.\n\n## Technology Stack\n- Frontend: React with TypeScript\n- Backend: Node.js with Express\n- Database: PostgreSQL\n- Real-time: WebSockets\n\n## Components\n1. Authentication Service\n2. Project Management Service\n3. Real-time Collaboration Service', document_type: 'technical' } ] }; log('\n📝 Creating project with plan...', colors.cyan); const createResult = await client.callTool('prompt_to_project', { prompt: 'Create a task management app with user authentication, project boards, and real-time collaboration features', execution_mode: 'create', project_plan: projectPlan }); log('\n✨ Creation Result:', colors.green); const creationData = JSON.parse(createResult.content[0].text); if (creationData.success) { log('\n🎉 Project created successfully!', colors.green); console.log('\nCreated entities:'); console.log(`- Project: ${creationData.created.project.name} (ID: ${creationData.created.project.id})`); console.log(`- Initiatives: ${creationData.created.initiatives.length}`); creationData.created.initiatives.forEach(i => { console.log(` • ${i.name} (ID: ${i.id})`); }); console.log(`- Tasks: ${creationData.created.tasks.length}`); creationData.created.tasks.forEach(t => { console.log(` • ${t.title}`); }); console.log(`- Documents: ${creationData.created.documents.length}`); creationData.created.documents.forEach(d => { console.log(` • ${d.title} (${d.type})`); }); log(`\n${creationData.summary}`, colors.bright); } else { log('\n❌ Project creation failed', colors.red); console.log(creationData); } } catch (error) { log(`\n❌ Test failed: ${error.message}`, colors.red); console.error(error); } finally { await client.stop(); } } // Run the test log('\n🧪 Starting prompt-to-project tool test...', colors.bright); log(`API URL: ${HELIOS_API_URL}`, colors.cyan); log(`API Key: ${HELIOS_API_KEY.substring(0, 16)}...`, colors.cyan); testPromptToProject().then(() => { log('\n✅ All tests completed!', colors.green); process.exit(0); }).catch((error) => { log(`\n❌ Test suite failed: ${error.message}`, colors.red); process.exit(1); });

Latest Blog Posts

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/jakedx6/helios9-MCP-Server'

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