Build a competitor-monitoring agent with Claude and the Caelario MCP server

Connect Claude Code or the Claude Agent SDK to Caelario, let the agent price and run an Instagram competitor snapshot, and keep the arithmetic in your own code. This guide shows the real tool calls from a Gymshark and Alo Yoga run, what they returned and cost, a weekly schedule and the Monday brief it produces.

1 real dataset in this guide
CLAUDE MCP COMPETITOR AGENT · 25 November 20261 real dataset
A robot at a desk watching three competitor cards through binoculars, with a calendar, a summary note and an alert bell
  1. 1
    13.8×Gymshark's median engagement vs Alo Yoga's
  2. 2
    11 of 60Gymshark items at 3× its median
  3. 3
    386Credits for the whole run
In short
  1. 01 · Connect the MCP server

    Connect Claude to Caelario's MCP server (https://mcp.caelario.com/mcp, or npx -y caelario-mcp@latest install claude for the local server). The agent finds a template with list_templates, prices it for free with plan_template, runs it with run_plan and waits with wait_for_extraction.

  2. 02 · Code computes, Claude writes

    Let code compute the medians and breakouts and let Claude write the brief from those numbers. Then check that every number in the brief appears in the computed facts.

  3. 03 · 225 credits per account

    The instagram-competitor template has a flat price of 225 credits per account. Our Gymshark and Alo Yoga run on 25 November 2026, charged at the earlier 200-credit price, cost 386 credits in total, including one 1-credit profile check.

  4. 04 · Keep pages small

    Page results small. One 25-row page of Instagram posts came to about 200,000 characters, because each row carries media URLs. Better still, have your code read the stored result.

  5. 05 · Weekly schedule

    For the weekly run, create_schedule takes a frequency, an IANA timezone and a start time. Pulling 12 posts from each of two accounts costs at most 24 credits a run.

On this page 17 sections
  1. 1.What does a Claude competitor-monitoring agent do
  2. 2.Which parts should Claude do
  3. 3.Connect Claude Code to the Caelario MCP server
  4. 4.Connect the Claude Agent SDK
  5. 5.How does the agent price a competitor snapshot
  6. 6.How does run_plan collect the data
  7. 7.Read results without filling the model's context
  8. 8.Keep the numbers honest
  9. 9.What did the agent find on Gymshark and Alo Yoga
  10. 10.What does the Monday brief look like
  11. 11.Run the agent every Monday
  12. 12.What does a run cost
  13. 13.What goes wrong in a real run
  14. 14.What does this agent not show
  15. 15.Start
  16. 16.Why build the agent on Caelario
  17. 17.Questions
01 · Guide

What does a Claude competitor-monitoring agent do?

Every Monday it looks at a few competitor accounts, finds the posts that did far better than usual, and writes a short brief for your team. In this guide a breakout is a post with at least 3 times the account's median engagement, where engagement is likes plus comments.

The agent has two jobs: collecting the data and writing about it. Collecting means choosing the right operations, checking the price, starting jobs and waiting for them. Claude does this well through the Caelario MCP server, and every tool call is visible in the transcript.

Arithmetic is a different job. A model reading 50 rows can misread a count or round a median differently each week. So the agent hands the rows to code, the code computes the numbers, and Claude writes only from those numbers.

We built this against two activewear accounts on Instagram, Gymshark and Alo Yoga, on 25 November 2026. Everything below, from tool inputs to credits, comes from that run. For setup and the full tool list, see the Caelario MCP server guide.

02 · Comparison

Which parts should Claude do, and which should code do?

Split the work so that each part is done by whatever is most reliable at it.

StageWho does itTools or code
Plan and priceClaudelist_templates, plan_template, estimate_credits. All free.
Approve the spendYou, or a cap in the agent's instructionsCompare estimated_credits or maximum_reserved_credits_total with your limit
CollectCaelario, started by Clauderun_plan or create_extraction, then wait_for_extraction
Read the rowsCodeGET /v1/jobs/{job_id}/export?format=json, or get_extraction_result in small pages
ComputeCodeMedians, 3× breakouts, posting pace, own posts versus collabs
WriteClaudeA brief written only from the computed JSON
CheckCodeEvery number in the brief must appear in the computed JSON
RepeatCaelariocreate_schedule with frequency: "weekly" and an IANA timezone

Discovery and estimate tools cost nothing. Credits are spent only when a job or plan runs.

03 · How it works

How do you connect Claude Code to the Caelario MCP server?

