Integration guide
Use ClipEmber from the OpenAI Agents SDK
Connect an OpenAI Agents SDK agent to the ClipEmber MCP server with MCPServerStreamableHttp and an X-API-Key header, with a confirm step before posting.
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-Keyheader 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 asX-API-Key. The OAuth sign-in on the MCP page is for chat apps; code uses the key.- Package
pip install openai-agents
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
MCPServerStreamableHttp with the key in its headers.
The server object opens the connection; the agent lists and calls its tools.
- agent.py
import asyncio import os from agents import Agent, Runner from agents.mcp import MCPServerStreamableHttp 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.""" async def main() -> None: async with MCPServerStreamableHttp( name="ClipEmber", params={ "url": "https://clipember.com/api/mcp", "headers": {"X-API-Key": os.environ["CLIPEMBER_API_KEY"]}, }, cache_tools_list=True, ) as clipember: agent = Agent(name="Scheduler", instructions=RULES, mcp_servers=[clipember]) result = await Runner.run( agent, "Schedule media <mediaId> to my YouTube Shorts for Friday 6 pm, " "caption 'Launch day'.", ) print(result.final_output) # the preview, waiting for a yes # The user's answer is the next turn; the agent confirms with the token. follow_up = result.to_input_list() + [{"role": "user", "content": "Yes, schedule it."}] result = await Runner.run(agent, follow_up) print(result.final_output) asyncio.run(main())- Fewer tools
- The SDK can filter an MCP server’s tools by name (a tool filter on the server object); keep the ones the task needs, e.g.
clipember_create_post,clipember_upload_media_from_url,clipember_list_platform_connectionsandclipember_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_postwith modescheduleornow(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 withconfirmation_required: true, aconfirmationTokenandexpiresAt. 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: trueand the token. The token lasts 10 minutes and fits only those arguments and your account; otherwise the call is refused withconfirmation_invalidorconfirmation_expiredand nothing is created. In the Agents SDK that’s the secondRunner.runabove, fedresult.to_input_list()so the agent still has the token. - Drafts
- Mode
draftskips 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: truemeans the same call can work later (for examplerate_limited);falsemeans something has to change first. - Ask the server
clipember_explain_errortakes acodeand 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_requestandclipember_upload_media_from_urltake anidempotencyKey. The same key and arguments within 10 minutes return the first result instead of a duplicate; the same key with other arguments getsidempotency_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_connectionsandclipember_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, thenclipember_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.
- API reference
- Every endpoint: posts, your own videos, webhooks, idempotency.
- 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.