Skip to main content
Glama
test-connection.jsโ€ข4.9 kB
#!/usr/bin/env node /** * TestRail Connection Test Script * Tests the connection to TestRail with provided credentials */ require('dotenv').config(); const axios = require('axios'); async function testTestRailConnection() { console.log('๐Ÿงช Testing TestRail Connection...\n'); const baseUrl = process.env.TESTRAIL_BASE_URL; const username = process.env.TESTRAIL_USERNAME; const apiKey = process.env.TESTRAIL_API_KEY; console.log(`๐Ÿ“ Base URL: ${baseUrl}`); console.log(`๐Ÿ‘ค Username: ${username}`); console.log(`๐Ÿ”‘ API Key: ${apiKey ? apiKey.substring(0, 10) + '...' : 'Not set'}\n`); if (!baseUrl || !username || !apiKey) { console.error('โŒ Missing required environment variables!'); console.error('Required: TESTRAIL_BASE_URL, TESTRAIL_USERNAME, TESTRAIL_API_KEY'); process.exit(1); } try { // Test 1: Basic API connection console.log('๐Ÿ” Test 1: Testing basic API connection...'); const auth = Buffer.from(`${username}:${apiKey}`).toString('base64'); const response = await axios.get(`${baseUrl}/index.php?/api/v2/get_projects`, { headers: { 'Authorization': `Basic ${auth}`, 'Content-Type': 'application/json' }, timeout: 10000 }); console.log('โœ… Connection successful!'); console.log(`๐Ÿ“Š Found ${response.data.length} projects\n`); // Test 2: List projects console.log('๐Ÿ” Test 2: Listing available projects...'); response.data.slice(0, 5).forEach((project, index) => { console.log(` ${index + 1}. ${project.name} (ID: ${project.id}) - ${project.is_completed ? 'Completed' : 'Active'}`); }); if (response.data.length > 5) { console.log(` ... and ${response.data.length - 5} more projects`); } console.log(''); // Test 3: Get first project details if (response.data.length > 0) { const firstProject = response.data[0]; console.log('๐Ÿ” Test 3: Getting project details...'); const projectResponse = await axios.get(`${baseUrl}/index.php?/api/v2/get_project/${firstProject.id}`, { headers: { 'Authorization': `Basic ${auth}`, 'Content-Type': 'application/json' }, timeout: 10000 }); console.log(`โœ… Project "${projectResponse.data.name}" details retrieved successfully`); console.log(` - Suite Mode: ${projectResponse.data.suite_mode}`); console.log(` - Announcement: ${projectResponse.data.announcement || 'None'}`); console.log(` - Completed: ${projectResponse.data.is_completed ? 'Yes' : 'No'}\n`); } // Test 4: Test MCP tools initialization console.log('๐Ÿ” Test 4: Testing MCP tools initialization...'); // Import and test the TestRail service const { TestrailService } = require('./dist/utils/testrail-service.js'); const service = new TestrailService(); // Test the service connection const projects = await service.getProjects(); console.log(`โœ… MCP Service initialized successfully`); console.log(`๐Ÿ“ˆ MCP Service found ${projects.length} projects\n`); console.log('๐ŸŽ‰ All tests passed! TestRail MCP Server is ready for Smithery AI!'); console.log('\n๐Ÿ“‹ Summary:'); console.log(` โœ… TestRail API connection: Working`); console.log(` โœ… Authentication: Valid`); console.log(` โœ… Projects accessible: ${response.data.length}`); console.log(` โœ… MCP Service: Functional`); console.log('\n๐Ÿš€ Ready for Smithery AI tool discovery!'); } catch (error) { console.error('โŒ Connection test failed!'); if (error.response) { console.error(` Status: ${error.response.status}`); console.error(` Message: ${error.response.data?.error || error.response.statusText}`); if (error.response.status === 401) { console.error('\n๐Ÿ”‘ Authentication failed. Please check:'); console.error(' - TestRail username/email is correct'); console.error(' - API key is valid and not expired'); console.error(' - User has API access enabled in TestRail'); } else if (error.response.status === 403) { console.error('\n๐Ÿšซ Access forbidden. Please check:'); console.error(' - User has sufficient permissions'); console.error(' - Account is not locked or suspended'); } } else if (error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED') { console.error('\n๐ŸŒ Network/URL error. Please check:'); console.error(` - TestRail URL is correct: ${baseUrl}`); console.error(' - TestRail instance is accessible'); console.error(' - No firewall blocking the connection'); } else { console.error(` Error: ${error.message}`); } process.exit(1); } } // Run the test testTestRailConnection().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/samuelvinay91/testrail-mcp'

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