You have two options. The hosted server at https://mcp.caelario.com/mcp signs you in with OAuth in the browser, so the command contains no key. The local server runs through npx and uses a workspace key that the installer asks for in a hidden prompt. It needs Node.js 20 or newer.

Create a workspace at app.caelario.com/connect first. Never paste the key into the chat.

Add the server to Claude Code

Pick one. The .mcp.json file shares the hosted server with everyone who opens the project, and it holds no secret.

claude mcp add --transport http caelario https://mcp.caelario.com/mcp

Keep "type": "http" in .mcp.json. Claude Code's docs say an entry with a url but no type is a configuration error, and it is read as a stdio server.

To check the connection for free, ask: "Use Caelario to check my credit balance and list the research templates." Claude should call get_credit_usage and list_templates, and neither costs anything.

04 · How it works

How do you connect the Claude Agent SDK?

A scheduled script can't click Approve in a browser. So give the Agent SDK the local server and pass the key through the environment, as CAELARIO_API_KEY.

MCP tools must be listed in allowedTools (allowed_tools in Python). The SDK docs note that permissionMode: "acceptEdits" does not auto-approve MCP tools. The wildcard mcp__caelario__* approves every Caelario tool and nothing else.

Agent SDK: one MCP server, Caelario tools only

import asyncio
import os

from claude_agent_sdk import ClaudeAgentOptions, ResultMessage, query

options = ClaudeAgentOptions(
    mcp_servers={
        "caelario": {
            "command": "npx",
            "args": ["-y", "caelario-mcp", "serve"],
            "env": {
                "CAELARIO_API_URL": "https://api.caelario.com",
                "CAELARIO_API_KEY": os.environ["CAELARIO_API_KEY"],
            },
        }
    },
    allowed_tools=["mcp__caelario__*"],
)

async def main():
    prompt = "Use Caelario to check my credit balance, then list the research templates."
    async for message in query(prompt=prompt, options=options):
        if isinstance(message, ResultMessage):
            print(message.result)

asyncio.run(main())

On Windows, start npx through cmd: "command": "cmd" with "args": ["/c", "npx", "-y", "caelario-mcp", "serve"].

05 · Cost

How does the agent price a competitor snapshot before it spends?

It starts with list_templates. In our run it returned 15 templates, among them instagram-competitor: a profile, 50 posts, 30 reels, the accounts Instagram groups the brand with, and comments under its top posts, for a flat price.

Then it calls plan_template with the handle. This saves a plan with every step and its price, but runs nothing and charges nothing. The responses below are trimmed to the first template and the first five plan steps.

Tool call: list_templates
{}
Tool result
{
  "result": [
    {
      "id": "instagram-competitor",
      "title": "Instagram competitor snapshot",
      "inputs": [{ "key": "handle", "kind": "handle" }],
      "basic_steps": 7,
      "deep_steps": 3,
      "price": 200
    }
  ]
}
Tool call: plan_template
{
  "template_id": "instagram-competitor",
  "inputs": { "handle": "gymshark" }
}
Tool result
{
  "id": "a6e2f784-f45e-4a02-ae30-2a4ec13423fa",
  "status": "planned",
  "estimated_credits": 200,
  "steps": [
    { "operation": "profile", "target": "gymshark", "limit": 1, "follow_up": false, "deep": false },
    { "operation": "posts", "target": "gymshark", "limit": 50, "follow_up": false, "deep": false },
    { "operation": "reels", "target": "gymshark", "limit": 30, "follow_up": false, "deep": false },
    { "operation": "similar_accounts", "target": "gymshark", "limit": 20, "follow_up": false, "deep": false },
    { "operation": "comments", "target": "Top post #1 from step 2", "limit": 50, "follow_up": true, "deep": false }
  ],
  "recipe": { "price": 200, "settled": null, "returned": null }
}

estimated_credits is 200. The full plan has 10 steps: profile (1), posts (50), reels (30), similar_accounts (20) and three comment pulls of 50 on the top posts from step 2. Those make up the 7 basic steps. The 3 deep steps (tagged and two more comment pulls) stay deferred and don't run.

recipe.settled and recipe.returned stay null until the plan finishes. That is where the final charge appears, because a template is billed once at the plan level and not per job.

For a single operation, estimate_credits gives the most a request can reserve. Pulling 50 posts each from two accounts returns a maximum of 100 credits:

