list_rules
List automated rules for an ad account to review and manage campaign automation settings.
Instructions
List automated rules for the ad account.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fields | No | Comma-separated fields to return | |
| limit | No | Number of results to return | |
| after | No | Pagination cursor for next page |
Implementation Reference
- src/tools/rules.ts:15-23 (handler)Handler function for the list_rules tool. Calls the Facebook Ads API endpoint /adrules_library to list automated rules for the ad account, with support for fields, limit, and pagination (after cursor). Returns JSON response with rate limit info.
async (params) => { try { const { data, rateLimit } = await client.get(`${client.accountPath}/adrules_library`, { ...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/rules.ts:10-14 (schema)Zod schema definitions for list_rules input parameters: fields (optional string), limit (optional number, default 25), after (optional string for pagination cursor).
{ fields: z.string().optional().describe("Comma-separated fields to return"), limit: z.number().optional().default(25).describe("Number of results to return"), after: z.string().optional().describe("Pagination cursor for next page"), }, - src/tools/rules.ts:7-23 (registration)Registration of the list_rules tool via server.tool() with name 'list_rules' and description 'List automated rules for the ad account.'
server.tool( "list_rules", "List automated rules for the ad account.", { fields: z.string().optional().describe("Comma-separated fields to return"), limit: z.number().optional().default(25).describe("Number of results to return"), after: z.string().optional().describe("Pagination cursor for next page"), }, async (params) => { try { const { data, rateLimit } = await client.get(`${client.accountPath}/adrules_library`, { ...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 }; } } );