search_users_by_email
Retrieve user details by searching with a specific email address using this tool, part of the User Info MCP Server for managing user data efficiently.
Instructions
E-posta adresine göre kullanıcı ara
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Yes | Aranacak kullanıcı e-posta adresi |
Implementation Reference
- The MCP tool handler function that receives the input, calls the user service to perform the search, formats the response as required by the MCP protocol, and handles errors.static async handleSearchUsersByEmail({ email }: { email: string }): Promise<ToolResponse> { try { const result = await userService.searchUsersByEmail(email); return { content: [ { type: "text", text: result.success && result.data ? JSON.stringify(result.data, null, 2) : result.message || result.error || "Kullanıcı bulunamadı", }, ], }; } catch (error) { return { content: [ { type: "text", text: "Kullanıcı arama işleminde hata oluştu", }, ], }; } }
- src/tools/user-tools.ts:52-60 (registration)The registration of the 'search_users_by_email' tool on the MCP server, linking the name, metadata, input schema, and handler function.server.registerTool( "search_users_by_email", { title: "Kullanıcı Ara", description: "E-posta adresine göre kullanıcı ara", inputSchema: SearchUsersByEmailInputSchema, }, UserController.handleSearchUsersByEmail );
- src/types/user.ts:27-29 (schema)Zod schema defining the input structure for the tool, ensuring the 'email' parameter is a valid email string.export const SearchUsersByEmailInputSchema = { email: z.string().email().describe("Aranacak kullanıcı e-posta adresi") };
- src/services/user.service.ts:117-142 (helper)Helper service method that performs the actual business logic for searching users by email, including validation and delegation to the repository.async searchUsersByEmail(email: string): Promise<ServiceResult<User | null>> { try { // Business rule: Email must be a valid email address if (!email.includes('@')) { return { success: false, error: "E-posta adresi geçersiz", data: null }; } const user = await userRepository.findByEmail(email); return { success: true, data: user, message: user ? `"${email}" için kullanıcı bulundu` : `"${email}" e-posta adresiyle kullanıcı bulunamadı` }; } catch (error) { return { success: false, error: "Kullanıcı arama işleminde hata oluştu", data: null }; } }