Tool call: estimate_credits
{
  "platform": "instagram",
  "operation": "posts",
  "limit": 50,
  "target_count": 2
}
Tool result
{
  "platform": "instagram",
  "operation": "posts",
  "limit": 50,
  "include_posts": 0,
  "target_count": 2,
  "normalized_limit": 50,
  "maximum_reserved_credits_per_target": 50,
  "maximum_reserved_credits_total": 100,
  "settlement": "Actual billing uses delivered results and releases unused reservation."
}

settlement describes the guardrail: the job reserves the maximum, bills only delivered results, and releases the rest.

06 · How it works

How does run_plan collect the data?

Once you approve the price, the agent calls run_plan with the plan_id. It returns straight away with a job_id for each step that started. Comment steps show waiting because they depend on the top posts that the posts step finds.

Tool call: run_plan
{ "plan_id": "a6e2f784-f45e-4a02-ae30-2a4ec13423fa" }
Tool result (trimmed to 5 steps)
{
  "status": "running",
  "steps": [
    { "operation": "profile", "job_id": "ad66952b-1e30-4433-bfce-5bb0736e63ce", "status": "running" },
    { "operation": "posts", "job_id": "8c72233e-5092-4b6c-b00b-3fd11127bd9d", "status": "running" },
    { "operation": "reels", "job_id": "9418508f-73db-4aae-8f40-1d370475a546", "status": "queued" },
    { "operation": "similar_accounts", "job_id": "bb3517ba-1114-474f-8808-cbbcee6e4233", "status": "queued" },
    { "operation": "comments", "job_id": null, "status": "waiting" }
  ]
}
Second plan, shared workspace
{
  "status": "running",
  "error": {
    "error": "steps_skipped",
    "message": "Some steps couldn't start.",
    "steps": [{ "step": 3, "error": "concurrent_job_limit_exceeded" }]
  }
}

The second result is from the Alo Yoga plan, which ran while other jobs were busy in the same workspace. Step 3, similar_accounts, hit concurrent_job_limit_exceeded and never ran. The plan still finished, at 185 credits instead of 200, and recipe.returned showed the 15 credits for the skipped step.

Next the agent waits on each job with wait_for_extraction. Gymshark's 50 posts went from queued to completed in 33 seconds:

Tool call: wait_for_extraction
{
  "job_id": "8c72233e-5092-4b6c-b00b-3fd11127bd9d",
  "timeout_seconds": 120
}
Tool result
{
  "timed_out": false,
  "job": {
    "id": "8c72233e-5092-4b6c-b00b-3fd11127bd9d",
    "operation": "posts",
    "target": "gymshark",
    "status": "completed",
    "result_count": 50,
    "billed_credits": 0,
    "started_at": "2026-11-25T14:19:55.012997Z",
    "finished_at": "2026-11-25T14:20:28.181782Z"
  }
}

billed_credits is 0 on each template step. The charge sits on the plan: get_plan returned recipe: {"price": 200, "settled": 200, "returned": 0} for Gymshark.

Alo Yoga's posts waited 74 seconds for a free Instagram slot, then took 266 seconds to collect. From approval to the template's written answer took 430 seconds for Gymshark and 487 for Alo Yoga. So give wait_for_extraction a timeout_seconds and call it again if it returns timed_out: true. The job keeps running whether or not the agent is waiting.

07 · How it works

How do you read results without filling the model's context?

get_extraction_result pages through a completed job with limit and offset. Here the agent asks for the first 25 of Gymshark's 50 posts. The response below was read from the file Claude Code saved it to, and is trimmed to one row and the fields the analysis uses.

Tool call: get_extraction_result
{
  "job_id": "8c72233e-5092-4b6c-b00b-3fd11127bd9d",
  "limit": 25,
  "offset": 0
}
Tool result (trimmed)
{
  "result": {
    "job_id": "8c72233e-5092-4b6c-b00b-3fd11127bd9d",
    "status": "completed",
    "result_count": 50,
    "result": [
      {
        "shortcode": "DgIqofKCM8t",
        "username": "gymshark",
        "media_type": "carousel",
        "caption": "That first session after shopping the Gymshark Black Friday sale >\n🔗 in bio to shop up to 50% off everything",
        "like_count": 31304,
        "comment_count": 86,
        "view_count": null,
        "published_at": "2026-11-24T19:05:46Z",
        "content_url": "https://www.instagram.com/p/DgIqofKCM8t/",
        "collaborator_usernames": []
      }
    ],
    "pagination": {
      "result": { "offset": 0, "limit": 25, "returned": 25, "total": 50, "next_offset": 25 }
    }
  }
}

pagination.result.next_offset was 25, so the agent asked again with offset: 25. On the second page it came back null, which means there's nothing left to read.

