search_users_by_email
Find user information by searching with an email address. This tool helps locate specific user data in the User Info MCP Server system.
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 handler function that executes the tool logic: receives email input, calls userService.searchUsersByEmail, formats result into MCP ToolResponse with JSON stringified output.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/types/user.ts:27-29 (schema)Zod schema defining the input for the tool: requires a valid email string.export const SearchUsersByEmailInputSchema = { email: z.string().email().describe("Aranacak kullanıcı e-posta adresi") };
- src/tools/user-tools.ts:52-60 (registration)Registration of the MCP tool 'search_users_by_email' with title, description, input schema, and reference to the 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/services/user.service.ts:117-142 (helper)Supporting service method implementing business logic: validates email format, queries repository by email, returns structured ServiceResult.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 }; } }