get_lead
Retrieve lead details by ID from Meta Ads campaigns. Provide the lead ID to access specific lead data.
Instructions
Get details of a specific lead by ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lead_id | Yes | Lead ID | |
| fields | No | Comma-separated fields to return |
Implementation Reference
- src/tools/leads.ts:26-42 (registration)The get_lead tool is registered via server.tool() in registerLeadTools().
// ─── get_lead ────────────────────────────────────────────── server.tool( "get_lead", "Get details of a specific lead by ID.", { lead_id: z.string().describe("Lead ID"), fields: z.string().optional().describe("Comma-separated fields to return"), }, async ({ lead_id, ...params }) => { try { const { data, rateLimit } = await client.get(`/${lead_id}`, { ...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:34-42 (handler)The handler function that executes the tool logic — calls client.get() with the lead_id, returns JSON response with rate limit info.
async ({ lead_id, ...params }) => { try { const { data, rateLimit } = await client.get(`/${lead_id}`, { ...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:30-33 (schema)Input schema for get_lead: requires lead_id (string), optional fields (string).
{ lead_id: z.string().describe("Lead ID"), fields: z.string().optional().describe("Comma-separated fields to return"), }, - src/index.ts:68-68 (registration)The top-level registration call in the main server setup.
registerLeadTools(server, client); - src/services/ads-client.ts:180-185 (helper)The AdsClient.get() method used by the handler to make the API request.
async get( path: string, params?: Record<string, unknown> ): Promise<ClientResponse> { return this.request("GET", path, params); }