get_user_by_id
Retrieve user information by ID using a JWT token for authentication on the MCP JSON Database Server. Designed for secure user data access and management.
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)Main execution logic for get_user_by_id tool: permission check, database lookup, user data retrieval (without password), access control for self/other users.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 handler, defining name, description, and input schema (id: number required, token: string required).{ 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'] } },
- src/index.js:235-242 (schema)Input schema definition for get_user_by_id tool.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'] }