get_my_permissions
Retrieve a list of user permissions specific to their role by providing a valid JWT token, integrated with MCP JSON Database Server for secure access management.
Instructions
Kullanıcının sahip olduğu yetkileri listeler
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token | Yes | JWT token |
Implementation Reference
- src/index.js:548-587 (handler)Main handler for the 'get_my_permissions' tool. Extracts user from JWT token, retrieves the user's permissions using getUserPermissions helper, and returns a JSON response with user info, permissions list, and role description.case 'get_my_permissions': { const { token } = args; try { const user = extractUserFromToken(token); if (!user) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: 'Geçersiz token' }) }] }; } const permissions = getUserPermissions(user.role); return { content: [{ type: 'text', text: JSON.stringify({ success: true, user: { id: user.userId, email: user.email, role: user.role }, permissions: permissions, totalPermissions: permissions.length, roleDescription: { [ROLES.ADMIN]: 'Sistem yöneticisi - Tüm yetkilere sahip', [ROLES.MANAGER]: 'Yönetici - Çoğu yönetim yetkilerine sahip', [ROLES.EMPLOYEE]: 'Çalışan - Temel yetkilere sahip' }[user.role] }, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: error.message }) }] }; } }
- src/index.js:120-130 (registration)Tool registration in ListToolsRequestHandler, including name, description, and input schema requiring a JWT token.{ name: 'get_my_permissions', description: 'Kullanıcının sahip olduğu yetkileri listeler', inputSchema: { type: 'object', properties: { token: { type: 'string', description: 'JWT token' } }, required: ['token'] } },
- src/index.js:123-129 (schema)Input schema for get_my_permissions tool: requires a 'token' string (JWT).inputSchema: { type: 'object', properties: { token: { type: 'string', description: 'JWT token' } }, required: ['token'] }
- src/permissions.js:147-151 (helper)Helper function that returns the array of permissions for a given user role, based on the predefined ROLE_PERMISSIONS matrix.export function getUserPermissions(userRole) { if (!userRole) return []; return ROLE_PERMISSIONS[userRole] || []; }
- src/auth.js:54-64 (helper)Helper function used in handler to extract userId, email, and role from the provided JWT token.export function extractUserFromToken(token) { try { const decoded = verifyToken(token); return { userId: decoded.userId, email: decoded.email, role: decoded.role }; } catch (error) { return null; }