list_all_users
Retrieve all users in your Portkey organization with their roles and account details to manage access and permissions.
Instructions
List all users in your Portkey organization, including their roles and account details
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:24-29 (handler)Inline handler function for the 'list_all_users' tool that invokes portkeyService.listUsers() and returns the users data as formatted JSON text content.async () => { const users = await portkeyService.listUsers(); return { content: [{ type: "text", text: JSON.stringify(users, null, 2) }] } }
- src/index.ts:20-30 (registration)Registers the 'list_all_users' MCP tool with the server, including name, description, empty input schema ({}), and the handler function.server.tool( "list_all_users", "List all users in your Portkey organization, including their roles and account details", {}, async () => { const users = await portkeyService.listUsers(); return { content: [{ type: "text", text: JSON.stringify(users, null, 2) }] } } );
- Core helper method 'listUsers()' in PortkeyService class that performs the actual API call to Portkey's /admin/users endpoint to retrieve the list of users.async listUsers(): Promise<PortkeyUsersResponse> { try { const response = await fetch(`${this.baseUrl}/admin/users`, { method: 'GET', headers: { 'x-portkey-api-key': this.apiKey, 'Accept': 'application/json' } }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json() as PortkeyUsersResponse; return { total: data.total, object: data.object, data: data.data.map(user => ({ object: user.object, id: user.id, first_name: user.first_name, last_name: user.last_name, email: user.email, role: user.role, created_at: user.created_at, last_updated_at: user.last_updated_at })) }; } catch (error) { console.error('PortkeyService Error:', error); throw new Error('Failed to fetch users from Portkey API'); } }