Integration guide

Use ClipEmber from a LangChain agent

Connect a LangChain agent to the ClipEmber MCP server with langchain-mcp-adapters and an API key, with the preview-and-confirm step before anything posts.

Uses the MCP server·Python·updated

01Before you start

An API key, connected accounts, and the server address.

An API key
Create it in the app (API keys). New keys come with Pro and Agency, and during the 7-day Pro trial; a key you already have keeps working on any plan. The secret is shown once, so put it straight into your tool’s credential store. It goes in the X-API-Key header of every call.
Connected accounts
Connect TikTok, YouTube, Instagram and the rest in the app, through each network’s own sign-in. A key or an agent can’t sign in to a network for you. Each account has an id you pass as connectionId.
Server
https://clipember.com/api/mcp, streamable HTTP. Send the key as X-API-Key. The OAuth sign-in on the MCP page is for chat apps; code uses the key.
Packages
langchain-mcp-adapters to load MCP tools, LangChain itself, and the package for your chat model.
pip install langchain-mcp-adapters langchain langchain-openai

There is no ClipEmber package to install for this. Your code talks to the hosted MCP server at https://clipember.com/api/mcp — the same server Claude and ChatGPT connect to — over streamable HTTP, with your API key in a header.

02Connect

Load the tools, hand them to an agent.

MultiServerMCPClient turns every ClipEmber tool into a LangChain tool. Any chat model that can call tools works; swap the model string for yours.

agent.py
import asyncio
import os

from langchain.agents import create_agent
from langchain_mcp_adapters.client import MultiServerMCPClient

RULES = """You schedule social video posts with the ClipEmber tools.
- Before anything that schedules or posts now, call the tool once and show the user
  the preview it returns (networks, accounts, time, skipped networks, warnings).
- Only after the user says yes, call the same tool again with exactly the same
  arguments plus confirmed: true and the confirmationToken from the preview.
- Pass an idempotencyKey (for example a UUID) to tools that create things, and
  reuse it if you retry the same call.
- If a tool returns an error code, call clipember_explain_error with it and tell
  the user what to do. Never guess a TikTok audience: if the user didn't say who
  can see a TikTok post, leave it out and say the post waits for their choice."""

client = MultiServerMCPClient({
    "clipember": {
        "transport": "streamable_http",
        "url": "https://clipember.com/api/mcp",
        "headers": {"X-API-Key": os.environ["CLIPEMBER_API_KEY"]},
    }
})


async def main() -> None:
    tools = await client.get_tools()  # every clipember_* tool
    agent = create_agent("openai:gpt-4.1", tools, system_prompt=RULES)

    messages = [{"role": "user", "content":
                 "Schedule media <mediaId> to my YouTube Shorts for Friday 6 pm, "
                 "caption 'Launch day'."}]
    result = await agent.ainvoke({"messages": messages})
    print(result["messages"][-1].content)  # the preview, waiting for a yes

    # The user's answer is the next turn; the agent confirms with the token.
    messages = result["messages"] + [{"role": "user", "content": "Yes, schedule it."}]
    result = await agent.ainvoke({"messages": messages})
    print(result["messages"][-1].content)


asyncio.run(main())
Fewer tools
The server has many tools. To keep the model focused, filter the list by name before creating the agent, e.g. keep clipember_list_platform_connections, clipember_upload_media_from_url, clipember_get_media, clipember_create_post, clipember_list_scheduled_posts and clipember_explain_error.

03Confirm before posting

The first call previews; only the second one posts.

This is enforced by the server, not by your prompt: a model can't schedule or publish in one call.

1. Preview
clipember_create_post with mode schedule or now (and other tools that schedule clips, a series, or move a draft into the schedule) creates nothing on the first call. It returns a preview with confirmation_required: true, a confirmationToken and expiresAt. The token is also in the tool’s text, so the model sees it.
2. The user says yes
Your app shows the preview and waits for a person. That reply is a new turn of the conversation.
3. Confirm
The model calls the same tool with exactly the same arguments plus confirmed: true and the token. The token lasts 10 minutes and fits only those arguments and your account; otherwise the call is refused with confirmation_invalid or confirmation_expired and nothing is created. In LangChain that’s the second ainvoke above: the same message history plus the user’s yes, so the model still has the token.
Drafts
Mode draft skips the preview. If your agent runs with nobody to ask, let it save drafts and have a person schedule them in the app — or use the REST API, where your own code decides.

04Errors and retries

Branch on the code, not the message.

Tool errors
A failed tool call comes back as an error result: a message written for a person, and { error: { code, retryable } } in its structured content. retryable: true means the same call can work later (for example rate_limited); false means something has to change first.
Ask the server
clipember_explain_error takes a code and returns what it means, whether to retry and what to do — the same catalog as API error codes.
Safe retries
clipember_create_post, clipember_schedule_clips, clipember_create_clip_request and clipember_upload_media_from_url take an idempotencyKey. The same key and arguments within 10 minutes return the first result instead of a duplicate; the same key with other arguments gets idempotency_key_reused. A failed call doesn’t use up the key.
Limits
The agent runs as you: the same plan limits, monthly limits and per-minute rate limit as the app and the REST API.

05What to ask

A first prompt to try.

Read first
“Which accounts do I have connected, and what is scheduled for next week?” — uses clipember_list_platform_connections and clipember_list_scheduled_posts, changes nothing.
Then post
“Import https://example.com/launch.mp4 and schedule it to my YouTube Shorts for Friday 6 pm with the caption ‘Launch day’.” — clipember_upload_media_from_url, then clipember_create_post, which stops at the preview until the user confirms. The post can be created while the video is still importing; it waits for the file.

06Reference

Where the details live.

MCP server
Setup and every tool, grouped by job, with the TikTok rule and what stays in the app.
OpenAPI
The machine-readable description: /api/v1/openapi.json.
Error codes
Every code with its HTTP status, whether to retry and what to do.

Try it with a real account.

Every new account gets 7 days of Pro, API keys included. No card.