Skip to main content
Glama
huseyindol

User Info MCP Server

by huseyindol

get_user_by_id

Retrieve specific user details by providing a unique user ID. This tool is part of the User Info MCP Server, designed for efficient user information management.

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 main handler function for the 'get_user_by_id' tool. It takes an ID, calls the user service, and formats the response as 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 tool: requires 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, linking name, 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 );
  • Service layer method providing business logic for fetching user by ID, including validation and repository call.
    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" }; } }

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