marketo_clone_landing_page
Clone an existing Marketo landing page to create a draft copy in a specified folder. Provide the source page ID, new name, and destination folder to generate a duplicate for reuse.
Instructions
Clone an existing Marketo landing page. Creates a draft copy with the specified name in the target folder.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the landing page to clone | |
| name | Yes | Name for the cloned landing page | |
| folderId | Yes | Destination folder ID | |
| folderType | No | Type of destination folder | Folder |
| description | No | Description for the cloned landing page |
Implementation Reference
- src/tools/landingPages.ts:51-66 (handler)The async handler function that executes the clone logic: builds the request body with name, folder (JSON-serialized), optional description, and POSTs to /rest/asset/v1/landingPage/{id}/clone.json using application/x-www-form-urlencoded content type.
async (args) => { try { const body: Record<string, unknown> = { name: args.name, folder: JSON.stringify({ id: args.folderId, type: args.folderType }), }; if (args.description) body.description = args.description; return ok(await makeRequest( `/rest/asset/v1/landingPage/${args.id}/clone.json`, "POST", body, "application/x-www-form-urlencoded" )); } catch (e) { return err(e); } } ); - src/tools/landingPages.ts:44-50 (schema)Zod schema for input validation: id (number), name (string), folderId (number), folderType (enum 'Folder'|'Program' default 'Folder'), description (optional string).
{ id: z.number().describe("ID of the landing page to clone"), name: z.string().describe("Name for the cloned landing page"), folderId: z.number().describe("Destination folder ID"), folderType: z.enum(["Folder", "Program"]).default("Folder").describe("Type of destination folder"), description: z.string().optional().describe("Description for the cloned landing page"), }, - src/tools/landingPages.ts:40-66 (registration)Tool registered via server.tool('marketo_clone_landing_page', ...) inside registerLandingPageTools(server), which is called from src/index.ts:28.
// ── marketo_clone_landing_page ───────────────────────────────────────────── server.tool( "marketo_clone_landing_page", "Clone an existing Marketo landing page. Creates a draft copy with the specified name in the target folder.", { id: z.number().describe("ID of the landing page to clone"), name: z.string().describe("Name for the cloned landing page"), folderId: z.number().describe("Destination folder ID"), folderType: z.enum(["Folder", "Program"]).default("Folder").describe("Type of destination folder"), description: z.string().optional().describe("Description for the cloned landing page"), }, async (args) => { try { const body: Record<string, unknown> = { name: args.name, folder: JSON.stringify({ id: args.folderId, type: args.folderType }), }; if (args.description) body.description = args.description; return ok(await makeRequest( `/rest/asset/v1/landingPage/${args.id}/clone.json`, "POST", body, "application/x-www-form-urlencoded" )); } catch (e) { return err(e); } } ); - src/client.ts:21-57 (helper)makeRequest helper that handles HTTP calls with auth token injection, used by the handler to POST the clone request.
export async function makeRequest<T = unknown>( endpoint: string, method: Method = "GET", data?: unknown, contentType?: string, ): Promise<T> { const token = await getAccessToken(); const config: AxiosRequestConfig = { url: `${MARKETO_BASE_URL}${endpoint}`, method, headers: { Authorization: `Bearer ${token}`, ...(contentType ? { "Content-Type": contentType } : {}), }, ...(data && method !== "GET" ? { data } : {}), ...(data && method === "GET" ? { params: data } : {}), }; const res = await axios(config); const body = res.data; // Marketo REST API returns errors inside the response body if (body?.errors?.length) { const e = body.errors[0]; throw new MarketoError(`${e.code}: ${e.message}`, res.status); } return body as T; } // ─── Response helpers (match GSC MCP pattern) ───────────────────────────────── export function ok(data: unknown) { return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }; } - src/client.ts:53-65 (helper)ok/err response helpers that format the MCP content response, used by the handler to return results.
export function ok(data: unknown) { return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }; } export function err(e: unknown) { const msg = e instanceof Error ? e.message : String(e); return { isError: true, content: [{ type: "text" as const, text: `Error: ${msg}` }], }; }