Watch the size. The full first page of 25 rows came to about 200,000 characters, because each carousel row carries every slide's media URLs. Claude Code refused to put it in the model's context: the tool call returned an error saying the result exceeded the maximum allowed tokens, and saved it to a file. The 30-row reels page, at 85,304 characters, hit the same limit. Ask for a few rows at a time and have the agent keep only the fields it needs.

For analysis, it's better to skip the model entirely. Your code can download the stored result with GET /v1/jobs/{job_id}/export?format=json. Exports don't cost credits and never re-run the job.

08 · Step by step

How do you keep the numbers honest?

This is the grounded pattern: code computes every figure, Claude writes the sentences, and code checks the sentences against the figures. These are the rules our analysis used.

  1. 01

    Merge and window the rows

    Combine posts and reels on shortcode. The reels tab reaches further back than the feed, so keep only items published on or after the oldest of the 50 feed posts. Otherwise one account's sample covers six months and the other's covers three.

  2. 02

    Drop rows with broken counts

    Two Alo Yoga posts showed 3 likes against 63 and 43 comments, so their likes were hidden or misreported. The rule: drop items with fewer than 10 likes and more than 10 comments.

  3. 03

    Use the median, then flag 3× breakouts

    Engagement is like_count + comment_count. A breakout is any item at 3 times the median or more. Report the mean only to show how far outliers pull it.

  4. 04

    Split own posts from collabs

    When username isn't the handle you asked for, the post belongs to another account and only shows on this grid as a collab. Count it separately, because its likes come from both audiences.

  5. 05

    Write from the JSON, then check it

    Give Claude only the computed facts and ask it to copy numbers exactly. Then pull every number out of its text and reject the brief if any number isn't in the facts.

brief_math.py: the facts and the number check

Run on our merged and windowed rows, facts_for returns the weekly figures in the brief further down: a Gymshark baseline median of 39,639.5 (the brief rounds it to 39,640), 7 posts this week with a median of 37,829, and a best post at x_median 3.06.

Python
import re
import statistics as st
from datetime import datetime, timedelta

def eng(row):
    return (row.get("like_count") or 0) + (row.get("comment_count") or 0)

def published(row):
    return datetime.fromisoformat(row["published_at"].replace("Z", "+00:00"))

def facts_for(handle, rows, now):
    # Likes hidden or misreported: under 10 likes but over 10 comments.
    rows = [r for r in rows if not ((r.get("like_count") or 0) < 10 and (r.get("comment_count") or 0) > 10)]
    median = st.median(eng(r) for r in rows)
    week = [r for r in rows if published(r) >= now - timedelta(days=7)]
    best = max(week, key=eng, default=None)
    week_median = st.median(eng(r) for r in week) if week else None
    return {
        "handle": handle,
        "posts_in_baseline": len(rows),
        "baseline_median": median,
        "posts_last_7d": len(week),
        "median_last_7d": week_median,
        "week_vs_baseline": round(week_median / median, 2) if week else None,
        "breakouts_last_7d": sum(1 for r in week if eng(r) >= 3 * median),
        "best_last_7d": best and {
            "url": best["content_url"],
            "engagement": eng(best),
            "x_median": round(eng(best) / median, 2),
            "own_post": best["username"] == handle,
        },
    }

def unchecked_numbers(text, facts):
    """Numbers in the model's text that don't appear anywhere in the facts."""
    allowed = {3.0, 7.0}  # the 3x breakout rule and the 7-day window
    def walk(value):
        if isinstance(value, dict):
            for v in value.values():
                walk(v)
        elif isinstance(value, list):
            for v in value:
                walk(v)
        elif isinstance(value, (int, float)) and not isinstance(value, bool):
            allowed.add(round(float(value), 2))
    walk(facts)
    found = {round(float(n.replace(",", "")), 2) for n in re.findall(r"\d[\d,]*(?:\.\d+)?", text)}
    return found - allowed

Asking Claude to compute "0.95×" itself would fail the check, which is why week_vs_baseline is computed in code and passed in.

09 · Real example · collected 25 November 2026

What did the agent find on Gymshark and Alo Yoga?

Both accounts' 50 feed posts and 30 reels, merged and limited to the feed window. Engagement is likes + comments, because share_count and save_count came back null on every row. @aloyoga is not Alo's main brand account. It is Alo's yoga and community account. Alo's main account, @alo, reports 6,000,000 followers, so read this as two accounts in one category rather than brand against brand.

