create-user
Create new users in Descope projects by defining login IDs, email, phone, roles, and tenant associations for identity management.
Instructions
Create a new user in Descope project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| loginId | Yes | Primary login identifier for the user | |
| additionalLoginIds | No | Additional login identifiers | |
| No | User's email address | ||
| verifiedEmail | No | Whether the email is pre-verified | |
| phone | No | User's phone number in E.164 format | |
| verifiedPhone | No | Whether the phone is pre-verified | |
| displayName | No | User's display name | |
| givenName | No | User's given/first name | |
| middleName | No | User's middle name | |
| familyName | No | User's family/last name | |
| picture | No | URL to user's profile picture | |
| roles | No | Global role names to assign to the user | |
| userTenants | No | Tenant associations with specific roles | |
| ssoAppIds | No | SSO application IDs to associate | |
| customAttributes | No | Custom attributes for the user |
Implementation Reference
- src/descope.ts:208-230 (handler)The async handler function for the 'create-user' tool. It destructures input params, calls descope.management.user.create, and returns a text content response with the user data or error.async ({ loginId, ...options }) => { try { const user = await descope.management.user.create(loginId, options); return { content: [ { type: "text", text: `Successfully created user:\n\n${JSON.stringify(user.data, null, 2)}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error creating user: ${error}`, }, ], }; } },
- src/descope.ts:173-207 (schema)Zod input schema for the 'create-user' tool parameters, validating fields like loginId, email, phone, names, roles, tenants, etc.{ 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"), },
- src/descope.ts:170-231 (registration)Registration of the 'create-user' tool on the MCP server using server.tool(name, description, inputSchema, handlerFn). This is within the createServer function.server.tool( "create-user", "Create a new user in Descope project", { 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"), }, async ({ loginId, ...options }) => { try { const user = await descope.management.user.create(loginId, options); return { content: [ { type: "text", text: `Successfully created user:\n\n${JSON.stringify(user.data, null, 2)}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error creating user: ${error}`, }, ], }; } }, );