Prerequisites Before you begin, create an account and get your API Key.

Getting started

Connect to Plai to create and manage Facebook, Instagram, and LinkedIn ad campaigns through AI agents.
1

Install the SDKs (optional)

pip install klavis
2

Create a server instance

from klavis import Klavis
from klavis.types import McpServerName

klavis_client = Klavis(api_key="YOUR_API_KEY")

# Create a Plai MCP server instance
plai_server = klavis_client.mcp_server.create_server_instance(
    server_name=McpServerName.PLAI,
    user_id="user123"
)
Response Information: The API returns:
  • serverUrl: The URL for connecting your MCP client to Plai
  • instanceId: Unique identifier for your server instance
3

Configure API Key

# Set the Plai API key for your instance
response = klavis_client.mcp_server.set_instance_auth(
    instance_id=plai_server.instance_id,
    auth_data={
        "token": "YOUR_PLAI_API_KEY"
    }
)
🎉 Your Plai MCP Server is ready! You can now use your MCP server URL with any MCP-compatible client.

Available Tools

Tool NameDescription
plai_create_user_profileCreate a new user profile on the Plai platform. This allows onboarding new users into the system.
plai_get_user_profileRetrieve the current user profile using their email address.
plai_create_linkGenerate a link that allows users to connect their Ad accounts (Facebook/Instagram or LinkedIn).
plai_create_leads_dynamicCreate a dynamic Facebook Lead Ad campaign. Lead generation ads collect contact information directly from users on Meta platforms.
plai_get_campaign_insightsFetch campaign insights for a specific campaign with performance metrics.
plai_update_campaign_statusUpdate the status of a campaign (pause, activate, or delete).
plai_check_leadform_tosCheck whether the user has accepted the Terms of Service for their connected Facebook page.
plai_create_leadformCreate a lead form for Facebook Lead Ads with predefined questions (EMAIL and FULL_NAME).
plai_get_leadform_listGet a list of all lead forms for the user.
plai_search_targeting_locationsSearch for advertising target locations based on search query. This helps in identifying relevant locations to improve the accuracy and effectiveness of ad targeting.
For more details about tool input schema, use the get_tools API.

Next Steps