:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(workflows): send an email with inline html from an MCP tool (#127167)
Michael Reichenbach6a260330f863
diff --git a/frontend/src/lib/agentScopes.generated.ts b/frontend/src/lib/agentScopes.generated.tsindex 1e62f1b44beb..db8ca7eeec0f 100644--- a/frontend/src/lib/agentScopes.generated.ts+++ b/frontend/src/lib/agentScopes.generated.ts@@ -139,6 +139,7 @@ export const AGENT_USE_CASE_SCOPES = ['task:read','task:write','tracing:read',+ 'transactional_email:write','field_note:read','field_note:write','uploaded_media:read',diff --git a/products/workflows/mcp/email_templates.yaml b/products/workflows/mcp/email_templates.yamlindex 26dcfca864fd..9b414c51ce9b 100644--- a/products/workflows/mcp/email_templates.yaml+++ b/products/workflows/mcp/email_templates.yaml@@ -139,6 +139,57 @@ tools:- content- created_by- draft_content+ workflows-send-email:+ operation: messaging_send_email_create+ enabled: true+ annotations:+ readOnly: false+ destructive: true+ idempotent: false+ title: Send transactional email+ description: >+ Send one transactional email to one recipient with the content you pass, such as a receipt or an order+ update. No template has to exist in PostHog first. Name the email with template_key (for example welcome);+ sends under one key share a workflow, so their metrics and runs group together. Pass the subject and the+ body as html, text or both, exactly as the recipient should see it: PostHog renders nothing, so {{ }} goes+ out as typed. When the user points you at a local file, such as an HTML email in their repository, read the+ file yourself and pass its content as html. This tool can't read files or URLs. from must be an address on a+ domain the project verified; sender_not_verified means nothing was sent. Leave from out to send from the+ project's default sender; sender_required means the project has several senders and no default, so ask the+ user which address to send from. Sending takes two calls: prepare checks only the arguments and returns a+ message for the user, and execute sends it only after the user replies with the literal word 'confirm'.+ PostHog checks the sender and the content when execute runs, so settle from before prepare, and tell the+ user which address the email goes out from (the address you pass, or the project's default sender). Each+ execute call sends an email, so never repeat one that succeeded. A 503, a timeout or a connection error+ means PostHog did not confirm the send, and the email may still go out: do not try again on your own, tell+ the user. A 404 with code not_found means sending email from code is not enabled for this project, or the+ project does not exist: stop and tell the user.+ exclude_params:+ - template_id+ - message_data+ param_overrides:+ template_key:+ required: true+ subject:+ required: true+ html:+ description: >+ HTML body of the email, exactly as the recipient should see it. Through this tool the whole request+ as JSON, html and text included, must stay under 1 MiB, and quotes and line breaks count twice. A+ larger email can't be sent here.+ text:+ description: >+ Plain text body of the email. Without it, PostHog derives the text from html. Through this tool the+ whole request as JSON, html and text included, must stay under 1 MiB.+ distinct_id:+ description: >+ Distinct ID of the recipient's person. The send and its engagement events are recorded against that+ person. Defaults to the recipient's email address.+ feature_flag: workflows-email-from-code+ confirmed_action:+ message: |+ About to send the email '{subject}' to {to}. Reply 'confirm' to send it.+ action_label: send emailworkflows-show-email-template:operation: messaging_templates_retrieveenabled: truediff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 81381d82d0a7..94c42f47071f 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -17343,6 +17343,37 @@"readOnlyHint": false}},+ "workflows-send-email-execute": {+ "description": "Step 2 of 2 for send email. Verifies the confirmation_hash from -prepare and the literal \"confirm\" string typed by the user, then performs the action. ONLY call this after the user has explicitly typed \"confirm\" in chat. Original action: Send one transactional email to one recipient with the content you pass, such as a receipt or an order update. No template has to exist in PostHog first. Name the email with template_key (for example welcome); sends under one key share a workflow, so their metrics and runs group together. Pass the subject and the body as html, text or both, exactly as the recipient should see it: PostHog renders nothing, so {{ }} goes out as typed. When the user points you at a local file, such as an HTML email in their repository, read the file yourself and pass its content as html. This tool can't read files or URLs. from must be an address on a domain the project verified; sender_not_verified means nothing was sent. Leave from out to send from the project's default sender; sender_required means the project has several senders and no default, so ask the user which address to send from. Sending takes two calls: prepare checks only the arguments and returns a message for the user, and execute sends it only after the user replies with the literal word 'confirm'. PostHog checks the sender and the content when execute runs, so settle from before prepare, and tell the user which address the email goes out from (the address you pass, or the project's default sender). Each execute call sends an email, so never repeat one that succeeded. A 503, a timeout or a connection error means PostHog did not confirm the send, and the email may still go out: do not try again on your own, tell the user. A 404 with code not_found means sending email from code is not enabled for this project, or the project does not exist: stop and tell the user.",+ "category": "Workflows",+ "feature": "workflows",+ "summary": "Send transactional email (execute)",+ "title": "Send transactional email (execute)",+ "required_scopes": ["transactional_email:write"],+ "api_operations": ["POST /api/projects/{project_id}/messaging/send/email/"],+ "annotations": {+ "destructiveHint": true,+ "idempotentHint": false,+ "openWorldHint": true,+ "readOnlyHint": false+ },+ "feature_flag": "workflows-email-from-code"+ },+ "workflows-send-email-prepare": {+ "description": "Step 1 of 2 for send email. Validates the arguments and returns a signed confirmation_hash plus a message to surface to the user. The user must reply with the literal word \"confirm\" before you call the matching -execute tool with the hash. Original action: Send one transactional email to one recipient with the content you pass, such as a receipt or an order update. No template has to exist in PostHog first. Name the email with template_key (for example welcome); sends under one key share a workflow, so their metrics and runs group together. Pass the subject and the body as html, text or both, exactly as the recipient should see it: PostHog renders nothing, so {{ }} goes out as typed. When the user points you at a local file, such as an HTML email in their repository, read the file yourself and pass its content as html. This tool can't read files or URLs. from must be an address on a domain the project verified; sender_not_verified means nothing was sent. Leave from out to send from the project's default sender; sender_required means the project has several senders and no default, so ask the user which address to send from. Sending takes two calls: prepare checks only the arguments and returns a message for the user, and execute sends it only after the user replies with the literal word 'confirm'. PostHog checks the sender and the content when execute runs, so settle from before prepare, and tell the user which address the email goes out from (the address you pass, or the project's default sender). Each execute call sends an email, so never repeat one that succeeded. A 503, a timeout or a connection error means PostHog did not confirm the send, and the email may still go out: do not try again on your own, tell the user. A 404 with code not_found means sending email from code is not enabled for this project, or the project does not exist: stop and tell the user.",+ "category": "Workflows",+ "feature": "workflows",+ "summary": "Send transactional email (prepare)",+ "title": "Send transactional email (prepare)",+ "required_scopes": ["transactional_email:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ },+ "feature_flag": "workflows-email-from-code"+ },"workflows-sending-rules-get": {"description": "The project-wide rules every workflow and broadcast follows when it sends: the marketing frequency cap, email tracking consent, and whether email engagement events are captured. Null cap fields mean no cap.","category": "Workflows",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex dfc0857e1956..c99d82387b00 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -18188,6 +18188,37 @@"readOnlyHint": false}},+ "workflows-send-email-execute": {+ "description": "Step 2 of 2 for send email. Verifies the confirmation_hash from -prepare and the literal \"confirm\" string typed by the user, then performs the action. ONLY call this after the user has explicitly typed \"confirm\" in chat. Original action: Send one transactional email to one recipient with the content you pass, such as a receipt or an order update. No template has to exist in PostHog first. Name the email with template_key (for example welcome); sends under one key share a workflow, so their metrics and runs group together. Pass the subject and the body as html, text or both, exactly as the recipient should see it: PostHog renders nothing, so {{ }} goes out as typed. When the user points you at a local file, such as an HTML email in their repository, read the file yourself and pass its content as html. This tool can't read files or URLs. from must be an address on a domain the project verified; sender_not_verified means nothing was sent. Leave from out to send from the project's default sender; sender_required means the project has several senders and no default, so ask the user which address to send from. Sending takes two calls: prepare checks only the arguments and returns a message for the user, and execute sends it only after the user replies with the literal word 'confirm'. PostHog checks the sender and the content when execute runs, so settle from before prepare, and tell the user which address the email goes out from (the address you pass, or the project's default sender). Each execute call sends an email, so never repeat one that succeeded. A 503, a timeout or a connection error means PostHog did not confirm the send, and the email may still go out: do not try again on your own, tell the user. A 404 with code not_found means sending email from code is not enabled for this project, or the project does not exist: stop and tell the user.",+ "category": "Workflows",+ "feature": "workflows",+ "summary": "Send transactional email (execute)",+ "title": "Send transactional email (execute)",+ "required_scopes": ["transactional_email:write"],+ "api_operations": ["POST /api/projects/{project_id}/messaging/send/email/"],+ "annotations": {+ "destructiveHint": true,+ "idempotentHint": false,+ "openWorldHint": true,+ "readOnlyHint": false+ },+ "feature_flag": "workflows-email-from-code"+ },+ "workflows-send-email-prepare": {+ "description": "Step 1 of 2 for send email. Validates the arguments and returns a signed confirmation_hash plus a message to surface to the user. The user must reply with the literal word \"confirm\" before you call the matching -execute tool with the hash. Original action: Send one transactional email to one recipient with the content you pass, such as a receipt or an order update. No template has to exist in PostHog first. Name the email with template_key (for example welcome); sends under one key share a workflow, so their metrics and runs group together. Pass the subject and the body as html, text or both, exactly as the recipient should see it: PostHog renders nothing, so {{ }} goes out as typed. When the user points you at a local file, such as an HTML email in their repository, read the file yourself and pass its content as html. This tool can't read files or URLs. from must be an address on a domain the project verified; sender_not_verified means nothing was sent. Leave from out to send from the project's default sender; sender_required means the project has several senders and no default, so ask the user which address to send from. Sending takes two calls: prepare checks only the arguments and returns a message for the user, and execute sends it only after the user replies with the literal word 'confirm'. PostHog checks the sender and the content when execute runs, so settle from before prepare, and tell the user which address the email goes out from (the address you pass, or the project's default sender). Each execute call sends an email, so never repeat one that succeeded. A 503, a timeout or a connection error means PostHog did not confirm the send, and the email may still go out: do not try again on your own, tell the user. A 404 with code not_found means sending email from code is not enabled for this project, or the project does not exist: stop and tell the user.",+ "category": "Workflows",+ "feature": "workflows",+ "summary": "Send transactional email (prepare)",+ "title": "Send transactional email (prepare)",+ "required_scopes": ["transactional_email:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ },+ "feature_flag": "workflows-email-from-code"+ },"workflows-sending-rules-get": {"description": "The project-wide rules every workflow and broadcast follows when it sends: the marketing frequency cap, email tracking consent, and whether email engagement events are captured. Null cap fields mean no cap.","category": "Workflows",diff --git a/services/mcp/src/generated/email_templates/api.ts b/services/mcp/src/generated/email_templates/api.tsindex 7c992efdbae0..662a17245869 100644--- a/services/mcp/src/generated/email_templates/api.ts+++ b/services/mcp/src/generated/email_templates/api.ts@@ -3,11 +3,86 @@* MCP service uses these Zod schemas for generated tool handlers.* To regenerate: hogli build:openapi*- * PostHog API - MCP 6 enabled ops+ * PostHog API - MCP 7 enabled ops* OpenAPI spec version: 1.0.0*/import * as zod from 'zod'+/**+ * Send one transactional email to one recipient. Name a template made transactional in `template_id`, and `message_data` fills its `{{ variables.* }}` placeholders. Or send content your code rendered with a `template_key`, a `subject` and `html` or `text`: PostHog sends it as is, and its metrics and run history group under the key. Transactional emails skip opt-outs and frequency caps. Send an `Idempotency-Key` header to retry safely without sending the email twice. Needs the `transactional_email:write` scope. A key with `hog_flow:write` also works, but that scope reaches the rest of Workflows too.+ * @summary Send a transactional email+ */+export const MessagingSendEmailCreateParams = () => zod.object({+ project_id: zod+ .string()+ .describe(+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."+ ),+})++export const MessagingSendEmailCreateHeader = () => zod.object({+ 'Idempotency-Key': zod+ .string()+ .optional()+ .describe(+ "A unique key for this email, 1 to 255 visible ASCII characters. Retrying with the same key and the same request within 24 hours sends nothing new and returns the first send's `message_id`. Reusing a key for a different request returns a 422."+ ),+})++export const messagingSendEmailCreateBodyTemplateKeyMax = 400++export const messagingSendEmailCreateBodyTemplateKeyRegExp = new RegExp('^[a-zA-Z0-9_-]+$')+export const messagingSendEmailCreateBodyDistinctIdMax = 400++export const messagingSendEmailCreateBodyReplyToMax = 10++export const messagingSendEmailCreateBodyFromMax = 1024++export const MessagingSendEmailCreateBody = () => zod.object({+ to: zod.email().describe('Email address of the recipient.'),+ template_key: zod+ .string()+ .max(messagingSendEmailCreateBodyTemplateKeyMax)+ .regex(messagingSendEmailCreateBodyTemplateKeyRegExp)+ .optional()+ .describe(+ 'Names an email whose content your code rendered, such as `order-shipped`, so its metrics, logs and status group under it. Letters, numbers, hyphens (-) and underscores (_) only. Send it with `subject` and `html` or `text`. PostHog sends the content as is and never stores it as a template.'+ ),+ distinct_id: zod+ .string()+ .max(messagingSendEmailCreateBodyDistinctIdMax)+ .nullish()+ .describe(+ "Distinct ID of the recipient's person. The email's engagement events (sent, delivered, opened, clicked, bounced) and the send itself are recorded against that person. Defaults to the recipient's email address. The template can't read the person's properties, so pass everything it needs in `message_data`."+ ),+ subject: zod.string().optional().describe('Subject of the email your code rendered.'),+ html: zod.string().optional().describe('HTML body of the email your code rendered, at most 5 MiB as UTF-8.'),+ text: zod+ .string()+ .optional()+ .describe(+ 'Plain text body of the email your code rendered, at most 5 MiB as UTF-8. Without it, PostHog derives the text from `html`.'+ ),+ reply_to: zod+ .array(zod.email())+ .max(messagingSendEmailCreateBodyReplyToMax)+ .optional()+ .describe('Addresses replies to the email your code rendered go to.'),+ capture_engagement: zod+ .boolean()+ .optional()+ .describe(+ 'Whether the engagement events (sent, delivered, opened, clicked, bounced) of the email your code rendered are captured as analytics events of the recipient. Defaults to true. A project whose admin turned engagement capture off captures nothing, whatever the send says.'+ ),+ from: zod+ .string()+ .max(messagingSendEmailCreateBodyFromMax)+ .optional()+ .describe(+ "Sender of the email your code rendered, as `[email protected]` or `Example <[email protected]>`, on a verified domain of the project. Without it, the email goes out from the project's default sender, or from its only verified sender when it has no default."+ ),+})+export const MessagingTemplatesListParams = () => zod.object({project_id: zod.string()diff --git a/services/mcp/src/hono/analytics.ts b/services/mcp/src/hono/analytics.tsindex fd0a19056810..44cbd0acb824 100644--- a/services/mcp/src/hono/analytics.ts+++ b/services/mcp/src/hono/analytics.ts@@ -340,10 +340,25 @@ const POSTHOG_CONNECTION_TOOL_NAMES: ReadonlySet<string> = new Set(['posthog-connection-forward',])+const EMAIL_SEND_TOOL_PREFIX = 'workflows-send-email'++function sendsEmailContent(toolName: string, input: unknown): boolean {+ if (toolName.startsWith(EMAIL_SEND_TOOL_PREFIX)) {+ return true+ }+ // Match the whole exec command, not its parsed inner tool: a send forwarded through+ // posthog-connection-call, or a command exec rejects, still carries the email body.+ const command = (input as { command?: unknown } | null | undefined)?.command+ return toolName === 'exec' && typeof command === 'string' && command.includes(EMAIL_SEND_TOOL_PREFIX)+}+function shouldCaptureToolSpan(toolName: string, input: unknown): boolean {if (isPrivateScoutTrialTool(toolName)) {return false}+ if (sendsEmailContent(toolName, input)) {+ return false+ }// A proxied third-party tool's args and result are the vendor's content — an issue// body, a support ticket, a CRM record — passing through our gateway on its way// somewhere else. Key-based redaction only catches credential-shaped fields, sodiff --git a/services/mcp/src/tools/generated/email_templates.ts b/services/mcp/src/tools/generated/email_templates.tsindex b102d2dd0916..d43ac025207b 100644--- a/services/mcp/src/tools/generated/email_templates.ts+++ b/services/mcp/src/tools/generated/email_templates.ts@@ -234,6 +234,107 @@ const workflowsPatchEmailTemplate = (): ToolBase<},})+const WorkflowsSendEmailSchema = () => {+ const MessagingSendEmailCreateBody = orvalSchemas.MessagingSendEmailCreateBody()+ return MessagingSendEmailCreateBody.extend({+ template_key: MessagingSendEmailCreateBody.shape['template_key'].nonoptional(),+ subject: MessagingSendEmailCreateBody.shape['subject'].nonoptional(),+ html: MessagingSendEmailCreateBody.shape['html'].describe(+ "HTML body of the email, exactly as the recipient should see it. Through this tool the whole request as JSON, html and text included, must stay under 1 MiB, and quotes and line breaks count twice. A larger email can't be sent here."+ ),+ text: MessagingSendEmailCreateBody.shape['text'].describe(+ 'Plain text body of the email. Without it, PostHog derives the text from html. Through this tool the whole request as JSON, html and text included, must stay under 1 MiB.'+ ),+ distinct_id: MessagingSendEmailCreateBody.shape['distinct_id'].describe(+ "Distinct ID of the recipient's person. The send and its engagement events are recorded against that person. Defaults to the recipient's email address."+ ),+ })+}++const WorkflowsSendEmailSchemaExecute = z.strictObject({+ confirmation_hash: z+ .string()+ .describe('The confirmation_hash returned by the matching -prepare tool. Pass it back verbatim.'),+ confirmation: z.string().describe('The literal string "confirm", typed by the user in chat. Required to proceed.'),+})++const workflowsSendEmailPrepare = (): ToolBase<+ ReturnType<typeof WorkflowsSendEmailSchema>,+ PrepareConfirmedActionResult+> => ({+ name: 'workflows-send-email-prepare',+ schema: WorkflowsSendEmailSchema(),+ handler: async (context: Context, params: z.infer<ReturnType<typeof WorkflowsSendEmailSchema>>) => {+ const __runtime = getConfirmedActionRuntime()+ const __scopeProjectId = await context.stateManager.getProjectId()+ return await prepareConfirmedAction(context, {+ args: params,+ purpose: 'workflows-send-email',+ actionLabel: 'send email',+ messageTemplate: "About to send the email '{subject}' to {to}. Reply 'confirm' to send it.\n",+ codec: __runtime.codec,+ stash: __runtime.stash,+ boundScope: { projectId: String(__scopeProjectId) },+ })+ },+})++const workflowsSendEmailExecute = (): ToolBase<typeof WorkflowsSendEmailSchemaExecute, unknown> => ({+ name: 'workflows-send-email-execute',+ schema: WorkflowsSendEmailSchemaExecute,+ handler: async (context: Context, confirmationParams: z.infer<typeof WorkflowsSendEmailSchemaExecute>) => {+ const __runtime = getConfirmedActionRuntime()+ const __scopeProjectId = await context.stateManager.getProjectId()+ const __guard = await executeConfirmedAction<z.infer<ReturnType<typeof WorkflowsSendEmailSchema>>>(context, {+ incomingArgs: confirmationParams,+ purpose: 'workflows-send-email',+ codec: __runtime.codec,+ ledger: __runtime.ledger,+ stash: __runtime.stash,+ expectedScope: { projectId: String(__scopeProjectId) },+ })+ if (!__guard.ok) {+ return __guard.result as never+ }+ const params = __guard.verifiedArgs+ const projectId = __scopeProjectId+ const body: Record<string, unknown> = {}+ if (params.to !== undefined) {+ body['to'] = params.to+ }+ if (params.template_key !== undefined) {+ body['template_key'] = params.template_key+ }+ if (params.distinct_id !== undefined) {+ body['distinct_id'] = params.distinct_id+ }+ if (params.subject !== undefined) {+ body['subject'] = params.subject+ }+ if (params.html !== undefined) {+ body['html'] = params.html+ }+ if (params.text !== undefined) {+ body['text'] = params.text+ }+ if (params.reply_to !== undefined) {+ body['reply_to'] = params.reply_to+ }+ if (params.capture_engagement !== undefined) {+ body['capture_engagement'] = params.capture_engagement+ }+ if (params.from !== undefined) {+ body['from'] = params.from+ }+ const result = await context.api.request<unknown>({+ method: 'POST',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/messaging/send/email/`,+ body,+ })+ return result+ },+})+const WorkflowsShowEmailTemplateSchema = () => {const MessagingTemplatesRetrieveParams = orvalSchemas.MessagingTemplatesRetrieveParams()return MessagingTemplatesRetrieveParams.omit({ project_id: true })@@ -319,6 +420,8 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {'workflows-make-email-template-transactional-prepare': workflowsMakeEmailTemplateTransactionalPrepare,'workflows-make-email-template-transactional-execute': workflowsMakeEmailTemplateTransactionalExecute,'workflows-patch-email-template': workflowsPatchEmailTemplate,+ 'workflows-send-email-prepare': workflowsSendEmailPrepare,+ 'workflows-send-email-execute': workflowsSendEmailExecute,'workflows-show-email-template': workflowsShowEmailTemplate,'workflows-update-email-template': workflowsUpdateEmailTemplate,}diff --git a/services/mcp/tests/hono/analytics.test.ts b/services/mcp/tests/hono/analytics.test.tsindex 2aa8a30b423b..f622bad6e03c 100644--- a/services/mcp/tests/hono/analytics.test.ts+++ b/services/mcp/tests/hono/analytics.test.ts@@ -554,6 +554,35 @@ describe('Hono MCP analytics contexts', () => {{ id: '1', method: 'GET', path: 'api/projects/1/persons/' },false,],+ [+ 'preparing an email send',+ 'workflows-send-email-prepare',+ { to: '[email protected]', html: '<a href="https://example.com/reset?t=1">Reset</a>' },+ false,+ ],+ ['executing an email send', 'workflows-send-email-execute', { confirmation: 'confirm' }, false],+ [+ 'an email send through exec',+ 'exec',+ { command: 'call workflows-send-email-prepare {"to":"[email protected]","html":"<p>code 123456</p>"}' },+ false,+ ],+ [+ 'an email send forwarded through a PostHog connection',+ 'exec',+ {+ command:+ 'call posthog-connection-call {"connection_id":"1","tool":"workflows-send-email-prepare","arguments":{"html":"<p>code 123456</p>"}}',+ },+ false,+ ],+ [+ 'an email send exec rejects for a missing verb',+ 'exec',+ { command: 'workflows-send-email-prepare {"html":"<p>code 123456</p>"}' },+ false,+ ],+ ['another tool through exec', 'exec', { command: 'call feature-flag-get-all {}' }, true],])('gates capture for %s', async (_case, toolName, input, captured) => {await trackToolSpan(toolName, makeState(), { durationMs: 100, isError: false, input, output: 'rows' })diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-send-email-execute.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-send-email-execute.jsonnew file mode 100644index 000000000000..f9e863b2ae53--- /dev/null+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-send-email-execute.json@@ -0,0 +1,16 @@+{+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "additionalProperties": false,+ "properties": {+ "confirmation": {+ "description": "The literal string \"confirm\", typed by the user in chat. Required to proceed.",+ "type": "string"+ },+ "confirmation_hash": {+ "description": "The confirmation_hash returned by the matching -prepare tool. Pass it back verbatim.",+ "type": "string"+ }+ },+ "required": ["confirmation_hash", "confirmation"],+ "type": "object"+}diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-send-email-prepare.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-send-email-prepare.jsonnew file mode 100644index 000000000000..622c83e69af2--- /dev/null+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-send-email-prepare.json@@ -0,0 +1,62 @@+{+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "properties": {+ "capture_engagement": {+ "description": "Whether the engagement events (sent, delivered, opened, clicked, bounced) of the email your code rendered are captured as analytics events of the recipient. Defaults to true. A project whose admin turned engagement capture off captures nothing, whatever the send says.",+ "type": "boolean"+ },+ "distinct_id": {+ "anyOf": [+ {+ "maxLength": 400,+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "Distinct ID of the recipient's person. The send and its engagement events are recorded against that person. Defaults to the recipient's email address."+ },+ "from": {+ "description": "Sender of the email your code rendered, as `[email protected]` or `Example <[email protected]>`, on a verified domain of the project. Without it, the email goes out from the project's default sender, or from its only verified sender when it has no default.",+ "maxLength": 1024,+ "type": "string"+ },+ "html": {+ "description": "HTML body of the email, exactly as the recipient should see it. Through this tool the whole request as JSON, html and text included, must stay under 1 MiB, and quotes and line breaks count twice. A larger email can't be sent here.",+ "type": "string"+ },+ "reply_to": {+ "description": "Addresses replies to the email your code rendered go to.",+ "items": {+ "format": "email",+ "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",+ "type": "string"+ },+ "maxItems": 10,+ "type": "array"+ },+ "subject": {+ "description": "Subject of the email your code rendered.",+ "type": "string"+ },+ "template_key": {+ "description": "Names an email whose content your code rendered, such as `order-shipped`, so its metrics, logs and status group under it. Letters, numbers, hyphens (-) and underscores (_) only. Send it with `subject` and `html` or `text`. PostHog sends the content as is and never stores it as a template.",+ "maxLength": 400,+ "pattern": "^[a-zA-Z0-9_-]+$",+ "type": "string"+ },+ "text": {+ "description": "Plain text body of the email. Without it, PostHog derives the text from html. Through this tool the whole request as JSON, html and text included, must stay under 1 MiB.",+ "type": "string"+ },+ "to": {+ "description": "Email address of the recipient.",+ "format": "email",+ "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",+ "type": "string"+ }+ },+ "required": ["to", "template_key", "subject"],+ "type": "object"+}diff --git a/services/mcp/tests/unit/tool-filtering.test.ts b/services/mcp/tests/unit/tool-filtering.test.tsindex 6aba385b7005..d68836bf1583 100644--- a/services/mcp/tests/unit/tool-filtering.test.ts+++ b/services/mcp/tests/unit/tool-filtering.test.ts@@ -1126,6 +1126,7 @@ describe('Tool Filtering - Feature Flags', () => {'insight-data-checks','logs-agent-tools','workflows-transactional-email-api',+ 'workflows-email-from-code','activity-summary','personal-inbox-ranking','anomalies-search',diff --git a/services/mcp/tests/unit/tool-schema-snapshots.test.ts b/services/mcp/tests/unit/tool-schema-snapshots.test.tsindex 1e1b1fbf9539..d76cbe6c8702 100644--- a/services/mcp/tests/unit/tool-schema-snapshots.test.ts+++ b/services/mcp/tests/unit/tool-schema-snapshots.test.ts@@ -114,6 +114,7 @@ async function loadSnapshotTools(): Promise<Tool<ZodObjectAny>[]> {'workflows-sending-tier-requests': true,'insight-data-checks': true,'workflows-transactional-email-api': true,+ 'workflows-email-from-code': true,'activity-summary': true,'activity-summary-search': true,'personal-inbox-ranking': true,