@auth0/auth0-mcp-server
Version:
Auth0 Model Context Protocol (MCP) Server (Beta) — A secure and extendable implementation of an MCP server that provides AI assistants with controlled access to the Auth0 Management API through natural language. This project is in beta and not intended fo
68 lines • 2.17 kB
JavaScript
// Add network error handling utility
export function handleNetworkError(error) {
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) {
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) {
// 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) {
return {
content: [
{
type: 'text',
text: errorString,
},
],
isError: true,
};
}
//# sourceMappingURL=http-utility.js.map