get_my_permissions
Lists user permissions from the MCP JSON Database Server to verify access rights for database operations using JWT authentication.
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)Handler function that extracts user information from the provided JWT token and retrieves the user's permissions based on their role using getUserPermissions.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 the ListTools response, including name, description, and input schema.{ 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/permissions.js:147-152 (helper)Helper function that returns the list of permissions associated with a given user role, based on the ROLE_PERMISSIONS matrix.export function getUserPermissions(userRole) { if (!userRole) return []; return ROLE_PERMISSIONS[userRole] || []; }
- src/auth.js:54-65 (helper)Helper function that decodes the JWT token and extracts user ID, email, and role.export function extractUserFromToken(token) { try { const decoded = verifyToken(token); return { userId: decoded.userId, email: decoded.email, role: decoded.role }; } catch (error) { return null; } }