Log inStart Free Trial
easyCoexistence Official APIs

Give a Claude Agent SDK agent Instagram, Facebook, TikTok and WhatsApp tools

A Claude Agent SDK agent gets Instagram, Facebook, TikTok and WhatsApp tools when you add easyCoexistence's MCP server to mcpServers as type http, with https://easycoexistence.com/api/mcp and an OAuth access token in a Bearer header, then allow its tools in allowedTools. The agent publishes, schedules, replies to comments and DMs and reads insights through each network's official API, with no Meta app review or TikTok audit on your side.

type: "http"

The mcpServers type for a Streamable HTTP server passed in code; JSON config files also accept streamable-http.

mcp__easycoexistence__

The prefix of this server's tool names under the SDK's mcp__<server>__<tool> convention, as allowedTools writes them.

needs-auth

The status the init message gives a server that asks for sign-in when the SDK has no token; the SDK opens no browser.

acceptEdits

A permission mode that does not auto-approve MCP tools; Anthropic recommends allowedTools for MCP access instead.

30 seconds

The SDK's default MCP connection timeout, raised with the MCP_TIMEOUT environment variable in milliseconds.

60 days

Life of an easyCoexistence refresh token; each refresh returns a new one beside a 1-hour access token.

How do you add easyCoexistence to an Agent SDK agent?

With one entry in mcpServers and the tools it may call in allowedTools. The key you give the server, easycoexistence here, becomes the middle of each tool's name: mcp__easycoexistence__publish_tiktok_post, mcp__easycoexistence__reply_to_comment and so on. type http selects the Streamable HTTP transport, which easyCoexistence's server speaks, and headers carries the OAuth access token as a Bearer token.

MCP tools need permission before Claude can call them. Without an allowedTools entry the agent sees the easyCoexistence tools and cannot use them; mcp__easycoexistence__* allows them all, and a list of names allows only those. The init message reports each server's status at the start of the run, and a run carries on without the tools of a server that is unavailable, so the example stops when easyCoexistence shows needs-auth or failed. A pending status is not a failure: the server may still be connecting.

TypeScript: the server, three allowed tools and a status check
import { query } from "@anthropic-ai/claude-agent-sdk";

const token = await freshAccessToken(); // your OAuth step: see the next section

for await (const message of query({
  prompt: "Schedule this video as a TikTok post for 9am Lisbon time tomorrow: https://cdn.example.com/launch.mp4",
  options: {
    mcpServers: {
      easycoexistence: {
        type: "http",
        url: "https://easycoexistence.com/api/mcp",
        headers: { Authorization: "Bearer " + token },
      },
    },
    allowedTools: [
      "mcp__easycoexistence__list_social_accounts",
      "mcp__easycoexistence__publish_tiktok_post",
      "mcp__easycoexistence__list_scheduled_posts",
    ],
  },
})) {
  if (message.type === "system" && message.subtype === "init") {
    const ec = message.mcp_servers.find((s) => s.name === "easycoexistence");
    if (ec?.status === "needs-auth" || ec?.status === "failed") {
      throw new Error("easyCoexistence MCP server: " + ec.status);
    }
  }
  if (message.type === "result" && message.subtype === "success") {
    console.log(message.result);
  }
}

How does the agent sign in, since the SDK opens no browser?

Your application does the sign-in, and the agent receives a token. The Agent SDK runs no interactive OAuth flow: when a server asks for authorization and no token is available, it marks the server needs-auth and the run goes on without those tools. easyCoexistence's MCP endpoint takes OAuth 2.1 access tokens only, never an ec_live_ API key, so there are two ways to supply one.

On a server, complete easyCoexistence's OAuth flow in your own app: dynamic client registration, the account owner's sign-in with PKCE S256, then tokens from https://easycoexistence.com/api/oauth/token. Store the refresh token, and before each run trade it for an access token, which lasts 1 hour; each refresh also returns a new refresh token, good for 60 days, so save that too. On a machine where you work, you can instead sign in to the server once from an interactive Claude Code session, with claude mcp add and then /mcp, before the run. A password change, a reset or "log out of all other devices" on easyCoexistence ends either connection.

Python: a fresh access token before each run
import asyncio
import httpx
from claude_agent_sdk import query, ClaudeAgentOptions, ResultMessage

TOKEN_URL = "https://easycoexistence.com/api/oauth/token"

def fresh_access_token() -> str:
    r = httpx.post(TOKEN_URL, data={
        "grant_type": "refresh_token",
        "refresh_token": load_refresh_token(),  # from your secret store
    })
    r.raise_for_status()
    tokens = r.json()
    save_refresh_token(tokens["refresh_token"])  # a new one each time, valid 60 days
    return tokens["access_token"]  # valid 1 hour

async def main() -> None:
    options = ClaudeAgentOptions(
        mcp_servers={
            "easycoexistence": {
                "type": "http",
                "url": "https://easycoexistence.com/api/mcp",
                "headers": {"Authorization": f"Bearer {fresh_access_token()}"},
            }
        },
        allowed_tools=[
            "mcp__easycoexistence__list_social_accounts",
            "mcp__easycoexistence__list_social_posts",
            "mcp__easycoexistence__get_social_insights",
        ],
    )
    async for message in query(prompt="Compare this week's reach on our Instagram and TikTok accounts.", options=options):
        if isinstance(message, ResultMessage) and message.subtype == "success":
            print(message.result)

asyncio.run(main())

Which easyCoexistence tools should the agent be allowed to use?

