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
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Kullanıcının ID'si |
Implementation Reference
- src/controllers/user.controller.ts:53-77 (handler)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", }, ], }; } }
- src/types/user.ts:15-17 (schema)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") };
- src/tools/user-tools.ts:30-38 (registration)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 );
- src/services/user.service.ts:46-76 (helper)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" }; } }