@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
59 lines • 2.22 kB
JavaScript
import { ACTION_HANDLERS, ACTION_TOOLS } from './actions.js';
import { APPLICATION_HANDLERS, APPLICATION_TOOLS } from './applications.js';
import { APPLICATION_GRANTS_HANDLERS, APPLICATION_GRANTS_TOOLS } from './application-grants.js';
import { FORM_HANDLERS, FORM_TOOLS } from './forms.js';
import { LOG_HANDLERS, LOG_TOOLS } from './logs.js';
import { ONBOARDING_HANDLERS, ONBOARDING_TOOLS } from './onboarding.js';
import { QUICKSTART_HANDLERS, QUICKSTART_TOOLS } from './quickstarts.js';
import { RESOURCE_SERVER_HANDLERS, RESOURCE_SERVER_TOOLS } from './resource-servers.js';
import trackEvent from '../utils/analytics.js';
// Combine all tools into a single array
export const TOOLS = [
...APPLICATION_TOOLS,
...RESOURCE_SERVER_TOOLS,
...ACTION_TOOLS,
...LOG_TOOLS,
...FORM_TOOLS,
...APPLICATION_GRANTS_TOOLS,
...ONBOARDING_TOOLS,
...QUICKSTART_TOOLS,
];
// Collect all handlers
const allHandlers = {
...APPLICATION_HANDLERS,
...RESOURCE_SERVER_HANDLERS,
...ACTION_HANDLERS,
...LOG_HANDLERS,
...FORM_HANDLERS,
...APPLICATION_GRANTS_HANDLERS,
...ONBOARDING_HANDLERS,
...QUICKSTART_HANDLERS,
};
/**
* Create handlers with analytics tracking
*/
const createHandlersWithAnalytics = () => {
const wrappedHandlers = {};
// Add analytics tracking to each handler
for (const [name, handler] of Object.entries(allHandlers)) {
wrappedHandlers[name] = async (request, config) => {
try {
// Execute the original handler
const result = await handler(request, config);
// Track the tool usage. Handlers signal failure by returning a response
// with isError set rather than throwing, so treat those as failures too.
trackEvent.trackTool(name, !result?.isError);
return result;
}
catch (error) {
// Track exception cases
trackEvent.trackTool(name, false);
throw error;
}
};
}
return wrappedHandlers;
};
// Export handlers with analytics tracking
export const HANDLERS = createHandlersWithAnalytics();
//# sourceMappingURL=index.js.map