Skip to main content
Glama

EuConquisto Composer MCP

by rkm097git
test-direct-api-with-env.js4.31 kB
#!/usr/bin/env node /** * Test Direct API with environment file loading */ import { promises as fs } from 'fs'; import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); async function loadEnvFile() { try { const envPath = join(__dirname, 'config', 'direct-api.env'); const envContent = await fs.readFile(envPath, 'utf-8'); // Parse env file const lines = envContent.split('\n'); for (const line of lines) { // Skip comments and empty lines if (line.trim().startsWith('#') || !line.trim()) continue; // Parse KEY=VALUE const match = line.match(/^([^=]+)=(.*)$/); if (match) { const key = match[1].trim(); const value = match[2].trim().replace(/^["']|["']$/g, ''); // Remove quotes process.env[key] = value; } } console.log('✅ Environment file loaded successfully'); return true; } catch (error) { console.error('❌ Failed to load environment file:', error.message); return false; } } async function testDirectAPI() { console.log('🔍 Direct API Test with Environment File'); console.log('========================================\n'); // Load environment file const loaded = await loadEnvFile(); if (!loaded) { console.log('Please ensure config/direct-api.env exists'); return; } // Import after loading env const { DirectAPIConfig } = await import('./src/config/direct-api-config.js'); // Load configuration const configLoaded = DirectAPIConfig.loadFromEnvironment(); console.log('\n📊 Configuration Status:'); console.log(` Configuration Valid: ${configLoaded ? '✅' : '❌'}`); if (configLoaded) { const summary = DirectAPIConfig.getSummary(); console.log('\n📋 Loaded Configuration:'); console.log(` Access Token: ✅ (${summary.authentication.tokenLength} characters)`); console.log(` Token Type: ${summary.authentication.tokenType}`); console.log(` Project UID: ${DirectAPIConfig.authentication.projectUid}`); console.log(` Connectors: ${summary.authentication.connectorsCount} available`); console.log(` Selected Connector: ${summary.authentication.selectedConnector}`); // Try to make a simple test request console.log('\n🧪 Testing Direct API Connection...'); try { const testUrl = DirectAPIConfig.baseURL + '/health'; console.log(` Testing: GET ${testUrl}`); const response = await fetch(testUrl, { method: 'GET', headers: { 'Accept': 'application/json' } }); console.log(` Response: ${response.status} ${response.statusText}`); if (response.ok || response.status === 404) { console.log(' ✅ API endpoint is reachable'); } else { console.log(' ⚠️ Unexpected response status'); } } catch (error) { console.log(' ❌ Network error:', error.message); } console.log('\n✅ Direct API configuration is ready!'); console.log('🎯 The authentication data has been successfully loaded'); console.log('📌 You can now use DirectAPIClient for API operations'); // Show example usage console.log('\n📝 Example Usage:'); console.log('```javascript'); console.log('import { DirectAPIClient } from "./src/tools/direct-api-client.js";'); console.log(''); console.log('const client = new DirectAPIClient();'); console.log('const result = await client.createComposition('); console.log(' "Explain photosynthesis",'); console.log(' "Biology",'); console.log(' "7º ano"'); console.log(');'); console.log('```'); } else { console.log('\n❌ Configuration is invalid'); const status = DirectAPIConfig.getValidationStatus(); console.log(' Issues found:'); if (status.issues.missingAccessToken) console.log(' - Missing access token'); if (status.issues.missingProjectUid) console.log(' - Missing project UID'); if (status.issues.missingConnectors) console.log(' - Missing connectors'); } console.log('\n' + '='.repeat(50)); } // Run the test testDirectAPI().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/rkm097git/euconquisto-composer-mcp-poc'

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