Skip to main content
Glama
huseyindol

User Info MCP Server

by huseyindol

search_users_by_name

Search for users by their name using this tool from the User Info MCP Server. Input a name to retrieve matching user data stored in JSON format for efficient information management.

Instructions

İsme göre kullanıcı ara

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesAranacak kullanıcı ismi

Implementation Reference

  • The main handler function for the 'search_users_by_name' tool. It receives the input name, delegates to userService.searchUsersByName, formats the result as MCP ToolResponse with JSON users or error message.
    static async handleSearchUsersByName({ name }: { name: string }): Promise<ToolResponse> { try { const result = await userService.searchUsersByName(name); return { content: [ { type: "text", text: result.success && result.data && result.data.length > 0 ? 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 for the tool, defining 'name' as a non-empty string.
    export const SearchUsersByNameInputSchema = { name: z.string().min(1).describe("Aranacak kullanıcı ismi") };
  • Registers the tool named 'search_users_by_name' on the MCP server with title, description, input schema, and handler reference.
    server.registerTool( "search_users_by_name", { title: "Kullanıcı Ara", description: "İsme göre kullanıcı ara", inputSchema: SearchUsersByNameInputSchema, }, UserController.handleSearchUsersByName );
  • Business logic helper in user service that validates input (min 2 chars), queries repository by name, and returns structured ServiceResult<User[]>.
    async searchUsersByName(name: string): Promise<ServiceResult<User[]>> { try { // Business rule: Name must be at least 2 characters if (name.trim().length < 2) { return { success: false, error: "Arama terimi en az 2 karakter olmalıdır", data: [] }; } const users = await userRepository.findByName(name); return { success: true, data: users, message: users.length > 0 ? `"${name}" için ${users.length} kullanıcı bulundu` : `"${name}" ismiyle kullanıcı bulunamadı` }; } catch (error) { return { success: false, error: "Kullanıcı arama işleminde hata oluştu", data: [] }; } }

Other Tools

Related Tools

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