Skip to main content
Glama

Tracxn MCP Server

by pHequals7
test-api.js2.76 kB
const axios = require('axios'); const dotenv = require('dotenv'); dotenv.config(); async function testTracxnAPI() { console.log('--- Starting Tracxn API Test ---'); const apiKey = process.env.TRACXN_API_KEY; if (!apiKey) { console.error('❌ FATAL: TRACXN_API_KEY environment variable is not set or not loaded.'); console.log('Please ensure you have a .env file in the tracxn-mcp/ directory with TRACXN_API_KEY=your_key'); return; } console.log('✅ TRACXN_API_KEY loaded from .env file.'); // console.log(` (Value starts with: "${apiKey.substring(0, 4)}...")`); // Uncomment for more debugging const configs = [ { name: 'Bearer Token Auth', headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json', 'Accept': 'application/json', } }, { name: 'Simple Token Auth', headers: { 'Authorization': apiKey, 'Content-Type': 'application/json', 'Accept': 'application/json', } } ]; for (const config of configs) { console.log(`\n--- Testing with: ${config.name} ---`); const client = axios.create({ baseURL: 'https://platform.tracxn.com/api/2.2/playground', headers: config.headers, }); try { console.log('Making test request to /companies...'); const response = await client.get('/companies'); console.log('✅ API connection successful!'); console.log('Response status:', response.status); console.log('Response data preview:', JSON.stringify(response.data, null, 2).substring(0, 300) + '...'); console.log('--- Test Passed ---'); return; // Exit after first success } catch (error) { console.error('❌ API connection failed:'); console.error('Error message:', error.message); if (error.response) { console.error('Response status:', error.response.status); if (typeof error.response.data === 'string' && error.response.data.includes('<!DOCTYPE html>')) { console.error('❌ Received HTML login page instead of JSON response.'); console.error('This indicates authentication failure.'); } else { console.error('Response data:', JSON.stringify(error.response.data, null, 2)); } } console.log('--- Test Failed ---'); } } console.log('\nBoth authentication methods failed. Please check the following:'); console.log('1. Your API key in the .env file is exactly correct and has no extra spaces or characters.'); console.log('2. The API key is for the Playground environment, not Production.'); console.log('3. You have saved the .env file in the root of the `tracxn-mcp` directory.'); } testTracxnAPI();

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/pHequals7/tracxn-mcp'

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