invite_user
Invite a new organization user, assign workspace roles, and create an API key if needed, all in one request.
Instructions
Invite a new org user and optionally provision workspace access and an API key in one call. Workspace assignments apply only after acceptance; use add_workspace_member or update_workspace_member later for follow-up changes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Yes | Email address of the user to invite | ||
| role | Yes | Organization-level role: 'admin' for full access, 'member' for limited access | |
| first_name | No | User's first name | |
| last_name | No | User's last name | |
| workspaces | Yes | List of workspaces and corresponding roles to grant to the user | |
| workspace_api_key_details | No | Optional API key to be created for the user |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | Whether the tool call succeeded and returned structured data | |
| data | No | Structured success payload when ok is true | |
| error | No | Structured error payload when ok is false |
Implementation Reference
- src/tools/users.tools.ts:213-237 (registration)The tool 'invite_user' is registered with the MCP server via server.tool(...). Located in the registerUsersTools function (line 184) which is exported and called from elsewhere.
// Invite user tool server.tool( "invite_user", "Invite a new org user and optionally provision workspace access and an API key in one call. Workspace assignments apply only after acceptance; use add_workspace_member or update_workspace_member later for follow-up changes.", USERS_TOOL_SCHEMAS.inviteUser, async (params) => { const result = await service.users.inviteUser(params); return { content: [ { type: "text", text: JSON.stringify( { message: `Successfully invited ${params.email} as ${params.role}`, invite_id: result.id, invite_link: result.invite_link, }, null, 2, ), }, ], }; }, ); - src/tools/users.tools.ts:218-237 (handler)Handler for 'invite_user': calls service.users.inviteUser(params) and returns a JSON response with message, invite_id, and invite_link.
async (params) => { const result = await service.users.inviteUser(params); return { content: [ { type: "text", text: JSON.stringify( { message: `Successfully invited ${params.email} as ${params.role}`, invite_id: result.id, invite_link: result.invite_link, }, null, 2, ), }, ], }; }, ); - src/tools/users.tools.ts:12-59 (schema)Zod schema for inviteUser parameters: email (required), role (admin|member), first_name, last_name, workspaces array, and workspace_api_key_details.
inviteUser: { email: z.string().email().describe("Email address of the user to invite"), role: z .enum(["admin", "member"]) .describe( "Organization-level role: 'admin' for full access, 'member' for limited access", ), first_name: z.string().optional().describe("User's first name"), last_name: z.string().optional().describe("User's last name"), workspaces: z .array( z.object({ id: z .string() .describe( "Workspace ID/slug where the user will be granted access", ), role: z .enum(["admin", "member", "manager"]) .describe( "Workspace-level role: 'admin' for full access, 'manager' for workspace management, 'member' for basic access", ), }), ) .describe( "List of workspaces and corresponding roles to grant to the user", ), workspace_api_key_details: z .object({ name: z .string() .optional() .describe("Name of the API key to be created"), expiry: z .string() .optional() .describe("Expiration date for the API key (ISO8601 format)"), metadata: z .record(z.string(), z.string()) .optional() .describe("Additional metadata key-value pairs for the API key"), scopes: z .array(z.string()) .describe("List of permission scopes for the API key"), }) .optional() .describe("Optional API key to be created for the user"), }, - src/services/users.service.ts:33-40 (helper)InviteUserRequest TypeScript interface defining the request shape sent to the backend API.
export interface InviteUserRequest { email: string; role: "admin" | "member"; first_name?: string; last_name?: string; workspaces: WorkspaceDetails[]; workspace_api_key_details?: WorkspaceApiKeyDetails; } - inviteUser method on UsersService that POSTs to /admin/users/invites and returns InviteUserResponse.
async inviteUser(data: InviteUserRequest): Promise<InviteUserResponse> { return this.post<InviteUserResponse>("/admin/users/invites", data); }