Skip to main content
Glama

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
NameRequiredDescriptionDefault
tokenYesJWT token

Implementation Reference

  • 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'] } },
  • Input schema for get_my_permissions tool: requires a 'token' string (JWT).
    inputSchema: { type: 'object', properties: { token: { type: 'string', description: 'JWT token' } }, required: ['token'] }
  • 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] || []; }
  • 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; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yusuferenkt/mcp-database'

If you have feedback or need assistance with the MCP directory API, please join our Discord server