Skip to content

MT-22401: Add email campaigns tools - #128

Draft
Rabsztok wants to merge 2 commits into
mainfrom
MT-22401-mcp-email-campaigns
Draft

MT-22401: Add email campaigns tools#128
Rabsztok wants to merge 2 commits into
mainfrom
MT-22401-mcp-email-campaigns

Conversation

@Rabsztok

@Rabsztok Rabsztok commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Draft until the server-side Email Campaigns API changes are released.

Motivation

MT-22401

Port the Email Campaigns public API (MT-21113) to the MCP server.

Do not merge until mailtrap-nodejs#148 is released to npm and the mailtrap dep is bumped here — handlers call client.emailCampaigns.*, which doesn't exist in 4.8.0. Types compile today via a local EmailCampaignsClient interface cast (marked with a TODO(MT-22401) to drop after the bump).

Changes

  • Add 11 tools: list-email-campaigns, get-email-campaign, create-email-campaign, update-email-campaign, delete-email-campaign, start-email-campaign, schedule-email-campaign, cancel-email-campaign, terminate-email-campaign, reset-email-campaign, get-email-campaign-stats
  • Hand-written JSON Schemas from the OpenAPI spec (snake_case, closed objects) with a zod .strict() validation layer on list/create/update/schedule; lifecycle preconditions (draft-only, scheduled-only, sending-states) called out in tool descriptions
  • Responses unwrap the data envelope; list keeps {data, pagination} so page tokens stay usable; delete returns {email_campaign_id, deleted: true}
  • README "Available Tools" sections + CLAUDE.md tool list updated; manifest/version files untouched (release workflow owns them)

How to test

  • With the bumped mailtrap dep and real env vars, ask the MCP client to create a draft campaign, update its design, schedule and cancel it, fetch stats, then delete it
  • Verify a lifecycle 422 (e.g. cancelling a draft) comes back as a readable Failed to cancel email campaign: ... message

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fd7c247a-df5c-43ca-99e8-c6692d26b664

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Rabsztok

Copy link
Copy Markdown
Contributor Author

Aligned with the account-id fix from the Python/Node.js PRs: all 11 campaign handlers now call requireClient("email campaigns", { requireAccountId: false }) — the endpoints are token-scoped, so the tools no longer demand MAILTRAP_ACCOUNT_ID. 32 campaign tests + lint green.

Decisions:
- 11 tools mirror src/tools/contactLists/ layout (one file per tool, schemas/, __tests__, barrel index.ts), registered after the contacts group in src/server.ts
- Handlers target the future mailtrap npm emailCampaigns surface via a local EmailCampaignsClient interface in src/types/mailtrap.ts with a single TODO(MT-22401) to drop the casts after the SDK release
- Single-object and stats responses unwrap the {data} envelope; list keeps {data, pagination} so page tokens stay visible; delete returns a {email_campaign_id, deleted: true} confirmation
- Zod validation layer added for list/create/update/schedule per repo CLAUDE.md recommendation
- readOnlyHint for list/get/stats; destructiveHint: true for create/update/delete and all five lifecycle tools per the MT-22401 plan
Decisions:
- The email campaigns endpoints are token-scoped, so the handlers now
  pass requireAccountId: false (listAccounts precedent), matching the
  same fix in the Python and Node.js SDK PRs
@Rabsztok
Rabsztok force-pushed the MT-22401-mcp-email-campaigns branch from a2d725e to 44d7081 Compare August 6, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant