get_user_by_id
Retrieve user information from the JSON database using a specific user ID. Requires JWT authentication token for authorization to access secure user data.
Instructions
ID'ye göre kullanıcı bilgilerini getirir (Yetki gerekli)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Kullanıcı ID'si | |
| token | Yes | JWT token (yetki kontrolü için) |
Implementation Reference
- src/index.js:632-689 (handler)Handler implementation for get_user_by_id tool. Performs permission check, retrieves user from database by ID, excludes password, handles errors.case 'get_user_by_id': { const { id, token } = args; try { // Yetki kontrolü const requestUser = checkPermissionWithToken(token, PERMISSIONS.USER_READ); const user = db.users.find(u => u.id === id); if (!user) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: 'Kullanıcı bulunamadı' }) }] }; } // Kendi bilgilerini görüntüleme veya yetki kontrolü if (requestUser.userId !== id && !hasPermission(requestUser.role, PERMISSIONS.USER_READ)) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: 'Bu kullanıcının bilgilerini görüntüleme yetkiniz yok' }) }] }; } const { password, ...userWithoutPassword } = user; return { content: [{ type: 'text', text: JSON.stringify({ success: true, data: userWithoutPassword, requestedBy: { id: requestUser.userId, role: requestUser.role } }, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: error.message, requiredPermission: PERMISSIONS.USER_READ }) }] }; } }
- src/index.js:232-243 (registration)Tool registration in ListTools response, including name, description, and input schema definition.{ name: 'get_user_by_id', description: 'ID\'ye göre kullanıcı bilgilerini getirir (Yetki gerekli)', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'Kullanıcı ID\'si' }, token: { type: 'string', description: 'JWT token (yetki kontrolü için)' } }, required: ['id', 'token'] } },