search_users_by_phone
Find user information by entering a phone number to search through stored user data.
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 main tool handler function for 'search_users_by_phone'. It receives the phone parameter, calls the user service to perform the search, formats the result as an MCP ToolResponse, and handles errors.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/types/user.ts:23-25 (schema)Zod input schema defining the 'phone' parameter for the tool, with length validation and description.export const SearchUsersByPhoneInputSchema = { phone: z.string().min(10).max(20).describe("Aranacak Telefon numarası") };
- src/tools/user-tools.ts:63-71 (registration)Tool registration call on the MCP server, specifying the tool name, metadata (title, description), input schema, and handler reference.server.registerTool( "search_users_by_phone", { title: "Kullanıcı Ara", description: "Telefon numarasına göre kullanıcı ara", inputSchema: SearchUsersByPhoneInputSchema, }, UserController.handleSearchUsersByPhone );
- src/services/user.service.ts:149-174 (helper)Service layer method implementing the search logic by phone, including business validation (phone format check) and repository call.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 }; } }