Use Workflows over PostHog MCP

The PostHog MCP server gives your coding agent access to Workflows. From your editor, your agent can write emails, send them from your code, build broadcasts and automations, and tell you how each email did.

It works in any MCP client, such as Claude Code, Cursor, Codex, and VS Code. The Workflows agent skills teach your agent how to use these tools well, such as how to build an automation as a draft and test it before it goes live.

Before you start

  1. Set up Workflows: install the PostHog SDK and set up your domain.
  2. Connect the MCP server: run the PostHog Wizard, and give the server access to your project. To set up a client by hand, see get started with MCP.
Terminal
npx @posthog/wizard mcp add

What you can ask

  • Send email from your code: "Add a password reset email to our app, sent with PostHog."
  • Write and edit emails: "Change the button on our welcome email to say Get started."
  • Send a broadcast: "Email everyone who signed up this week about our webinar on Thursday."
  • Build an automation: "Email new signups who haven't created a dashboard after 2 days."
  • Start from a suggestion: "Suggest an automation from our events, and build it as a draft."
  • See how an email did: "Which of our automations had the most unsubscribes last month, and why?"
  • Debug a send: "Why did the welcome email bounce for ada@example.com?"
  • Move from another provider: "Move our email from Customer.io to PostHog."

Your agent creates broadcasts and automations as drafts. A broadcast sends only after you launch it in PostHog. An automation runs only after it's enabled, and your agent asks you before it enables one. The send tools, and the tool that lets your code send a template, each take two calls: a prepare call that checks the request, and an execute call that runs only after you reply confirm.

Some tools are still rolling out, so your project might not have all of them yet.

Email tools

ToolDescription
workflows-send-email-template-prepare, workflows-send-email-template-executeSend an email template to one person, such as a password reset.
workflows-send-email-prepare, workflows-send-email-executeSend one email with content that you pass, such as a receipt.
workflows-make-email-template-transactional-prepare, workflows-make-email-template-transactional-executeMake a template sendable from your code.
workflows-create-email-templateSave an email template to the library.
workflows-list-email-templatesList the email templates in the library.
workflows-get-email-templateGet an email template, with its content.
workflows-patch-email-templateMake a small edit to a template, such as a heading or a button.
workflows-update-email-templateReplace a template's content.
workflows-show-email-templateShow a preview of a template.

Broadcast and automation tools

ToolDescription
broadcasts-createCreate a broadcast as a draft, which you review and launch in PostHog.
workflows-convert-to-broadcastMove an automation that sends one email to an audience over to broadcasts.
workflows-createCreate an automation as a draft.
workflows-data-suggestions-listSuggest automations from your project's events, such as a welcome email on sign-up.
workflows-data-suggestions-getCheck on suggestions that are still being generated.
workflows-data-suggestions-createBuild a suggested automation as a draft.
workflows-listList the automations in the project.
workflows-getGet an automation.
workflows-patch-graphAdd, remove, or change steps.
workflows-patch-action-emailEdit the email in one step.
workflows-updateChange an automation's name, description, exit condition, conversion goal, or variables.
workflows-update-scheduleChange when a scheduled automation runs.
workflows-test-runTest one step. Sends are mocked unless you turn that off.
workflows-publishMake the draft live.
workflows-discard-draftThrow away the draft.
workflows-enableTurn on an automation.
workflows-suggestSuggest a change for a person to review.
workflows-list-proposalsList the suggested changes on an automation.
workflows-list-revisionsList an automation's history.
workflows-get-revisionGet one version of an automation.
workflows-restore-revisionRoll an automation back to an earlier version, as a draft.

Results tools

ToolDescription
workflows-global-statsSee how every automation is doing.
workflows-statsGet the stats for one automation.
workflows-version-statsGet the stats for one published version.
workflows-list-versionsList an automation's published versions, with when each went live.
workflows-emails-listList the emails that a broadcast or automation sent.
workflows-email-getGet one email that an automation sent, with its timeline.
workflows-email-activitySee what the recipient did before and after an email.
workflows-transactional-emails-listList the transactional emails from the last 30 days.
workflows-transactional-email-getGet one transactional email, with its timeline.
workflows-transactional-email-statsCount transactional emails by outcome.
workflows-transactional-email-resultsCount the recipients who did an event after an email.
workflows-transactional-email-activitySee what the recipient did before and after a transactional email.
workflows-list-invocationsList an automation's runs.
workflows-get-invocationGet one run, with the event that started it.
workflows-logsRead an automation's logs.
workflows-list-batch-jobsList the batch runs of a broadcast or scheduled automation.

Sending rules tools

ToolDescription
workflows-setup-statusCheck which setup steps the project has done, such as a verified domain.
workflows-sending-rules-getGet the frequency cap and other sending rules.
workflows-sending-rules-updateChange the sending rules.
workflows-reputation-getGet your bounce and spam rates, and your sending allowance.
message-categories-list, message-categories-get, message-categories-create, message-categories-updateManage the message categories that people opt out of.
opt-outs-list, opt-outs-add, opt-outs-removeList, add, or remove opt-outs, up to 1,000 at a time.
suppressions-list, suppressions-add, suppressions-removeList, add, or remove addresses on the suppression list.

Import tools

ToolDescription
provider-imports-providersList the email tools that you can import from, and what each brings over.
provider-imports-createStart an import from a tool such as Resend, Postmark, SendGrid, Mailgun, or Mailchimp.
provider-imports-list, provider-imports-getCheck on an import.
workflows-import-customerioTurn Customer.io automations into draft automations.
workflows-import-notesSee what an import from Customer.io changed or left out.
supabase-auth-emails-settings-get, supabase-auth-emails-settings-update, supabase-auth-emails-starter-templates-createSend a Supabase project's auth emails with PostHog templates.

Other ways to use Workflows

  • Build the same things by hand in the web app.
  • Script them from your own systems with the API.

For the triggers, steps, Liquid variables, and limits that these tools work with, see the Workflows reference.

Still have questions?

Was this page useful?