Skip to main content
Glama
huseyindol

User Info MCP Server

by huseyindol

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
NameRequiredDescriptionDefault
phoneYesAranacak 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",
            },
          ],
        };
      }
    }
  • 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ı")
    };
  • 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
    );
  • 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
        };
      }
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/huseyindol/McpProjectScaffold'

If you have feedback or need assistance with the MCP directory API, please join our Discord server