search_users_by_phone
Locate user details stored in the User Info MCP Server by entering a phone number, enabling quick retrieval of associated information for efficient user management.
Instructions
Telefon numarasına göre kullanıcı ara
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| phone | Yes | Aranacak Telefon numarası |
Implementation Reference
- The tool handler function that processes the phone input, calls the user service, handles errors, and returns the formatted MCP ToolResponse with user data or error message.static async handleSearchUsersByPhone({ phone }: { phone: string }): Promise<ToolResponse> { try { const result = await userService.searchUsersByPhone(phone); 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:63-71 (registration)MCP server registration of the 'search_users_by_phone' tool, including name, title, description, input schema reference, and handler binding.server.registerTool( "search_users_by_phone", { title: "Kullanıcı Ara", description: "Telefon numarasına göre kullanıcı ara", inputSchema: SearchUsersByPhoneInputSchema, }, UserController.handleSearchUsersByPhone );
- src/types/user.ts:23-25 (schema)Zod input schema defining the 'phone' parameter validation for the tool input.export const SearchUsersByPhoneInputSchema = { phone: z.string().min(10).max(20).describe("Aranacak Telefon numarası") };
- src/services/user.service.ts:149-174 (helper)Service layer method providing business logic validation for phone format and delegating to repository for user lookup by phone.async searchUsersByPhone(phone: string): Promise<ServiceResult<User | null>> { try { // Business rule: Phone must be a valid phone number if (!phone.includes(' ')) { return { success: false, error: "Telefon numarası geçersiz", data: null }; } const user = await userRepository.findByPhone(phone); return { success: true, data: user, message: user ? `"${phone}" için kullanıcı bulundu` : `"${phone}" telefon numarasıyla kullanıcı bulunamadı` }; } catch (error) { return { success: false, error: "Kullanıcı arama işleminde hata oluştu", data: null }; } }