Skip to main content
Glama
huseyindol

User Info MCP Server

by huseyindol

get_user_by_id

Retrieve specific user details by providing their unique ID number. This tool fetches user information from the User Info MCP Server database for lookup and management purposes.

Instructions

ID'ye göre belirli bir kullanıcıyı getir

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesKullanıcının ID'si

Implementation Reference

  • The handler function that executes the tool logic for get_user_by_id. It calls the user service to fetch the user and returns a formatted MCP ToolResponse.
    static async handleGetUserById({ id }: { id: number }): Promise<ToolResponse> { try { const result = await userService.getUserById(id); return { content: [ { type: "text", text: result.success ? JSON.stringify(result.data, null, 2) : result.error || "Kullanıcı bulunamadı", }, ], }; } catch (error) { return { content: [ { type: "text", text: "Kullanıcı getirme işleminde hata oluştu", }, ], }; } }
  • Zod schema defining the input for the get_user_by_id tool, requiring a positive integer ID.
    export const GetUserByIdInputSchema = { id: z.number().int().positive().describe("Kullanıcının ID'si") };
  • Registration of the get_user_by_id tool on the MCP server, specifying name, metadata, input schema, and handler.
    server.registerTool( "get_user_by_id", { title: "Kullanıcı Getir", description: "ID'ye göre belirli bir kullanıcıyı getir", inputSchema: GetUserByIdInputSchema, }, UserController.handleGetUserById );
  • Helper service method that performs the actual user lookup by ID, including business rule validation and error handling.
    async getUserById(id: number): Promise<ServiceResult<User>> { try { // Business rule: ID must be positive if (id <= 0) { return { success: false, error: "Geçersiz kullanıcı ID'si. ID pozitif bir sayı olmalıdır." }; } const user = await userRepository.findById(id); if (!user) { return { success: false, error: `ID ${id} ile kullanıcı bulunamadı` }; } return { success: true, data: user, message: "Kullanıcı başarıyla bulundu" }; } catch (error) { return { success: false, error: "Kullanıcı getirilirken hata oluştu" }; } }

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