maasy_generate_ads
Generate ad copy and concepts for Meta or Google by combining brand DNA with a campaign brief. Specify product, audience, and offer to produce tailored creatives.
Instructions
Generate ad creatives (copy + concepts) for Meta or Google using brand DNA and a brief.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | No | Brand UUID | |
| brief | Yes | Campaign brief: product, objective, audience, offer | |
| platform | No | meta | |
| count | No |
Implementation Reference
- src/index.ts:315-325 (registration)Registration of the 'maasy_generate_ads' tool on the MCP server. It uses Zod schema for validation of inputs (project_id, brief, platform, count) and delegates to toolHandler('generate_ads').
server.tool( "maasy_generate_ads", "Generate ad creatives (copy + concepts) for Meta or Google using brand DNA and a brief.", { project_id: z.string().optional().describe("Brand UUID"), brief: z.string().describe("Campaign brief: product, objective, audience, offer"), platform: z.enum(["meta", "google", "tiktok"]).optional().default("meta"), count: z.number().int().min(1).max(10).optional().default(3), }, toolHandler("generate_ads") ); - src/index.ts:26-43 (handler)The toolHandler helper function that wraps every tool call. For 'generate_ads', it calls callGateway('generate_ads', args) which makes an HTTP POST to the mcp-gateway Supabase edge function.
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)The callGateway function that sends the tool name and arguments to the mcp-gateway edge function. This is the actual execution point — it sends { tool: 'generate_ads', args } to the remote gateway.
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; } - src/index.ts:318-323 (schema)Zod input schema for the 'maasy_generate_ads' tool: project_id (optional string), brief (required string), platform (optional enum: meta/google/tiktok, default meta), count (optional int 1-10, default 3).
{ project_id: z.string().optional().describe("Brand UUID"), brief: z.string().describe("Campaign brief: product, objective, audience, offer"), platform: z.enum(["meta", "google", "tiktok"]).optional().default("meta"), count: z.number().int().min(1).max(10).optional().default(3), },