Skip to main content
Glama
http-utility.ts2.03 kB
import { HandlerResponse } from './types'; // Add network error handling utility export function handleNetworkError(error: any): string { if (error.name === 'AbortError') { return 'request timed out. The Auth0 API did not respond in time.'; } else if (error instanceof TypeError) { return `network error: ${error.message || 'Failed to connect'}`; } else if (error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED') { return `Connection failed: Unable to reach the Auth0 API (${error.code}). Check your network connection.`; } else if (error.code === 'ECONNRESET') { return 'Connection was reset by the server. Try again later.'; } else { return `Error: ${error.message || error}`; } } // Helper function to ensure domain is properly formatted export function formatDomain(domain: string): string { if (!domain) return ''; // Remove protocol (http:// or https://) let formattedDomain = domain.replace(/^https?:\/\//, ''); // Remove trailing slash formattedDomain = formattedDomain.replace(/\/$/, ''); return formattedDomain.includes('.') ? formattedDomain : `${formattedDomain}.us.auth0.com`; } // Helper function to create success response export function createSuccessResponse(result: object | Array<any>): HandlerResponse { // Check if result is an array and has more than one item if (Array.isArray(result) && result.length > 1) { const mutiContent = result.map((item) => { return { type: 'text', text: JSON.stringify(item, null, 2), }; }); return { content: mutiContent, isError: false, }; } else { return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], isError: false, }; } } // Helper function to create error response export function createErrorResponse(errorString: string): HandlerResponse { return { content: [ { type: 'text', text: errorString, }, ], isError: true, }; }

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/auth0/auth0-mcp-server'

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