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
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"token": "<token>"
},
"name": "get_my_permissions"
}
}Input 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; } }