get-user-by-email
Retrieve detailed user profile information from a Zulip workspace by providing the exact email address. Includes Gravatar URL and custom profile fields if specified.
Instructions
📧 EXACT LOOKUP: Find a user when you have their exact email address. Use this when you know the specific email and need detailed profile information. Returns single user with complete details.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| client_gravatar | No | Include Gravatar profile image URL | |
| Yes | Email address of the user to look up | ||
| include_custom_profile_fields | No | Include organization-specific custom profile fields |
Implementation Reference
- src/server.ts:551-578 (handler)The handler function that executes the get-user-by-email tool logic. It takes email and optional parameters, calls ZulipClient.getUserByEmail, formats the user data with role computation, and returns a success response or error.async ({ email, client_gravatar, include_custom_profile_fields }) => { try { const result = await zulipClient.getUserByEmail(email, { client_gravatar, include_custom_profile_fields }); return createSuccessResponse(JSON.stringify({ user: { id: result.user.user_id, email: result.user.email, full_name: result.user.full_name, is_active: result.user.is_active, is_bot: result.user.is_bot, role: result.user.is_owner ? 'owner' : result.user.is_admin ? 'admin' : result.user.is_moderator ? 'moderator' : result.user.is_guest ? 'guest' : 'member', date_joined: result.user.date_joined, timezone: result.user.timezone, avatar_url: result.user.avatar_url, profile_data: result.user.profile_data } }, null, 2)); } catch (error) { return createErrorResponse(`Error getting user by email: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
- src/types.ts:155-159 (schema)Zod schema defining the input parameters for the get-user-by-email tool: required email and optional client_gravatar, include_custom_profile_fields.export const GetUserByEmailSchema = z.object({ email: z.string().email().describe("Email address of the user to look up"), client_gravatar: z.boolean().optional().describe("Include Gravatar profile image URL"), include_custom_profile_fields: z.boolean().optional().describe("Include organization-specific custom profile fields") });
- src/server.ts:548-579 (registration)Registration of the get-user-by-email tool using McpServer.tool(), including name, description, input schema, and handler function."get-user-by-email", "📧 EXACT LOOKUP: Find a user when you have their exact email address. Use this when you know the specific email and need detailed profile information. Returns single user with complete details.", GetUserByEmailSchema.shape, async ({ email, client_gravatar, include_custom_profile_fields }) => { try { const result = await zulipClient.getUserByEmail(email, { client_gravatar, include_custom_profile_fields }); return createSuccessResponse(JSON.stringify({ user: { id: result.user.user_id, email: result.user.email, full_name: result.user.full_name, is_active: result.user.is_active, is_bot: result.user.is_bot, role: result.user.is_owner ? 'owner' : result.user.is_admin ? 'admin' : result.user.is_moderator ? 'moderator' : result.user.is_guest ? 'guest' : 'member', date_joined: result.user.date_joined, timezone: result.user.timezone, avatar_url: result.user.avatar_url, profile_data: result.user.profile_data } }, null, 2)); } catch (error) { return createErrorResponse(`Error getting user by email: ${error instanceof Error ? error.message : 'Unknown error'}`); } } );
- src/zulip/client.ts:386-396 (helper)ZulipClient.getUserByEmail method: Makes API call to /users/{email} with optional params, handles response, used by the tool handler.async getUserByEmail(email: string, params: { client_gravatar?: boolean; include_custom_profile_fields?: boolean; } = {}): Promise<{ user: ZulipUser }> { // Filter out undefined values const filteredParams = Object.fromEntries( Object.entries(params).filter(([, value]) => value !== undefined) ); const response = await this.client.get(`/users/${encodeURIComponent(email)}`, { params: filteredParams }); return response.data; }