Skip to main content
Glama

campaigns_generate_messages

Per-step, per-lead equivalent of the auto-generation that runs during campaigns_activate. Use this to cover leads that are still PENDING on a specific step — typically because:

  • new leads were enrolled after the campaign first activated,

  • a previous activation ran out of connects mid-way, or

  • the user wants to regenerate selectively after tweaking the sequence template.

Input is Lead sqids, not CampaignLog sqids. The natural source is campaigns_step_logs with ?status=0. The endpoint resolves each Lead to its CampaignLog row for this (campaign, step) pair, filters to status=PENDING, and queues the generation as a background Celery task.

Returns task_sqid — poll jobs_get(task_sqid) until status == 'COMPLETED' (or 'FAILED'). Per-lead generation errors (unresolved ${vars}, AI snippet failures) appear in the task's result payload; the affected rows stay PENDING so a follow-up call can retry them.

Cost. One COMPOSE_EMAIL charge per generated message; see billing_pricelist for the current rate. The task does a batch-level balance pre-check before charging anything; if the account is short on connects the whole task fails cleanly with no partial charges. Call billing_balance before batches of 1000+.

Idempotent. If the task crashes halfway, re-calling with the same lead sqids picks up the still-PENDING rows; already-generated rows are skipped silently inside the per-row SELECT … FOR UPDATE SKIP LOCKED transaction.

Race-safe with the background process_campaign_steps_pending_status scheduler — both paths use the same row lock.

Method: POST /api/v1/workspaces/{workspace_sqid}/campaigns/{sqid}/steps/{step_sqid}/generate-messages/

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "sqid": "<sqid>",
      "step_sqid": "<step_sqid>",
      "lead_sqids": "<lead_sqids>"
    },
    "name": "campaigns_generate_messages"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqidYes
step_sqidYes
lead_sqidsYesLead sqids whose pending messages for this step should be generated. Source these from `campaigns_step_logs` filtered by status=0 (PENDING). Cap 1000 per call.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so: async Celery task returning `task_sqid`, per-lead failure handling that leaves rows PENDING, one `COMPOSE_EMAIL` charge per message with a batch-level balance pre-check and no partial charges, idempotent retry via `SELECT … FOR UPDATE SKIP LOCKED`, and race safety with the pending-status scheduler.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose and the key ID disambiguation are front-loaded, then bold-labeled sections for return value, cost, idempotency, and concurrency make it skimmable. It is on the long side with some formatting overhead, but nearly every line carries operational information rather than filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a costly, asynchronous, mutating batch operation with no annotations and no output schema, the description covers everything an agent needs: what it enqueues, what it returns and how to poll, how errors surface, how billing works, and how retries behave.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is only 33%, but the description compensates well: `lead_sqids` is explained as Lead (not CampaignLog) sqids sourced from `campaigns_step_logs` status=0, and the (campaign, step) pairing implies what `sqid` and `step_sqid` are via the documented endpoint path. It does not explicitly restate the 1000 cap or spell out the two sqid params, leaving a small gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb+resource framing: per-step, per-lead generation of campaign messages, and explicitly positions it as the manual equivalent of the auto-generation in `campaigns_activate`. It also disambiguates the ID type ('Input is Lead sqids, not CampaignLog sqids'), so an agent can tell it apart from activation and log tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives three concrete when-to-use triggers (new leads enrolled after activation, prior run ran out of connects, selective regeneration after template edits) and names the alternative path (`campaigns_activate`). It also prescribes where to source the input (`campaigns_step_logs` with `?status=0`) and the polling follow-up via `jobs_get`.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.