Skip to main content
Glama
test-api-debug.js•6.13 kB
#!/usr/bin/env node /** * API Debug Test - Investigate the 500 error */ import { readFileSync } from 'fs'; import { resolve, dirname } from 'path'; import { fileURLToPath } from 'url'; const currentDir = dirname(fileURLToPath(import.meta.url)); const tokenPath = resolve(currentDir, 'correct-jwt-new.txt'); const jwtToken = readFileSync(tokenPath, 'utf8').trim(); async function debugAPI() { console.log('šŸ” API Debug Test\n'); // First, let's verify our JWT token console.log('1ļøāƒ£ JWT Token Info:'); console.log(` - Length: ${jwtToken.length} characters`); console.log(` - Starts with: ${jwtToken.substring(0, 50)}...`); console.log(` - Contains NEsta: ${jwtToken.includes('NEsta')}`); console.log(` - Contains WEJLam: ${jwtToken.includes('WEJLam')}`); // Parse JWT to check expiration try { const [header, payload, signature] = jwtToken.split('.'); const decodedPayload = JSON.parse(Buffer.from(payload, 'base64').toString()); console.log(` - Issued: ${new Date(decodedPayload.iat * 1000).toISOString()}`); console.log(` - Expires: ${new Date(decodedPayload.exp * 1000).toISOString()}`); console.log(` - Email: ${decodedPayload.email}`); console.log(` - Roles: ${decodedPayload.role.join(', ')}`); } catch (e) { console.log(' - Failed to decode JWT'); } const baseURL = "https://api.digitalpages.com.br"; const projectUID = "36c92686-c494-ec11-a22a-dc984041c95d"; // Test 1: Try search endpoint (original) console.log('\n2ļøāƒ£ Testing Search Endpoint:'); try { const searchURL = `${baseURL}/storage/v1.0/search?project_uid=${projectUID}&limit=1`; console.log(` - URL: ${searchURL}`); const searchResponse = await fetch(searchURL, { method: 'GET', headers: { 'Authorization': `Bearer ${jwtToken}`, 'User-Agent': 'EuConquisto-MCP-Debug/1.0', 'Accept': 'application/json' } }); console.log(` - Status: ${searchResponse.status} ${searchResponse.statusText}`); const searchData = await searchResponse.text(); console.log(` - Response: ${searchData}`); } catch (error) { console.log(` - Error: ${error.message}`); } // Test 2: Try without project_uid console.log('\n3ļøāƒ£ Testing Without Project UID:'); try { const simpleURL = `${baseURL}/storage/v1.0/search?limit=1`; console.log(` - URL: ${simpleURL}`); const simpleResponse = await fetch(simpleURL, { method: 'GET', headers: { 'Authorization': `Bearer ${jwtToken}`, 'User-Agent': 'EuConquisto-MCP-Debug/1.0', 'Accept': 'application/json' } }); console.log(` - Status: ${simpleResponse.status} ${simpleResponse.statusText}`); const simpleData = await simpleResponse.text(); console.log(` - Response: ${simpleData}`); } catch (error) { console.log(` - Error: ${error.message}`); } // Test 3: Try the content endpoint directly (from Claude Desktop's discovery) console.log('\n4ļøāƒ£ Testing Content Endpoint (GET):'); try { const contentURL = `${baseURL}/storage/v1.0/content?manual_project_uid=${projectUID}`; console.log(` - URL: ${contentURL}`); const contentResponse = await fetch(contentURL, { method: 'GET', headers: { 'Authorization': `Bearer ${jwtToken}`, 'User-Agent': 'EuConquisto-MCP-Debug/1.0', 'Accept': 'application/json' } }); console.log(` - Status: ${contentResponse.status} ${contentResponse.statusText}`); const contentData = await contentResponse.text(); console.log(` - Response: ${contentData.substring(0, 200)}...`); } catch (error) { console.log(` - Error: ${error.message}`); } // Test 4: Try a simple OPTIONS request to check CORS console.log('\n5ļøāƒ£ Testing OPTIONS (CORS Check):'); try { const optionsURL = `${baseURL}/storage/v1.0/content`; console.log(` - URL: ${optionsURL}`); const optionsResponse = await fetch(optionsURL, { method: 'OPTIONS', headers: { 'Origin': 'https://composer.euconquisto.com', 'Access-Control-Request-Method': 'PUT', 'Access-Control-Request-Headers': 'authorization,content-type' } }); console.log(` - Status: ${optionsResponse.status} ${optionsResponse.statusText}`); console.log(` - CORS Headers:`); console.log(` - Allow-Origin: ${optionsResponse.headers.get('access-control-allow-origin')}`); console.log(` - Allow-Methods: ${optionsResponse.headers.get('access-control-allow-methods')}`); console.log(` - Allow-Headers: ${optionsResponse.headers.get('access-control-allow-headers')}`); } catch (error) { console.log(` - Error: ${error.message}`); } // Test 5: Try to decode the actual working URL from the browser console.log('\n6ļøāƒ£ Testing Known Working Pattern:'); console.log(' - In browser, compositions are saved via:'); console.log(' PUT /storage/v1.0/content?uid={UID}&manual_project_uid={PROJECT_UID}'); console.log(' - With multipart/form-data containing composition.rdpcomposer file'); console.log(' - This suggests we need to use PUT with multipart, not GET'); console.log('\nšŸ“‹ Summary:'); console.log(' - The 500 error might be because the search endpoint expects different parameters'); console.log(' - Or the API might require specific headers/format we\'re missing'); console.log(' - The JWT token appears valid and not expired'); console.log(' - We should try the exact pattern used by the browser'); } debugAPI().catch(console.error);

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/rkm097git/euconquisto-composer-mcp-poc'

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