13.8×Gymshark's median engagement vs Alo Yoga'sOn 2.25× the followers
11 of 60Gymshark items at 3× its medianAlo Yoga: 2 of 48
386Credits for the whole run200 + 185 + 1 profile check
Share of items at 3× the account's median or more
@gymshark
18.3% (11 of 60)
@aloyoga
4.2% (2 of 48)

Each account is measured against its own median, so the share is comparable across account sizes.

See the full table
Metric@gymshark@aloyoga
Followers (as the profile reports them, rounded)9,000,0004,000,000
Items analysed6048 (2 with broken like counts dropped)
Feed window4 Oct to 24 Nov (51.0 days)23 Aug to 23 Nov (91.7 days)
Posts per week, last 30 days8.6 (37 items)3.5 (15 items)
Median engagement39,639.52,877.5
Mean engagement (mean ÷ median)92,997 (2.35×)3,479 (1.21×)
Median engagement ÷ followers0.44%0.072%
Median: carousels vs videos53,618.5 (32) vs 34,062 (28)2,948 (40) vs 1,792 (8)
Median reel views1,277,230 (28 reels)Not returned: view_count was null on all 30 reels
Breakouts (3× median or more)11 of 60 (18.3%)2 of 48 (4.2%)
Top itemCollab carousel posted by Megan Thee Stallion's account, 14 Oct: 620,455 (15.7×)"Calm, community, connection." carousel, 26 Aug: 13,361 (4.6×)
Top item posted by the account itselfWynwood, Miami gym announcement, 26 Oct: 417,525 (11.0× its own-post median of 37,829)Same post
Items posted by other accounts7, from 4 accounts1
Captions mentioning Black Friday17 (median 45,151)1 (4,066)
Comments sampled under top posts100 on 2 posts; 0 complaints150 on 3 posts; 10 refund, delivery or support complaints from 8 people

What it tells you

  • Gymshark's median post drew 13.8 times Alo Yoga's engagement, with only 2.25 times the followers. Its median engagement rate was 6.1 times higher, and it posted 2.5 times as often over the last 30 days.
  • Collabs inflate the top of the list. Gymshark's three highest items came from Megan Thee Stallion's account and only appear on Gymshark's grid as collabs. They make up 3 of its 11 breakouts. Among Gymshark's own posts, the top one announced a new gym.
  • Sale posts filled the feed but rarely broke out. 17 Gymshark captions mention Black Friday, yet only 1 of the 11 breakouts does. The rest were creator collabs, collection drops, athlete moments, motivational reels and the gym launch.
  • Alo Yoga had a quiet week. Its 4 posts had a median of 1,601, which is 0.56 times its baseline. Its best post, the Black Friday 30% off carousel, reached 1.41 times the median, short of a breakout.
  • The comments flag a service issue, not a content one. 10 of the 150 comments sampled under Alo Yoga's top posts were refund, delivery or support complaints. Gymshark had none in 100. With 2 or 3 posts per account, treat this as a signal to watch, not a rate.

Follower counts are rounded on the profile, so engagement rates are approximate. Comment samples are the first 50 visible comments under each top post. Gymshark's third comment pull, on a reel with 6,355 comments, returned 0 rows with a no_results notice. Instagram's suggested accounts for Gymshark were 20 verified accounts: 14 creators or athletes, 2 supplement brands, 2 Gymshark sub-accounts, 1 apparel brand (YoungLA) and 1 event organiser. Alo Yoga's step was skipped.

Sources: Gymshark on Instagram · Alo Yoga on Instagram · Gymshark's top item (collab) · Gymshark Wynwood gym post · Alo Yoga's top post

10 · Guide

What does the Monday brief look like?

This is the brief our analysis script printed for the 7 days to 25 November. It was built from the full analysis output, which also has posting pace, reel views and comment counts. Account handles mentioned in captions are removed, and captions are cut at 40 characters.

Output
Monday competitor brief: Instagram, 7 days to 25 Nov 2026
@gymshark: 7 posts this week, median 37,829 interactions (0.95x its 39,640 baseline). Best: carousel "She does it again 💪 makes history breaki..." at 121,171 (3.06x, breakout).
@aloyoga: 4 posts this week, median 1,601 interactions (0.56x its 2,878 baseline). Best: carousel "Calling all yogis. 30% off for Black Fri..." at 4,066 (1.41x, no breakout).
Cadence (last 30 days): @gymshark 8.6/week vs @aloyoga 3.5/week.
Breakouts (3x median) in the sample: @gymshark 11 of 60 (18.3%), @aloyoga 2 of 48 (4.2%).
Reach check: @gymshark reels median 1,277,230 views; @aloyoga reels return no view counts.
Comment watch: 10 of 150 comments under @aloyoga's top posts are refund/delivery complaints (8 people); @gymshark 0 of 100.

