Skip to main content
Glama
descope-sample-apps

descope-mcp-server

Official

invite-user

Create and invite new users to a Descope project by generating invitation links and managing user details like login IDs, roles, and contact information.

Instructions

Create and invite a new user to the Descope project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
loginIdYesPrimary login identifier for the user
additionalLoginIdsNoAdditional login identifiers
emailNoUser's email address
verifiedEmailNoWhether the email is pre-verified
phoneNoUser's phone number in E.164 format
verifiedPhoneNoWhether the phone is pre-verified
displayNameNoUser's display name
givenNameNoUser's given/first name
middleNameNoUser's middle name
familyNameNoUser's family/last name
pictureNoURL to user's profile picture
rolesNoGlobal role names to assign to the user
userTenantsNoTenant associations with specific roles
ssoAppIdsNoSSO application IDs to associate
customAttributesNoCustom attributes for the user
inviteUrlNoCustom URL for the invitation link
sendMailNoSend invite via email (default follows project settings)
sendSMSNoSend invite via SMS (default follows project settings)
templateIdNoCustom template ID for the invitation
templateOptionsNoOptions for customizing the invitation template

Implementation Reference

  • Handler function that processes input parameters, constructs invite options, calls descope.management.user.invite(), and returns success or error message.
    async ({ loginId, inviteUrl, sendMail, sendSMS, templateId, templateOptions, ...userOptions }) => {
        try {
            // Define the type for invite options
            const inviteOptions: {
                inviteUrl?: string;
                sendMail?: boolean;
                sendSMS?: boolean;
                templateId?: string;
                templateOptions?: {
                    appUrl?: string;
                    redirectUrl?: string;
                    customClaims?: string;
                };
            } & typeof userOptions = {
                ...userOptions,
                inviteUrl,
                sendMail,
                sendSMS,
                templateId,
            };
    
            // Only add templateOptions if they exist and ensure customClaims is handled properly
            if (templateOptions) {
                inviteOptions.templateOptions = {
                    appUrl: templateOptions.appUrl,
                    redirectUrl: templateOptions.redirectUrl,
                };
                // Only add customClaims if it's provided
                if (templateOptions.customClaims) {
                    inviteOptions.templateOptions.customClaims = templateOptions.customClaims;
                }
            }
    
            const user = await descope.management.user.invite(loginId, inviteOptions);
    
            return {
                content: [
                    {
                        type: "text",
                        text: `Successfully invited user:\n\n${JSON.stringify(user.data, null, 2)}`,
                    },
                ],
            };
        } catch (error) {
            return {
                content: [
                    {
                        type: "text",
                        text: `Error inviting user: ${error}`,
                    },
                ],
            };
        }
    },
  • Zod schema defining all input parameters for the invite-user tool, including user details and invite-specific options.
    {
        // Basic user info
        loginId: z.string()
            .describe("Primary login identifier for the user"),
        additionalLoginIds: z.array(z.string()).optional()
            .describe("Additional login identifiers"),
        email: z.string().email().optional()
            .describe("User's email address"),
        verifiedEmail: z.boolean().optional()
            .describe("Whether the email is pre-verified"),
        phone: z.string().optional()
            .describe("User's phone number in E.164 format"),
        verifiedPhone: z.boolean().optional()
            .describe("Whether the phone is pre-verified"),
        displayName: z.string().optional()
            .describe("User's display name"),
        givenName: z.string().optional()
            .describe("User's given/first name"),
        middleName: z.string().optional()
            .describe("User's middle name"),
        familyName: z.string().optional()
            .describe("User's family/last name"),
        picture: z.string().url().optional()
            .describe("URL to user's profile picture"),
        roles: z.array(z.string()).optional()
            .describe("Global role names to assign to the user"),
        userTenants: z.array(z.object({
            tenantId: z.string(),
            roleNames: z.array(z.string()),
        })).optional()
            .describe("Tenant associations with specific roles"),
        ssoAppIds: z.array(z.string()).optional()
            .describe("SSO application IDs to associate"),
        customAttributes: z.record(z.any()).optional()
            .describe("Custom attributes for the user"),
        // Invite specific options
        inviteUrl: z.string().url().optional()
            .describe("Custom URL for the invitation link"),
        sendMail: z.boolean().optional()
            .describe("Send invite via email (default follows project settings)"),
        sendSMS: z.boolean().optional()
            .describe("Send invite via SMS (default follows project settings)"),
        templateId: z.string().optional()
            .describe("Custom template ID for the invitation"),
        templateOptions: z.object({
            appUrl: z.string().url().optional()
                .describe("Application URL to use in the template"),
            redirectUrl: z.string().url().optional()
                .describe("URL to redirect after authentication"),
            customClaims: z.string().optional()
                .describe("Custom claims to include in the template (as JSON string)"),
        }).optional()
            .describe("Options for customizing the invitation template"),
    },
  • src/descope.ts:233-345 (registration)
    Registration of the invite-user tool on the MCP server with name, description, input schema, and handler function.
    // Add invite-user tool
    server.tool(
        "invite-user",
        "Create and invite a new user to the Descope project",
        {
            // Basic user info
            loginId: z.string()
                .describe("Primary login identifier for the user"),
            additionalLoginIds: z.array(z.string()).optional()
                .describe("Additional login identifiers"),
            email: z.string().email().optional()
                .describe("User's email address"),
            verifiedEmail: z.boolean().optional()
                .describe("Whether the email is pre-verified"),
            phone: z.string().optional()
                .describe("User's phone number in E.164 format"),
            verifiedPhone: z.boolean().optional()
                .describe("Whether the phone is pre-verified"),
            displayName: z.string().optional()
                .describe("User's display name"),
            givenName: z.string().optional()
                .describe("User's given/first name"),
            middleName: z.string().optional()
                .describe("User's middle name"),
            familyName: z.string().optional()
                .describe("User's family/last name"),
            picture: z.string().url().optional()
                .describe("URL to user's profile picture"),
            roles: z.array(z.string()).optional()
                .describe("Global role names to assign to the user"),
            userTenants: z.array(z.object({
                tenantId: z.string(),
                roleNames: z.array(z.string()),
            })).optional()
                .describe("Tenant associations with specific roles"),
            ssoAppIds: z.array(z.string()).optional()
                .describe("SSO application IDs to associate"),
            customAttributes: z.record(z.any()).optional()
                .describe("Custom attributes for the user"),
            // Invite specific options
            inviteUrl: z.string().url().optional()
                .describe("Custom URL for the invitation link"),
            sendMail: z.boolean().optional()
                .describe("Send invite via email (default follows project settings)"),
            sendSMS: z.boolean().optional()
                .describe("Send invite via SMS (default follows project settings)"),
            templateId: z.string().optional()
                .describe("Custom template ID for the invitation"),
            templateOptions: z.object({
                appUrl: z.string().url().optional()
                    .describe("Application URL to use in the template"),
                redirectUrl: z.string().url().optional()
                    .describe("URL to redirect after authentication"),
                customClaims: z.string().optional()
                    .describe("Custom claims to include in the template (as JSON string)"),
            }).optional()
                .describe("Options for customizing the invitation template"),
        },
        async ({ loginId, inviteUrl, sendMail, sendSMS, templateId, templateOptions, ...userOptions }) => {
            try {
                // Define the type for invite options
                const inviteOptions: {
                    inviteUrl?: string;
                    sendMail?: boolean;
                    sendSMS?: boolean;
                    templateId?: string;
                    templateOptions?: {
                        appUrl?: string;
                        redirectUrl?: string;
                        customClaims?: string;
                    };
                } & typeof userOptions = {
                    ...userOptions,
                    inviteUrl,
                    sendMail,
                    sendSMS,
                    templateId,
                };
    
                // Only add templateOptions if they exist and ensure customClaims is handled properly
                if (templateOptions) {
                    inviteOptions.templateOptions = {
                        appUrl: templateOptions.appUrl,
                        redirectUrl: templateOptions.redirectUrl,
                    };
                    // Only add customClaims if it's provided
                    if (templateOptions.customClaims) {
                        inviteOptions.templateOptions.customClaims = templateOptions.customClaims;
                    }
                }
    
                const user = await descope.management.user.invite(loginId, inviteOptions);
    
                return {
                    content: [
                        {
                            type: "text",
                            text: `Successfully invited user:\n\n${JSON.stringify(user.data, null, 2)}`,
                        },
                    ],
                };
            } catch (error) {
                return {
                    content: [
                        {
                            type: "text",
                            text: `Error inviting user: ${error}`,
                        },
                    ],
                };
            }
        },
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While it indicates this is a creation/invitation operation, it doesn't mention what permissions are required, whether this sends actual invitations versus just creating user records, what happens if the user already exists, or what the response contains. For a mutation tool with 20 parameters and no annotation coverage, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states the core purpose without unnecessary words. It's appropriately sized and front-loaded with the essential information, making it easy for an agent to quickly understand what the tool does.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex mutation tool with 20 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what happens after invocation (does it return the created user object? an invitation link?), what errors might occur, or any behavioral nuances. The agent would struggle to use this tool effectively without trial and error.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, meaning all 20 parameters are documented in the input schema itself. The description adds no additional parameter information beyond what's already in the schema descriptions, so it meets the baseline expectation but doesn't provide extra value regarding parameter usage or relationships.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create and invite') and target resource ('a new user to the Descope project'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from the sibling 'create-user' tool, which appears to serve a similar purpose but without the invitation aspect.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'create-user' or other sibling tools. There's no mention of prerequisites, when this tool is appropriate versus other user management approaches, or any exclusions or limitations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

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/descope-sample-apps/descope-mcp-server-stdio'

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