MCP (streamable HTTP) via MCPServerAdapter

Build a CrewAI content crew that drafts posts for human approval

CrewAI's MCPServerAdapter loads tools from an MCP server into your crew. Connect it to SocialHandoff and your writer agent can draft posts, while the approval inbox stays the final say.

How to do it

  1. Mint a key for the crew In https://app.socialhandoff.com, open Connections, add an agent for the crew, and grant draft on the target networks.
  2. Install CrewAI tools with MCP support Run pip install crewai 'crewai-tools[mcp]'.
  3. Describe the server Build server_params with the /mcp URL, transport streamable-http, and an Authorization header read from an environment variable.
  4. Open the adapter Use MCPServerAdapter as a context manager so the connection closes when the crew finishes. Give the tools only to the agent that writes.
  5. Kick off the crew Run crew.kickoff() and review the drafts in the SocialHandoff inbox.
import os

from crewai import Agent, Crew, Task
from crewai_tools import MCPServerAdapter

server_params = {
    "url": "https://app.socialhandoff.com/mcp",
    "transport": "streamable-http",
    "headers": {"Authorization": "Bearer " + os.environ["SOCIAL_AGENT_KEY"]},
}

with MCPServerAdapter(server_params, connect_timeout=60) as tools:
    writer = Agent(
        role="Social writer",
        goal="Draft on-brand posts and leave them for human approval",
        backstory="You follow the brand memory exactly and never schedule.",
        tools=tools,
    )
    task = Task(
        description="Draft an X post and a Mastodon post about this week's release notes.",
        expected_output="The ids of the pending drafts",
        agent=writer,
    )
    Crew(agents=[writer], tasks=[task]).kickoff()

A crew shape that suits approval

CrewAI is built around roles. A useful content crew splits the work:

  • A researcher with no SocialHandoff tools reads your changelog, docs, or a URL and writes a brief.
  • A writer with the SocialHandoff tools turns the brief into drafts, one per network, after reading brand memory.
  • An optional editor with only preview_posts and list_posts checks the drafts and reports problems.

Only the writer needs draft_post. Giving tools to the agents that need them keeps a confused researcher from creating drafts, and it keeps prompts shorter.

Filtering tools

The adapter returns every tool the server lists. You can pick by name, for example tools["draft_post"], or pass only the ones you want to each agent. The server exposes planning, drafting, scheduling, preview, list, insights, and brand memory tools; an agent key gets 403 on approval and on update_brand_memory.

Example tasks

  • "Turn the release brief into a 3-part X thread and a single LinkedIn post. Keep each part under the network limit."
  • "Draft 5 Bluesky posts, one per tutorial in the brief, each with a link and alt text for any image."
  • "List pending posts for Mastodon and write a short report of which ones duplicate each other."

Running on a schedule

Crews often run from cron or a queue. Each run should use the same agent key so the audit log groups its drafts, and a per-account daily limit guardrail keeps a misfiring schedule from flooding the inbox. If the kill switch is on, scheduling calls return 423 and the crew should stop.

Troubleshooting

  • Adapter hangs on connect: raise connect_timeout and check the URL ends in /mcp.
  • SSE errors: set "transport": "streamable-http" explicitly; otherwise the adapter may assume a different transport.
  • 401: the environment variable was empty when the adapter opened.
  • Tools missing: upgrade crewai-tools; MCP support needs the mcp extra.

Guides by network: CrewAI for X, CrewAI for LinkedIn, CrewAI for Bluesky, CrewAI for Mastodon, and CrewAI for Threads.

Frequently asked questions

How does CrewAI connect to SocialHandoff?
Through MCPServerAdapter from crewai-tools, using the streamable-http transport, the /mcp URL, and an Authorization header with your agent key.
Should every agent in the crew get the SocialHandoff tools?
No. Give draft_post only to the writing agent. Other agents can work from text, or get read-only tools like list_posts and preview_posts.
Will a crew publish posts on its own?
Not while the agent is draft-only, which is the default. Drafts wait in the approval inbox for a person.

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