get_form_leads
Retrieve leads submitted through a lead generation form. Specify form ID, filter fields, and paginate results as needed.
Instructions
Get leads submitted through a lead generation form.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| form_id | Yes | Lead form ID | |
| 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/leads.ts:7-24 (handler)The handler for 'get_form_leads' tool. Registers the tool via server.tool() with the name 'get_form_leads'. It accepts form_id (required), fields, limit (default 25), and after (pagination cursor). Makes a GET request to /{form_id}/leads via the AdsClient and returns the JSON response with rate limit info.
server.tool( "get_form_leads", "Get leads submitted through a lead generation form.", { form_id: z.string().describe("Lead form ID"), 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 ({ form_id, ...params }) => { try { const { data, rateLimit } = await client.get(`/${form_id}/leads`, { ...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/leads.ts:10-15 (schema)Input schema for 'get_form_leads' using Zod: form_id (string, required), fields (optional string), limit (optional number, default 25), after (optional string for pagination).
{ form_id: z.string().describe("Lead form ID"), 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/leads.ts:7-24 (registration)Registration via server.tool() inside registerLeadTools(), which is called from src/index.ts at line 68.
server.tool( "get_form_leads", "Get leads submitted through a lead generation form.", { form_id: z.string().describe("Lead form ID"), 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 ({ form_id, ...params }) => { try { const { data, rateLimit } = await client.get(`/${form_id}/leads`, { ...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/index.ts:68-68 (registration)Call site where registerLeadTools(server, client) is invoked, registering all lead tools including 'get_form_leads'.
registerLeadTools(server, client);