list_system_users
Retrieve system users for your Meta Business account. Specify fields, limit results, and paginate through data.
Instructions
List system users of the configured business. Requires META_BUSINESS_ID env var.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fields | No | Comma-separated fields to return | |
| limit | No | Number of results (default 25) | |
| after | No | Pagination cursor for next page |
Implementation Reference
- src/tools/business.ts:213-240 (registration)Registration of the 'list_system_users' tool on the MCP server via server.tool(), defining its schema (fields, limit, after) and handler.
// ─── list_system_users ──────────────────────────────────────── server.tool( "list_system_users", "List system users of the configured business. Requires META_BUSINESS_ID env var.", { fields: z.string().optional().describe("Comma-separated fields to return"), limit: z.number().optional().default(25).describe("Number of results (default 25)"), after: z.string().optional().describe("Pagination cursor for next page"), }, async ({ fields, limit, after }) => { try { let businessId: string; try { businessId = client.businessId; } catch { return { content: [{ type: "text" as const, text: "META_BUSINESS_ID environment variable is required for this operation. Please set it and restart the server." }], isError: true }; } const params: Record<string, unknown> = {}; if (fields) params.fields = fields; if (limit) params.limit = limit; if (after) params.after = after; const { data, rateLimit } = await client.get(`/${businessId}/system_users`, params); return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); - src/tools/business.ts:222-239 (handler)Handler function for list_system_users. Extracts businessId from client, makes a GET request to /{businessId}/system_users with optional params, and returns JSON response with rate limit info.
async ({ fields, limit, after }) => { try { let businessId: string; try { businessId = client.businessId; } catch { return { content: [{ type: "text" as const, text: "META_BUSINESS_ID environment variable is required for this operation. Please set it and restart the server." }], isError: true }; } const params: Record<string, unknown> = {}; if (fields) params.fields = fields; if (limit) params.limit = limit; if (after) params.after = after; const { data, rateLimit } = await client.get(`/${businessId}/system_users`, params); return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } - src/tools/business.ts:217-221 (schema)Zod schema defining input parameters: optional 'fields' (string), optional 'limit' (number, default 25), and optional 'after' (string for pagination).
{ fields: z.string().optional().describe("Comma-separated fields to return"), limit: z.number().optional().default(25).describe("Number of results (default 25)"), after: z.string().optional().describe("Pagination cursor for next page"), },