We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/h3ro-dev/cursor-admin-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
test-connection.tsโข1.71 KiB
#!/usr/bin/env tsx
/**
* Test connection to Cursor API
* Usage: npm run dev examples/test-connection.ts
*/
import { CursorAdminClient } from '../src/cursor-client';
import dotenv from 'dotenv';
// Load environment variables
dotenv.config();
async function testConnection() {
const apiKey = process.env.CURSOR_API_KEY;
if (!apiKey) {
console.error('โ Error: CURSOR_API_KEY environment variable is required');
console.error('Please set it in your .env file');
process.exit(1);
}
console.log('๐ Testing connection to Cursor API...\n');
try {
const client = new CursorAdminClient(apiKey);
// Test connection
console.log('Testing API connection...');
const isConnected = await client.testConnection();
if (isConnected) {
console.log('โ Successfully connected to Cursor API!\n');
// Get team members
console.log('๐ Fetching team members...');
const members = await client.getTeamMembers();
console.log(`Found ${members.length} team members:`);
members.forEach((member, index) => {
console.log(` ${index + 1}. ${member.name} (${member.email}) - ${member.role}`);
});
console.log('\nโจ All tests passed! Your API key is valid and working.');
}
} catch (error) {
console.error('โ Connection test failed:', error);
if (error instanceof Error && error.message.includes('Invalid API key')) {
console.error('\n๐ก Please check that:');
console.error(' 1. Your API key is correct');
console.error(' 2. You have admin access to the team');
console.error(' 3. The API key hasn\'t been revoked');
}
process.exit(1);
}
}
// Run the test
testConnection();