Every figure comes from code. The weekly script below sends Claude only the facts_for fields, so its brief is shorter, and unchecked_numbers would reject this one as written: it rounds the baseline to 39,640 and adds figures facts_for doesn't compute. Add a field to the facts before you ask Claude to mention it.

Because we pulled only one snapshot, this brief compares the last 7 days with each account's own median over the whole window. A weekly agent should compare against stored history instead. The script below keeps every post it has seen and uses the last 60 days as the baseline.

11 · How it works

How do you run the agent every Monday?

There are two ways. The first is to let Caelario repeat the pull with create_schedule. It requires name, platform, operation, targets (an array), frequency (once, daily, weekly or monthly), timezone and starts_at. It also takes an optional limit (default 12) and include_posts. starts_at must carry a UTC offset: the server rejects 2026-11-30T07:00:00 without one. Each run creates normal jobs that you read the usual way.

These are the arguments for a weekly pull of 12 posts per account at 07:00 London time, starting Monday 30 November (London is at +00:00 in winter). We describe the call here and did not create the schedule. The free estimate_credits call for the same request returned a maximum of 24 credits a run, 12 per account.

Tool call: create_schedule
{
  "name": "Weekly competitor posts",
  "platform": "instagram",
  "operation": "posts",
  "targets": ["gymshark", "aloyoga"],
  "frequency": "weekly",
  "timezone": "Europe/London",
  "starts_at": "2026-11-30T07:00:00+00:00",
  "limit": 12
}

The timezone is an IANA name, so 07:00 stays 07:00 local time across daylight-saving changes.

The second way is to run the whole agent from your own scheduler, such as cron or a CI job. The script below does one weekly cycle. Claude estimates the run and stops if it costs more than the cap, then starts the jobs and waits for them. Code downloads the rows, adds them to the history and computes the facts. Claude then writes the brief, and code checks its numbers before saving it.

weekly_agent.py: one Monday run with a spend cap

PythonGET /v1/jobs/
import asyncio
import json
import os
from datetime import datetime, timedelta, timezone

import requests
from claude_agent_sdk import ClaudeAgentOptions, ResultMessage, query

from brief_math import facts_for, published, unchecked_numbers

HANDLES = ["gymshark", "aloyoga"]
LIMIT = 12          # posts per account per week
MAX_CREDITS = 24    # the run stops above this: 12 posts x 2 accounts
API = "https://api.caelario.com"
KEY = os.environ["CAELARIO_API_KEY"]
HISTORY = "history.json"  # every post seen so far, per handle, keyed by shortcode

CAELARIO = {
    "command": "npx",
    "args": ["-y", "caelario-mcp", "serve"],
    "env": {"CAELARIO_API_URL": API, "CAELARIO_API_KEY": KEY},
}

COLLECT = f"""Use only the Caelario tools.
1. Call estimate_credits for instagram posts with limit {LIMIT} and target_count {len(HANDLES)}.
   If maximum_reserved_credits_total is above {MAX_CREDITS}, reply {{"error": "over_cap"}} and stop.
2. Start one create_extraction job per handle (instagram, posts, limit {LIMIT}): {", ".join(HANDLES)}.
3. Call wait_for_extraction on each job until it completes. Don't read the rows.
4. Reply with JSON only: {{"jobs": {{"<handle>": "<job_id>"}}}}"""

WRITE = """Write a Monday competitor brief in at most 8 short lines from the JSON below.
Copy numbers exactly as they appear. Don't calculate new ones and don't add dates.
If own_post is false, say the best post is a collab. JSON:
"""

async def ask(prompt, options):
    async for message in query(prompt=prompt, options=options):
        if isinstance(message, ResultMessage):
            return message.result or ""
    return ""

def export_rows(job_id):
    # Reading a stored result never re-runs the job, and exports cost no credits.
    response = requests.get(
        f"{API}/v1/jobs/{job_id}/export",
        headers={"X-API-Key": KEY},
        params={"format": "json"},
        timeout=60,
    )
    response.raise_for_status()
    return response.json()

