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

Draft and schedule Threads posts from LangChain

A LangChain pipeline that repurposes content can draft Threads posts alongside other networks. Load SocialHandoff's tools with the MCP adapter, and the agent writes a Threads version of a long piece in its own voice, capped at 500 characters. The approval inbox is where you catch anything that reads wrong. Single posts, carousels, and reply chains are all supported, and drafts wait in the inbox until you approve them.

Prompt

Pipeline: take our latest podcast transcript, find the most quotable moment, and call draft_post for threads with a short post quoting it and linking the episode example.com/podcast/57. Under 400 characters.

How to do it

  1. Mint a Threads agent key In https://app.socialhandoff.com, open Connections, connect your Threads account, then create an agent key scoped to Threads with draft permission only. Copy the key when it is shown; only its hash is stored.
  2. Install the MCP adapter Add langchain-mcp-adapters and create a MultiServerMCPClient with a streamable_http connection to https://app.socialhandoff.com/mcp and a bearer header.
  3. Load tools into the agent Call get_tools() and pass them to your agent. Keep the key scoped to Threads and draft so the model only sees what it needs.
  4. Run the pipeline Feed the chain its source material, let it call draft_post for Threads, and read the returned post id. Or skip MCP and POST to /v1/posts from a plain tool.

Example draft

"The best onboarding email I ever sent had no links in it. It just asked what they were trying to get done." From this week's episode with a founder who grew to 10k users on a support inbox and a spreadsheet. Listen: example.com/podcast/57

Gotchas

  • A draft too long for one post can go out as a reply-chain thread, with each part published as a reply to the one before. Every part has its own 500-character limit, and a carousel of 2 to 20 images or videos can lead the chain.
  • Threads allows 250 posts per account in any 24 hours. The quota is checked before each publish, so a post that would go over it is stopped before it is sent rather than failing at the network.
  • Threads fetches images and video from your instance at signed, expiring URLs, so you do not need a separate public media host. The API itself must be reachable over public HTTPS; an instance that only runs on localhost cannot publish media to Threads.
  • The adapter loads every tool the key allows. Scope the key to Threads and draft permission so the model cannot reach analytics or scheduling tools you did not plan for.
Threads
  • Character limit: 500 characters per post. Emoji count as their UTF-8 bytes, so an emoji can use up to 4 characters of the limit.
  • Links: Up to 5 links per post. Threads generates a preview for the first one.
  • Carousels: 2 to 20 images or videos in one carousel post.
  • Image files: JPEG or PNG, up to 8 MB. Threads fetches each file from a URL at publish time.
Threads scheduler for agent drafts you approve first

Frequently asked questions

Do I have to use MCP with LangChain?
No. You can wrap POST /v1/posts in a plain LangChain tool, or use the TypeScript SDK. MCP saves you writing tool schemas.
Should a LangChain agent auto-publish to Threads?
Only once it has earned it. Start the agent draft-only for Threads and promote it on the trust ladder after a run of clean approvals; a guardrail failure demotes it immediately.
What happens if a Threads publish fails?
The post is marked failed with the error, a post.failed webhook fires if you registered one, and you can fix and retry from the inbox.

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