The SSE protocol will be deprecated soon. Please use streamable-http as the connectionType moving forward.

Prerequisites

1. Create a Plai MCP Server

Use the following endpoint to create a new remote Plai MCP server instance:

Request

from klavis import Klavis
from klavis.types import McpServerName, ConnectionType

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="<YOUR_USER_ID>",
    platform_name="<YOUR_PLATFORM_NAME>",
    connection_type=ConnectionType.STREAMABLE_HTTP,
)

Response

{
  "serverUrl": "https://plai-mcp-server.klavis.ai/sse?instance_id=<instance-id>",
  "instanceId": "<instance-id>"
}
serverUrl specifies the endpoint of the Plai MCP server, which allows you to create and manage Facebook, Instagram, and LinkedIn ad campaigns.
instanceId is used for authentication and identification of your server instance.

2. Configure Plai API Key

To use the Plai MCP Server, you need to configure it with your Plai API key.

Setting up Plai API Key

curl --request POST \
  --url https://api.klavis.ai/mcp-server/instance/set-auth-token \
  --header 'Authorization: Bearer <YOUR_KLAVIS_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "instanceId": "<YOUR_INSTANCE_ID>",
  "authToken": "<YOUR_PLAI_API_KEY>"
}'

Response

{
  "success": true,
  "message": "<string>"
}

Explore MCP Server Tools