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

A LangChain agent that drafts X threads

LangChain is often used for pipelines where one step researches and another writes. Adding X as an output is where teams get nervous, because a chain has no taste. Load the SocialHandoff MCP tools with langchain-mcp-adapters and the final step becomes draft_post, not publish. The chain can research, summarize, and draft as much as you like; a person approves the result, and the audit log records which agent key wrote it.

Prompt

You are the social step of a research pipeline. Given the summary of this week's top 3 papers on retrieval, draft one X thread: a hook tweet, one tweet per paper with the key finding, and a closing tweet. Call draft_post once with networks ['x'].

How to do it

  1. Mint a key Create a key for the pipeline, scoped to X with the draft permission.
  2. Load the tools Use MultiServerMCPClient from langchain-mcp-adapters with transport streamable_http, url https://app.socialhandoff.com/mcp, and an Authorization header. Call get_tools().
  3. Bind them to the agent Pass the tools to your agent, for example create_react_agent, alongside your research tools.
  4. Or call REST directly If you prefer a plain tool, wrap POST https://app.socialhandoff.com/v1/posts with body, thread, networks, and mode submit in a @tool function.
  5. Review the output Check drafts in the inbox. Reject with a reason so you can feed it back into the prompt.

Example draft

1/ Three retrieval papers worth your time this week, each with one finding you can use.

2/ Paper 1: re-ranking with a small model after BM25 beat dense-only retrieval on long documents.

3/ Paper 2: chunking by headings, not fixed tokens, cut wrong-section answers by a third.

4/ Paper 3: caching query embeddings made eval runs cheaper with no change in scores. Links in replies.

Gotchas

  • Chains can call a tool more than once. Pass an idempotency key in REST calls, or instruct the agent to call draft_post exactly once, so retries do not create duplicate drafts.
  • Each tweet in the thread is validated against X's weighted 280 count. Have the chain return a list, not one string you split later.
  • Do not give the pipeline an owner key. Agent keys cannot approve, which is the point.
X
  • Character limit: 280 weighted characters for standard accounts. Most CJK characters and many emoji count as 2. Premium accounts can post longer, but SocialHandoff checks against 280.
  • Links: Every URL is wrapped by t.co and counts as 23 characters, whatever its real length.
  • Media per post: Up to 4 images, or 1 GIF, or 1 video.
  • File sizes: Images up to 5 MB, GIFs up to 15 MB, video up to 512 MB (uploaded in chunks).
Schedule tweets and X threads with a human approval step

Frequently asked questions

MCP adapters or REST: which should I use?
MCP gives you all the tools with descriptions the model already understands. REST is simpler if you only need one call and want full control over the payload.
Can the chain learn from rejections?
You can read past posts back with list_posts and adjust the prompt, or store voice rules and banned topics in brand memory so every run starts from them.

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