The ones its job needs, named in allowedTools, which grants exactly those and nothing more. Anthropic advises it over permission modes: acceptEdits does not approve MCP tools, and bypassPermissions approves them but also lifts most other safety prompts, while disallowedTools denies a tool outright. A reporting agent needs only reads; a community agent adds replies and hiding; a publishing agent adds the publish tools and the posts queue. The SDK's tool search, on by default, keeps a large tool set's definitions out of context until Claude needs one, which suits a server with more than 30 tools.

The agent sees the tools for the networks on your easyCoexistence account. Each takes an account_id from list_social_accounts, so name the account in the prompt when several are connected.

list_social_accountsThe connected channels and their health, and each account_id
publish_instagram_postPhotos, carousels of 2 to 10, Reels and Stories, now or with scheduled_at
publish_facebook_postPage posts with text, a link, a photo or a video
publish_tiktok_postVideos of 3 to 600 seconds, or photo posts of 1 to 35 images
list_social_comments, reply_to_commentRead a post's comments and answer in public, or privately on Instagram and Facebook
send_social_dmInstagram Direct or Messenger, to someone who wrote in the last 24 hours
get_social_insightsAccount or post metrics on Instagram, Facebook and TikTok
create_comment_rule, create_automationReplies that keep running on easyCoexistence after the agent stops

How does a new comment or DM start a run?

Through your own HTTPS endpoint, since an agent runs only when your code calls query. set_social_webhook_destination, or PUT /channels/{id}/webhook on the REST API, points an Instagram or Facebook account's comments, mentions and DMs, or a TikTok account's comments, at your URL and returns a signing secret once. Each delivery carries an X-EC-Signature header with t and v1, where v1 is an HMAC-SHA256 of the timestamp, a dot and the raw body; reject timestamps older than 5 minutes. Answer 2xx at once and queue the event, because relayed events are passed on once, with no retry and no copy kept.

A worker then calls query with the event in the prompt and only the tools the answer needs: reply_to_comment, or send_social_dm for a DM inside Meta's 24-hour window. On TikTok, reply_to_comment posts in public and needs the video's id as post_id. Replies that must go out with no agent running belong in automations and comment-to-DM rules, which run on easyCoexistence around the clock.

Can one agent serve several clients, or a SaaS's customers?

Several clients, yes. One easyCoexistence account holds the channels of as many clients as you connect, each billed as one connection, and list_social_accounts returns them all, so an agency's agent works across clients by naming the account in each task. Clients connect from a link they open, with their own Instagram, Facebook or TikTok sign-in.

A SaaS whose customers each get an agent needs one more boundary. The OAuth token reaches each channel on the account, and allowedTools filters tools, not accounts. Connect customers through the Partner API, which tags each channel with your external_ref, and give each customer's agent an in-process SDK MCP server of your own whose tools call easyCoexistence's REST API with your ec_live_ key and that customer's channel_id. Claude then acts only on the channels your code chose, while easyCoexistence holds the approvals, the tokens and the monitoring underneath.

How to set it up

  1. Connect the accountsSign in to easyCoexistence and connect Instagram, Facebook or TikTok with each network's own login, or have customers connect through the Partner API.
  2. Get a tokenComplete easyCoexistence's OAuth sign-in in your app and store the refresh token, or sign in once from Claude Code's /mcp on the same machine.
  3. Configure the agentAdd easycoexistence to mcpServers with type http, the URL and a Bearer header, and list the tools it may use in allowedTools.
  4. Check and runRead the init message, stop on needs-auth or failed, and refresh the access token before each run.

Common mistakes

  • Leaving the easyCoexistence tools out of allowedTools. Claude sees them and cannot call them; add their mcp__easycoexistence__ names, or mcp__easycoexistence__* for the whole server.
  • Relying on permissionMode acceptEdits for these tools. It approves file edits and filesystem commands only, so MCP tools still need allowedTools.
  • Starting a server run with no token in headers. The SDK opens no browser, reports needs-auth and carries on without the tools, so the agent may answer without having acted.
  • Building the options once in a long-lived worker. The access token in headers expires after an hour; refresh it and build new options for each run.
Doing this with EasyCoexistence

easyCoexistence gives Claude Agent SDK agents reach to Instagram, Facebook, TikTok and WhatsApp: one MCP server with more than 30 tools behind a single mcpServers entry, signed events for comments and DMs, and a Partner API for customers' accounts, on a Meta Tech Provider app and its own TikTok app, with each connection monitored. US$ 9 to US$ 0.75 per connection a month, falling as you add connections, with the first 3 days free.

easyCoexistence is a multichannel API and MCP server that connects AI agents such as Claude and ChatGPT to WhatsApp, Instagram, TikTok, Facebook, Google Business Profile and more. On WhatsApp it uses Coexistence: the business keeps using its number in the WhatsApp Business app while the AI works through Meta's official API.

Frequently asked questions

Does the Agent SDK need an easyCoexistence API key?

No. The MCP server signs in with OAuth, and the access token goes in the Authorization header. An ec_live_ key is for code that calls the REST API, such as tools of your own.

Can the agent reply to customers when it is not running?

Not by itself. Comment-to-DM rules and automations, which the agent can set up with create_comment_rule and create_automation, run on easyCoexistence and keep replying when no query is open.

Can the agent post a video from its working directory?

Not directly. The publishing tools fetch media from a public HTTPS link, so upload the file to storage the network can reach and pass its URL.

How much does easyCoexistence cost for an Agent SDK agent?

US$ 9 to US$ 0.75 per connected account each month, depending on how many you connect, the same on every network and with every tool included. Anthropic bills the agent's model usage separately, and the first 3 days are free.

Keep reading

Connect your first channel in two minutes.

No platform reviews to wait for. Connect WhatsApp, Instagram, TikTok or another channel, then ask your AI to post, reply or report, and watch it work.

  • 3 days free
  • Cancel any time
  • Official APIs only
  • Monitored 24/7

Verified on