async def main():
    now = datetime.now(timezone.utc)
    reply = await ask(COLLECT, ClaudeAgentOptions(
        mcp_servers={"caelario": CAELARIO},
        allowed_tools=["mcp__caelario__*"],
        max_turns=30,
    ))
    jobs = json.loads(reply[reply.index("{"): reply.rindex("}") + 1]).get("jobs")
    if not jobs:
        raise SystemExit(f"Collection stopped: {reply}")

    history = json.load(open(HISTORY, encoding="utf-8")) if os.path.exists(HISTORY) else {}
    for handle, job_id in jobs.items():
        seen = history.setdefault(handle, {})
        for row in export_rows(job_id):
            seen[row["shortcode"]] = row  # newer counts replace older ones
    json.dump(history, open(HISTORY, "w", encoding="utf-8"), ensure_ascii=False)

    window = now - timedelta(days=60)
    facts = [facts_for(h, [r for r in history[h].values() if published(r) >= window], now) for h in jobs]

    brief = await ask(WRITE + json.dumps(facts, indent=1), ClaudeAgentOptions(max_turns=1))
    bad = unchecked_numbers(brief, facts)
    if bad:
        raise SystemExit(f"The brief has numbers that aren't in the facts: {sorted(bad)}")
    open("monday_brief.md", "w", encoding="utf-8").write(brief)
    print(brief)

asyncio.run(main())

The writing call gets no MCP server and max_turns=1, so it has no Caelario tools and one turn to write. If the check fails, the script stops rather than sending a brief with numbers nobody computed.

12 · Comparison

What does a run cost?

Our full run on 25 November 2026, call by call, and what the weekly version costs at most.

CallWhat it returnedCredits
get_credit_usage, list_templates, get_operation_guide, plan_template ×2, estimate_credits ×3Balance, 15 templates, operation guides, two priced plans, three estimates0
run_plan: instagram-competitor for gymsharkProfile, 50 posts, 30 reels, 20 similar accounts, 100 comments200
run_plan: instagram-competitor for aloyogaProfile, 50 posts, 30 reels, 150 comments; similar_accounts skipped185 (15 returned)
extract_now: profile of alo503 platform_busy0, not charged
create_extraction: profile of aloQueued, then completed: 6,000,000 followers, 2,524 posts1
wait_for_extraction, get_plan, get_extraction_result, exportsStatus, plan answers and stored rows0
Total for the run386
Weekly: posts, limit 12, 2 accountsUp to 24 posts24 at most

In a shared workspace, the change in get_credit_usage includes everyone's jobs. Ours fell from 3,000 to 1,872 during the run, while this agent's own spend was 386. Track spend per job and per plan instead.

13 · Common traps

What goes wrong in a real run, and how should the agent handle it?

All of these happened in our run. Put the handling into the agent's instructions.

✕ Mistake 01

A step can't start: concurrent_job_limit_exceeded

run_plan returned steps_skipped for one step. The plan finished without it and returned 15 credits. A plan runs only once, so report the gap, and run that one operation with create_extraction if the brief needs it.

✕ Mistake 02

The platform is busy: 503 platform_busy

extract_now failed with retryable: true, an idempotency_key and the message "you were not charged". Retry with the same key and identical arguments, or queue the request with create_extraction, which is what our agent did. It completed for 1 credit.

✕ Mistake 03

A pull comes back empty: no_results

Comments on a Gymshark reel with 6,355 comments returned 0 rows. Treat empty as a fact to report, not a reason to loop, and note the smaller sample in the brief.

✕ Mistake 04

A job outlives the conversation

While Alo Yoga's posts job ran, wait_for_extraction returned "Connection closed" twice, "Request timed out" once and timed_out: true once. The job finished anyway. Call wait_for_extraction or get_extraction again with the same job_id instead of starting a new job.

✕ Mistake 05

Rows too big for the model

25 Instagram post rows came to about 200,000 characters, and Claude Code rejected the tool result as over its token limit. Read results in code, or page with a small limit.

✕ Mistake 06

Template jobs that look free

Each template step shows billed_credits: 0. The real charge is recipe.settled on the plan, so budget per plan.

14 · Common traps

What does this agent not show?

✕ Mistake 01

Reach, saves and shares

Reach, impressions and audience demographics are private to the account owner. In our run share_count and save_count were null on every row, so engagement means likes plus comments only.

✕ Mistake 02

Views for every account

Gymshark's reels had view counts. Alo Yoga's 30 reels all had view_count: null, so the agent can't compare reach between the two.

✕ Mistake 03

Exact rates

Profiles report rounded follower counts (9,000,000 and 4,000,000), so engagement rates are approximate. Compare them with each other, not with a benchmark to the decimal.

✕ Mistake 04

One answer per window

