get_user_invite
Retrieve an invitation by ID to view its email, role, status, and expiry. Use for pending invites only.
Instructions
Get one invitation by invite id and return its email, role, status, and expiry. Use this for pending invites only; use get_user for accepted users.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| invite_id | Yes | The invite ID to retrieve |
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:358-373 (handler)MCP tool handler for 'get_user_invite'. Registers the tool with name 'get_user_invite', description about retrieving an invitation by ID, schema from USERS_TOOL_SCHEMAS.getUserInvite, and calls service.users.getUserInvite(params.invite_id). Returns a formatted user invite as JSON text content.
// Phase 1: Get user invite tool server.tool( "get_user_invite", "Get one invitation by invite id and return its email, role, status, and expiry. Use this for pending invites only; use get_user for accepted users.", USERS_TOOL_SCHEMAS.getUserInvite, async (params) => { const invite = await service.users.getUserInvite(params.invite_id); return { content: [ { type: "text", text: JSON.stringify(formatUserInvite(invite), null, 2), }, ], }; }, - src/tools/users.tools.ts:121-123 (schema)Zod schema for the get_user_invite tool's input parameter. Defines 'invite_id' as a required string describing 'The invite ID to retrieve'.
getUserInvite: { invite_id: z.string().describe("The invite ID to retrieve"), }, - src/tools/users.tools.ts:184-425 (registration)The registerUsersTools function registers all user-related MCP tools including get_user_invite on the McpServer instance.
export function registerUsersTools( server: McpServer, service: PortkeyService, ): void { // List all users tool server.tool( "list_all_users", "List accepted org users with id, name, email, role, and timestamps. Use this to find a user_id before get_user, update_user, delete_user, or add_workspace_member; use list_user_invites for pending invitations.", USERS_TOOL_SCHEMAS.listAllUsers, async () => { const users = await service.users.listUsers(); return { content: [ { type: "text", text: JSON.stringify( { total: users.total, users: users.data.map(formatUser), }, null, 2, ), }, ], }; }, ); // 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, ), }, ], }; }, ); // User analytics tool server.tool( "get_user_stats", "Return per-user request and cost analytics for a required time range. This is usage-by-user, not population metrics; use get_users_analytics for active-user or cohort trends.", USERS_TOOL_SCHEMAS.getUserStats, async (params) => { const stats = await service.users.getUserGroupedData(params); return { content: [ { type: "text", text: JSON.stringify( { total_users: stats.total, users: stats.data.map(formatUserAnalyticsGroup), }, null, 2, ), }, ], }; }, ); // Phase 1: Get user tool server.tool( "get_user", "Get one accepted user by id and return their profile, role, and timestamps. Use list_all_users to find the id if you only have a name or email, and get_user_invite for pending invitations.", USERS_TOOL_SCHEMAS.getUser, async (params) => { const user = await service.users.getUser(params.user_id); return { content: [ { type: "text", text: JSON.stringify(formatUser(user), null, 2), }, ], }; }, ); // Phase 1: Update user tool server.tool( "update_user", "Update a user's first name, last name, or organization role by id. Email and workspace roles are not editable here; use update_workspace_member for workspace membership changes.", USERS_TOOL_SCHEMAS.updateUser, async (params) => { const { user_id, ...updateData } = params; const user = await service.users.updateUser(user_id, updateData); return { content: [ { type: "text", text: JSON.stringify( { message: "Successfully updated user", user: formatUser(user), }, null, 2, ), }, ], }; }, ); // Phase 1: Delete user tool server.tool( "delete_user", "Delete a user from the org by id. This is permanent, removes org and workspace memberships, revokes API keys, and ends active sessions; use delete_user_invite for pending invites instead.", USERS_TOOL_SCHEMAS.deleteUser, async (params) => { await service.users.deleteUser(params.user_id); return { content: [ { type: "text", text: JSON.stringify( { message: `Successfully deleted user ${params.user_id}`, success: true, }, null, 2, ), }, ], }; }, ); // Phase 1: List user invites tool server.tool( "list_user_invites", "List pending and sent invitations with id, email, role, status, and expiry. Use this to check invite state; use list_all_users for users who already accepted.", USERS_TOOL_SCHEMAS.listUserInvites, async () => { const invites = await service.users.listUserInvites(); return { content: [ { type: "text", text: JSON.stringify( { total: invites.total, invites: invites.data.map(formatUserInvite), }, null, 2, ), }, ], }; }, ); // Phase 1: Get user invite tool server.tool( "get_user_invite", "Get one invitation by invite id and return its email, role, status, and expiry. Use this for pending invites only; use get_user for accepted users.", USERS_TOOL_SCHEMAS.getUserInvite, async (params) => { const invite = await service.users.getUserInvite(params.invite_id); return { content: [ { type: "text", text: JSON.stringify(formatUserInvite(invite), null, 2), }, ], }; }, ); // Phase 1: Delete user invite tool server.tool( "delete_user_invite", "Delete a pending invite and revoke its invite link. This does not affect existing users; use delete_user for full user removal.", USERS_TOOL_SCHEMAS.deleteUserInvite, async (params) => { await service.users.deleteUserInvite(params.invite_id); return { content: [ { type: "text", text: JSON.stringify( { message: `Successfully deleted invite ${params.invite_id}`, success: true, }, null, 2, ), }, ], }; }, ); // Phase 1: Resend user invite tool server.tool( "resend_user_invite", "Resend the email for a pending invite that has not been accepted, unlike invite_user which creates a new invite. This sends a fresh email without modifying the invite record, expiry, or role; use get_user_invite first if you are unsure whether the invite still exists and list_user_invites to discover invite_ids.", USERS_TOOL_SCHEMAS.resendUserInvite, async (params) => { await service.users.resendUserInvite(params.invite_id); return { content: [ { type: "text", text: JSON.stringify( { message: `Successfully resent invite ${params.invite_id}`, success: true, }, null, 2, ), }, ], }; }, ); } - src/tools/users.tools.ts:154-170 (helper)Helper function formatUserInvite that transforms a UserInvite object into a simplified response format with id, email, role, status, created_at, and expires_at fields.
function formatUserInvite(invite: UserInvite): { id: string; email: string; role: string; status: string; created_at: string; expires_at: string; } { return { id: invite.id, email: invite.email, role: invite.role, status: invite.status, created_at: invite.created_at, expires_at: invite.expires_at, }; } - Service method getUserInvite that makes a GET request to /admin/users/invites/{inviteId} and returns a UserInvite object. This is the actual data-access layer that calls the backend API.
async getUserInvite(inviteId: string): Promise<UserInvite> { return this.get<UserInvite>( `/admin/users/invites/${this.encodePathSegment(inviteId)}`, ); }