MCP (streamable HTTP) via langchain-mcp-adapters · TikTok

Build a LangChain agent that drafts TikTok posts for approval

A LangChain agent can match a library of short clips to trending questions in your niche and write captions for each. SocialHandoff handles the TikTok side: the agent attaches each video with attach_media by URL, creates drafts with mediaIds, and previews them with preview_posts. Every post waits in the approval inbox, where TikTok's consent text is shown before anyone approves.

Prompt

You manage TikTok for a language-learning app. From the clip library metadata, pick the clip that answers this week's most common learner question, upload it, and create a TikTok draft with a hook and 4 hashtags. Never create a TikTok post without a video.

How to do it

  1. Connect TikTok and mint a key In https://app.socialhandoff.com, open Connections, connect TikTok, then open TikTok settings on the account and choose visibility, comment/duet/stitch, and commercial disclosure. Then create an agent key named LangChain scoped to TikTok with draft and schedule permission.
  2. Load the tools Connect with MultiServerMCPClient from langchain-mcp-adapters with transport streamable_http, pointing at https://app.socialhandoff.com/mcp and sending the key as a bearer header. The agent gets attach_media, draft_post, schedule_post, and preview_posts.
  3. Attach media The agent calls attach_media through the MCP adapter with a public url (or base64 data up to 8 MB) and alt text for the video or up to 35 photos. From plain code, POST https://app.socialhandoff.com/v1/media/import does the same. Pass the ids to draft_post in mediaIds.
  4. Run the agent Invoke the agent with the clip metadata and the question list. It uploads the chosen clip and creates one draft.

Example draft

Why do Spanish speakers say "tengo hambre" and not "estoy hambre"?

Because hunger is something you have, not something you are. Same with thirst, cold, and fear.

#learnspanish #spanishtips #languagelearning #spanish

[Video: 29-second vertical clip from the library, chosen by the agent]

Gotchas

  • Photo posts are fetched by URL, so the domain serving your media must be verified in the TikTok developer portal. Videos upload as bytes and skip this.
  • Tell the agent in its instructions to call attach_media before draft_post for image and video networks. Otherwise it may produce text-only drafts that cannot be approved.
  • TikTok refuses text-only posts. The agent can draft the caption first, but approval and scheduling are refused until a video or photos are attached.
TikTok
  • Media: Every post needs one video or up to 35 photos. Text-only posts are not possible.
  • Video upload: Videos upload in chunks of 5 to 64 MB; smaller files go in one piece. Maximum duration depends on the creator account.
  • Photo posts: Up to 35 JPEG or WebP images, a title up to 90 characters, and a description up to 4,000 characters.
  • Required choices: TikTok requires a visibility setting with no default, comment/duet/stitch toggles, and a commercial content disclosure.
TikTok scheduler with approval and TikTok's required choices

Frequently asked questions

What does the reviewer see before approving?
The approval screen shows the caption, the media, the account's chosen settings, and TikTok's consent text, so the person approving knows exactly what will be posted.
Can the LangChain agent approve its own posts?
No. approve_post only works with owner keys, and an agent key can never approve its own draft.
Where do I choose who can see the video?
In Connections, TikTok settings reads the creator's live options and asks for visibility, comment, duet, stitch, and commercial content disclosure. Those choices apply to every post from that account.

Let your agents post. Keep the final say.

Connect your first agent in minutes. Every draft waits in your inbox until you approve it.

14 days free. No card required.

The hosted version is opening soon

Leave your email and we will send one message when hosted accounts open, with your 14-day trial ready. Want it today? Self-host it free from the repo.

Start free trial