Skip to main content
Glama

create_lead_form

Create a lead generation form on a Facebook Page to collect user information with customizable questions and privacy policy.

Instructions

Create a new lead generation form on a Facebook Page. Requires pages_manage_ads permission.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
page_idYesFacebook Page ID
nameYesLead form name
questionsYesJSON array of questions. Each: {key: string, type: 'CUSTOM'|'EMAIL'|'PHONE'|'FULL_NAME'|'CITY'|'STATE'|'COUNTRY'|'ZIP'|'JOB_TITLE'|'COMPANY_NAME', label?: string}
privacy_policy_urlYesURL to privacy policy
follow_up_action_urlNoURL to redirect after submission
thank_you_pageNoJSON object: {title: string, body: string, button_text?: string, button_type?: 'VIEW_WEBSITE'|'DOWNLOAD'}

Implementation Reference

  • The handler function for the create_lead_form tool. It calls the Facebook Graph API POST /{page_id}/leadgen_forms with the provided parameters (name, questions, privacy_policy, follow_up_action_url, thank_you_page) to create a new lead generation form.
    // ─── create_lead_form ───────────────────────────────────────
    server.tool(
      "create_lead_form",
      "Create a new lead generation form on a Facebook Page. Requires pages_manage_ads permission.",
      {
        page_id: z.string().describe("Facebook Page ID"),
        name: z.string().describe("Lead form name"),
        questions: z.string().describe("JSON array of questions. Each: {key: string, type: 'CUSTOM'|'EMAIL'|'PHONE'|'FULL_NAME'|'CITY'|'STATE'|'COUNTRY'|'ZIP'|'JOB_TITLE'|'COMPANY_NAME', label?: string}"),
        privacy_policy_url: z.string().describe("URL to privacy policy"),
        follow_up_action_url: z.string().optional().describe("URL to redirect after submission"),
        thank_you_page: z.string().optional().describe("JSON object: {title: string, body: string, button_text?: string, button_type?: 'VIEW_WEBSITE'|'DOWNLOAD'}"),
      },
      async ({ page_id, name, questions, privacy_policy_url, follow_up_action_url, thank_you_page }) => {
        try {
          const params: Record<string, unknown> = {
            name,
            questions,
            privacy_policy: JSON.stringify({ url: privacy_policy_url }),
          };
          if (follow_up_action_url) params.follow_up_action_url = follow_up_action_url;
          if (thank_you_page) params.thank_you_page = thank_you_page;
          const { data, rateLimit } = await client.post(`/${page_id}/leadgen_forms`, 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 };
        }
      }
    );
  • Zod input schema for create_lead_form. Defines required fields: page_id, name, questions (JSON array), privacy_policy_url, and optional fields: follow_up_action_url, thank_you_page.
    {
      page_id: z.string().describe("Facebook Page ID"),
      name: z.string().describe("Lead form name"),
      questions: z.string().describe("JSON array of questions. Each: {key: string, type: 'CUSTOM'|'EMAIL'|'PHONE'|'FULL_NAME'|'CITY'|'STATE'|'COUNTRY'|'ZIP'|'JOB_TITLE'|'COMPANY_NAME', label?: string}"),
      privacy_policy_url: z.string().describe("URL to privacy policy"),
      follow_up_action_url: z.string().optional().describe("URL to redirect after submission"),
      thank_you_page: z.string().optional().describe("JSON object: {title: string, body: string, button_text?: string, button_type?: 'VIEW_WEBSITE'|'DOWNLOAD'}"),
    },
  • The registerLeadTools function in src/tools/leads.ts registers the create_lead_form tool via server.tool().
    export function registerLeadTools(server: McpServer, client: AdsClient): void {
      // ─── get_form_leads ────────────────────────────────────────
      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 };
          }
        }
      );
    
      // ─── 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 };
          }
        }
      );
    
      // ─── list_lead_forms ───────────────────────────────────────
      server.tool(
        "list_lead_forms",
        "List lead generation forms for a Facebook Page.",
        {
          page_id: z.string().describe("Facebook Page 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 ({ page_id, ...params }) => {
          try {
            const { data, rateLimit } = await client.get(`/${page_id}/leadgen_forms`, { ...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 };
          }
        }
      );
    
      // ─── create_lead_form ───────────────────────────────────────
      server.tool(
        "create_lead_form",
        "Create a new lead generation form on a Facebook Page. Requires pages_manage_ads permission.",
        {
  • src/index.ts:68-68 (registration)
    Registration call in the main entry point: registerLeadTools(server, client) is invoked at line 68.
    registerLeadTools(server, client);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must fully disclose behavioral traits. It only mentions the required permission and the basic creation action. It does not describe the return value, side effects, error handling, or any constraints beyond permission, leaving significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that conveys the essential information without any wasted words. It includes the action, resource, location, and a key prerequisite, making it efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 6 parameters (4 required), no output schema, and no annotations, the description is insufficiently complete. It lacks information about the return value, error scenarios, or any additional behavioral context needed for correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the baseline is 3. The description adds no parameter-level detail beyond what the schema already provides, thus not meeting the higher bar for compensation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly specifies the action (create), the resource (lead generation form), and the location (on a Facebook Page), distinguishing it from list/get siblings. It also mentions required permission, which adds clarity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description states a prerequisite (pages_manage_ads permission) but does not provide explicit guidance on when to use this tool versus alternatives or when not to use it. The context is clear, but no exclusions or alternative comparisons are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mikusnuz/meta-ads-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server