-
Notifications
You must be signed in to change notification settings - Fork 21
feat: add connections management #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,4 @@ | ||
| { | ||
| "$schema": "https://glama.ai/mcp/schemas/server.json", | ||
| "maintainers": [ | ||
| "gyaneshgouraw-okta", | ||
| "kushalshit27" | ||
| ] | ||
| } | ||
| "maintainers": ["gyaneshgouraw-okta", "kushalshit27"] | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,342 @@ | ||||||||||||||||||||||||||
| import { ConnectionCreateStrategyEnum, type ConnectionCreate, type ConnectionUpdate } from 'auth0'; | ||||||||||||||||||||||||||
| import type { HandlerConfig, HandlerRequest, HandlerResponse, Tool } from '../utils/types.js'; | ||||||||||||||||||||||||||
| import { log } from '../utils/logger.js'; | ||||||||||||||||||||||||||
| import { createErrorResponse, createSuccessResponse } from '../utils/http-utility.js'; | ||||||||||||||||||||||||||
| import type { Auth0Config } from '../utils/config.js'; | ||||||||||||||||||||||||||
| import { getManagementClient } from '../utils/management-client.js'; | ||||||||||||||||||||||||||
| import { Type, type Static } from '@sinclair/typebox'; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Define TypeBox schemas for each tool's input | ||||||||||||||||||||||||||
| const ListConnectionsInputSchema = Type.Object({ | ||||||||||||||||||||||||||
| page: Type.Optional(Type.Number({ description: 'Page number (0-based)' })), | ||||||||||||||||||||||||||
| per_page: Type.Optional(Type.Number({ description: 'Number of connections per page' })), | ||||||||||||||||||||||||||
| include_totals: Type.Optional(Type.Boolean({ description: 'Include total count' })), | ||||||||||||||||||||||||||
| name: Type.Optional(Type.String({ description: 'Filter by connection name' })), | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const GetConnectionInputSchema = Type.Object({ | ||||||||||||||||||||||||||
| id: Type.String({ description: 'ID of the connection to retrieve' }), | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const CreateConnectionInputSchema = Type.Object({ | ||||||||||||||||||||||||||
| name: Type.String({ description: 'Name of the connection. Required.' }), | ||||||||||||||||||||||||||
| strategy: Type.Union( | ||||||||||||||||||||||||||
| Object.values(ConnectionCreateStrategyEnum).map((v) => Type.Literal(v)), | ||||||||||||||||||||||||||
| { description: 'Strategy of the connection. Required.' } | ||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||
| options: Type.Optional( | ||||||||||||||||||||||||||
| Type.Any({ description: 'Strategy-specific options for the connection.' }) | ||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||
| enabled_clients: Type.Optional( | ||||||||||||||||||||||||||
| Type.Array(Type.String(), { description: 'A list of client IDs to enable for the connection.' }) | ||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const UpdateConnectionInputSchema = Type.Object({ | ||||||||||||||||||||||||||
| id: Type.String({ description: 'ID of the connection to update. Required.' }), | ||||||||||||||||||||||||||
| options: Type.Optional( | ||||||||||||||||||||||||||
| Type.Any({ description: 'Strategy-specific options for the connection.' }) | ||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||
| enabled_clients: Type.Optional( | ||||||||||||||||||||||||||
| Type.Array(Type.String(), { description: 'A list of client IDs to enable for the connection.' }) | ||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const DeleteConnectionInputSchema = Type.Object({ | ||||||||||||||||||||||||||
| id: Type.String({ description: 'ID of the connection to delete' }), | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Define all available connection tools | ||||||||||||||||||||||||||
| export const CONNECTION_TOOLS: Tool[] = [ | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| name: 'auth0_list_connections', | ||||||||||||||||||||||||||
| description: 'List all connections in the Auth0 tenant', | ||||||||||||||||||||||||||
| inputSchema: ListConnectionsInputSchema, | ||||||||||||||||||||||||||
| _meta: { requiredScopes: ['read:connections'], readOnly: true }, | ||||||||||||||||||||||||||
| annotations: { | ||||||||||||||||||||||||||
| title: 'List Auth0 Connections', | ||||||||||||||||||||||||||
| readOnlyHint: true, | ||||||||||||||||||||||||||
| destructiveHint: false, | ||||||||||||||||||||||||||
| idempotentHint: true, | ||||||||||||||||||||||||||
| openWorldHint: false, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| name: 'auth0_get_connection', | ||||||||||||||||||||||||||
| description: 'Get details about a specific Auth0 connection', | ||||||||||||||||||||||||||
| inputSchema: GetConnectionInputSchema, | ||||||||||||||||||||||||||
| _meta: { requiredScopes: ['read:connections'], readOnly: true }, | ||||||||||||||||||||||||||
| annotations: { | ||||||||||||||||||||||||||
| title: 'Get Auth0 Connection Details', | ||||||||||||||||||||||||||
| readOnlyHint: true, | ||||||||||||||||||||||||||
| destructiveHint: false, | ||||||||||||||||||||||||||
| idempotentHint: true, | ||||||||||||||||||||||||||
| openWorldHint: false, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| name: 'auth0_create_connection', | ||||||||||||||||||||||||||
| description: 'Create a new Auth0 connection', | ||||||||||||||||||||||||||
| inputSchema: CreateConnectionInputSchema, | ||||||||||||||||||||||||||
| _meta: { requiredScopes: ['create:connections'] }, | ||||||||||||||||||||||||||
| annotations: { | ||||||||||||||||||||||||||
| title: 'Create Auth0 Connection', | ||||||||||||||||||||||||||
| readOnlyHint: false, | ||||||||||||||||||||||||||
| destructiveHint: false, | ||||||||||||||||||||||||||
| idempotentHint: false, | ||||||||||||||||||||||||||
| openWorldHint: false, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| name: 'auth0_update_connection', | ||||||||||||||||||||||||||
| description: 'Update an existing Auth0 connection', | ||||||||||||||||||||||||||
| inputSchema: UpdateConnectionInputSchema, | ||||||||||||||||||||||||||
| _meta: { requiredScopes: ['update:connections'] }, | ||||||||||||||||||||||||||
| annotations: { | ||||||||||||||||||||||||||
| title: 'Update Auth0 Connection', | ||||||||||||||||||||||||||
| readOnlyHint: false, | ||||||||||||||||||||||||||
| destructiveHint: true, | ||||||||||||||||||||||||||
| idempotentHint: true, | ||||||||||||||||||||||||||
| openWorldHint: false, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| name: 'auth0_delete_connection', | ||||||||||||||||||||||||||
| description: 'Delete an Auth0 connection', | ||||||||||||||||||||||||||
| inputSchema: DeleteConnectionInputSchema, | ||||||||||||||||||||||||||
| _meta: { requiredScopes: ['delete:connections'] }, | ||||||||||||||||||||||||||
| annotations: { | ||||||||||||||||||||||||||
| title: 'Delete Auth0 Connection', | ||||||||||||||||||||||||||
| readOnlyHint: false, | ||||||||||||||||||||||||||
| destructiveHint: true, | ||||||||||||||||||||||||||
| idempotentHint: false, | ||||||||||||||||||||||||||
| openWorldHint: false, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| export const CONNECTION_HANDLERS: Record< | ||||||||||||||||||||||||||
| string, | ||||||||||||||||||||||||||
| (request: HandlerRequest<any>, config: HandlerConfig) => Promise<HandlerResponse> | ||||||||||||||||||||||||||
| > = { | ||||||||||||||||||||||||||
| auth0_list_connections: async ( | ||||||||||||||||||||||||||
| request: HandlerRequest<Static<typeof ListConnectionsInputSchema>>, | ||||||||||||||||||||||||||
| config: HandlerConfig | ||||||||||||||||||||||||||
| ): Promise<HandlerResponse> => { | ||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||
| if (!request.token) { | ||||||||||||||||||||||||||
| log('Warning: Token is missing'); | ||||||||||||||||||||||||||
| return createErrorResponse('Error: Missing authorization token'); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| if (!config.domain) { | ||||||||||||||||||||||||||
| log('Error: Auth0 domain is not configured'); | ||||||||||||||||||||||||||
| return createErrorResponse('Error: Auth0 domain is not configured'); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+127
to
+134
|
||||||||||||||||||||||||||
| if (!request.token) { | |
| log('Warning: Token is missing'); | |
| return createErrorResponse('Error: Missing authorization token'); | |
| } | |
| if (!config.domain) { | |
| log('Error: Auth0 domain is not configured'); | |
| return createErrorResponse('Error: Auth0 domain is not configured'); | |
| } | |
| const validationError = validateRequestAndConfig(request, config); | |
| if (validationError) { | |
| return validationError; | |
| } |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
We are considering Zod over TypeBox #4 (draft).
For validation, TypeBox needs an external validator like Ajv , but zod has Built-in validation. Do you see any performance gain using TypeBox?
Let me know if you have any questions. Looking forward to your updates!