cloudflare-dns-mcp_list_page_rules
Retrieve and manage active or disabled redirect rules for a specified zone using structured commands, enabling efficient configuration and monitoring of Cloudflare page rules.
Instructions
List all page rules (redirects) for a zone
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| status | No | ||
| zone_name | Yes |
Implementation Reference
- src/tools/redirects.ts:30-45 (handler)Handler function that validates input using the schema, retrieves the zone ID by name, constructs a query for page rules with optional status filter, calls the Cloudflare API to list pagerules, and formats the JSON response in MCP content structure.handler: async (params: unknown) => { const { zone_name, status } = ListPageRulesInputSchema.parse(params); const zones = await client.get<Array<{ id: string; name: string }>>('/zones', { name: zone_name }); if (zones.length === 0) throw new Error(`Zone ${zone_name} not found`); const zoneId = zones[0].id; const query: any = {}; if (status) query.status = status; return { content: [ { type: "text", text: JSON.stringify(await client.get(`/zones/${zoneId}/pagerules`, query), null, 2) } ] }; },
- src/tools/redirects.ts:23-23 (schema)Zod input schema defining required zone_name (string) and optional status (enum: 'active' or 'disabled') for filtering page rules.const ListPageRulesInputSchema = z.object({ zone_name: z.string(), status: z.enum(['active','disabled']).optional() });
- src/tools/redirects.ts:127-127 (registration)Local registration of the tool under its name in the getRedirectTools() function's returned tools object, which is later imported and spread into the global tools map in src/index.ts.'cloudflare-dns-mcp/list_page_rules': listPageRulesTool,
- src/index.ts:25-30 (registration)Global aggregation of all tools including redirect tools (containing list_page_rules) into allTools object before mapping to sanitized names and registering with MCP server handlers.const allTools = { ...dnsTools.tools, ...securityTools.tools, ...sslCertTools.tools, ...echoTools.tools, ...redirectTools.tools,