maasy_execute_action
Execute marketing copilot actions: generate reports, redistribute budgets, rotate creatives, diagnose campaigns, and more using predefined actions.
Instructions
Execute a copilot action: generate report, redistribute budget, rotate creatives, diagnose campaigns, etc.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | No | Brand UUID | |
| action | Yes |
Implementation Reference
- src/index.ts:279-296 (registration)Registration of the 'maasy_execute_action' tool via server.tool() with Zod schema for project_id and action enum (generate_weekly_report, redistribute_budget, rotate_creatives, recalculate_scores, send_followup_leads, diagnose_campaigns, fill_content_gap, check_email_health). Delegates to toolHandler('execute_action').
server.tool( "maasy_execute_action", "Execute a copilot action: generate report, redistribute budget, rotate creatives, diagnose campaigns, etc.", { project_id: z.string().optional().describe("Brand UUID"), action: z.enum([ "generate_weekly_report", "redistribute_budget", "rotate_creatives", "recalculate_scores", "send_followup_leads", "diagnose_campaigns", "fill_content_gap", "check_email_health", ]), }, toolHandler("execute_action") ); - src/index.ts:279-293 (schema)Zod schema for maasy_execute_action: optional project_id (brand UUID string) and required action enum with 8 possible actions.
server.tool( "maasy_execute_action", "Execute a copilot action: generate report, redistribute budget, rotate creatives, diagnose campaigns, etc.", { project_id: z.string().optional().describe("Brand UUID"), action: z.enum([ "generate_weekly_report", "redistribute_budget", "rotate_creatives", "recalculate_scores", "send_followup_leads", "diagnose_campaigns", "fill_content_gap", "check_email_health", ]), - src/index.ts:26-43 (handler)The toolHandler function wraps all tools. For 'execute_action', it calls callGateway('execute_action', args) which forwards to the Supabase edge function 'mcp-gateway' on the server side. The actual execution logic lives in the Supabase backend.
function toolHandler(toolName: string, argsFn?: (args: Record<string, unknown>) => Record<string, unknown>) { return async (args: Record<string, unknown>) => { try { const gatewayArgs = argsFn ? argsFn(args) : args; // Auto-inject default project_id if not provided if (DEFAULT_PROJECT_ID && !gatewayArgs.project_id) { gatewayArgs.project_id = DEFAULT_PROJECT_ID; } const result = await callGateway(toolName, gatewayArgs); return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }] }; } catch (e: unknown) { return { content: [{ type: "text" as const, text: `Error: ${e instanceof Error ? e.message : String(e)}` }], isError: true, }; } }; } - src/supabase.ts:42-59 (helper)callGateway is the network helper that POSTs the tool name and args to the Supabase mcp-gateway edge function and returns the result. The actual 'execute_action' implementation is server-side in that edge function.
export async function callGateway(tool: string, args: Record<string, unknown> = {}): Promise<unknown> { const res = await fetch(gatewayUrl, { method: "POST", headers: { "Content-Type": "application/json", [authHeader.name]: authHeader.value, }, body: JSON.stringify({ tool, args }), }); const data = await res.json(); if (!res.ok) { throw new Error(data.error || `Gateway error (${res.status})`); } return data.result; }