list_business_users
Retrieve a list of users associated with your Meta Business account. Control output with fields, limit, and pagination.
Instructions
List 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:78-105 (handler)The handler function for the 'list_business_users' tool. It retrieves the business ID from the client config, makes a GET request to /{businessId}/business_users with optional pagination parameters (fields, limit, after), and returns the JSON result with rate limit info. Requires META_BUSINESS_ID env var.
// ─── list_business_users ────────────────────────────────────── server.tool( "list_business_users", "List 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}/business_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:82-86 (schema)Input schema for 'list_business_users' - defines optional fields (string), limit (number, default 25), and after (string for pagination cursor) using Zod validation.
{ 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"), }, - src/tools/business.ts:79-105 (registration)The tool is registered via server.tool('list_business_users', ...) inside the registerBusinessTools function in src/tools/business.ts.
server.tool( "list_business_users", "List 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}/business_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/services/ads-client.ts:235-242 (helper)The businessId getter on AdsClient that throws if META_BUSINESS_ID env var is not set. Used by the handler to obtain the business ID.
get businessId(): string { if (!this.config.businessId) { throw new Error( "META_BUSINESS_ID is not configured. Set it as an environment variable." ); } return this.config.businessId; } - src/services/ads-client.ts:180-185 (helper)The AdsClient.get() method that performs the actual HTTP GET request to the Meta Graph API, used by the handler.
async get( path: string, params?: Record<string, unknown> ): Promise<ClientResponse> { return this.request("GET", path, params); }