The template's own overview used the last 60 days: Gymshark's median was 38,065 over 62 items and Alo Yoga's 2,346 over 38. Our window gives 39,639.5 and 2,877.5. Both are correct. Pick one window and keep it every week.

✕ Mistake 05

A representative comment sample

The template reads the first 50 visible comments under 2 or 3 top posts, not a random sample. Its top posts come from the last 60 days, which left out Alo Yoga's best post of the whole sample, from 26 August.

✕ Mistake 06

The whole brand

@aloyoga is Alo's yoga and community account, not its 6,000,000-follower main account. Check which handle is the main one before you call a result brand against brand.

15 · Step by step

How do you start?

New accounts get 300 free credits, valid for 30 days. That covers one instagram-competitor snapshot at a flat 225 credits, or 12 runs of the 24-credit pull.

  1. 01

    Create a workspace

    Sign up at app.caelario.com/connect. For the Agent SDK, create a key there and store it as CAELARIO_API_KEY.

  2. 02

    Connect Claude

    In Claude Code, run claude mcp add --transport http caelario https://mcp.caelario.com/mcp or npx -y caelario-mcp@latest install claude. In the Agent SDK, use the mcp_servers config above with mcp__caelario__* in the allowed tools.

  3. 03

    Price one competitor

    Ask: "Run the Instagram competitor snapshot template for one competitor's handle, but show me the plan and price before running it." plan_template is free.

  4. 04

    Approve and read in code

    Approve the plan, then export each job with GET /v1/jobs/{job_id}/export?format=json and run facts_for on the rows.

  5. 05

    Make it weekly

    Run weekly_agent.py from your scheduler with a MAX_CREDITS cap, or have the agent call create_schedule and read the jobs each run creates.

WHY CAELARIO

Why build the agent on Caelario

Claude can't read Instagram on its own. Through the Caelario MCP server it gets public data from 5 platforms and the price of every request before it spends anything.

  • A price before every run

    plan_template and estimate_credits are free, so an agent knows each snapshot will cost at most 225 credits before it starts.

  • Charges that match what was delivered

    The Alo Yoga plan settled at 185 because one step was skipped, and the busy-platform call cost nothing.

  • Jobs that survive the conversation

    Jobs keep running when a wait times out, and an idempotency_key lets the agent retry without paying twice.

  • Results your code can read

    Every job's stored result exports as JSON, CSV or XLSX at no cost, so the arithmetic runs in code and not in the model's context.

  • Templates and schedules built in

    The instagram-competitor template covers profile, posts, reels, similar accounts and comments in one plan. create_schedule repeats a pull weekly in your timezone.

  • Start free

    300 free credits for new accounts, enough for 12 runs of the 24-credit pull.

QUESTIONS

Common questions

Can Claude do social media competitor analysis on its own?

Not from live data. Claude needs a tool that fetches public posts. With the Caelario MCP server it can find a template with list_templates, price it with plan_template and run it with run_plan. Keep the medians and breakouts in code, and let Claude write the brief from them.

How much does a Claude competitor-monitoring agent cost to run?

The instagram-competitor template has a flat price of 225 credits per account. Our two-account run, charged at the earlier 200-credit price, cost 386 credits, and estimates and previews were free. A weekly pull of 12 posts from two accounts costs at most 24 credits a run. New accounts get 300 free credits.

Should I use the hosted MCP server or the local one?

Use the hosted server, https://mcp.caelario.com/mcp, when a person is at the keyboard: it signs in through the browser and needs no key. For unattended Agent SDK runs, use the local server (npx -y caelario-mcp serve) with CAELARIO_API_KEY in the environment, and allow mcp__caelario__*.

Why shouldn't Claude calculate the engagement numbers itself?

A model reading dozens of rows can misread a count or round differently from one week to the next. Compute the figures in code, pass them to Claude as JSON, and reject any brief containing a number that isn't in that JSON.

Why does get_extraction_result return so much text?

Each Instagram row carries caption text and media URLs, so 25 post rows came to about 200,000 characters. Claude Code rejected that page as over its token limit. Use a small limit, or download the stored result with GET /v1/jobs/{job_id}/export?format=json and analyse it in code.

Can the agent see a competitor's reach or saves?

No. Reach, impressions and demographics are private to the account owner. In our Instagram run, share_count and save_count were null on every row, so engagement was likes plus comments.

BUILD IT WITH CAELARIO

Social media MCP server

The same data through the API and the Claude connector, with 300 free credits to start, valid for 30 days. No card needed.

KEEP READING