marketo_clone_program
Clone a Marketo program including all local assets (emails, landing pages, smart campaigns) into a destination folder, preserving the same channel.
Instructions
Clone an existing program into a destination folder. Clones all local assets (emails, landing pages, smart campaigns) within the program. The cloned program is created with the same channel.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| programId | Yes | ||
| name | Yes | ||
| folderId | Yes | ||
| description | No |
Implementation Reference
- src/index.ts:452-473 (handler)Registration and handler for 'marketo_clone_program' tool. Clones an existing Marketo program via POST to /asset/v1/program/{programId}/clone.json with name, folder (as JSON string with 'Folder' type), and optional description. Uses 'application/x-www-form-urlencoded' content type.
server.tool( 'marketo_clone_program', 'Clone an existing program into a destination folder. Clones all local assets (emails, landing pages, smart campaigns) within the program. The cloned program is created with the same channel.', { programId: z.number(), name: z.string(), folderId: z.number(), description: z.string().optional(), }, tool(async ({ programId, name, folderId, description }) => makeApiRequest( `/asset/v1/program/${programId}/clone.json`, 'POST', { name, folder: JSON.stringify({ id: folderId, type: 'Folder' }), description, }, 'application/x-www-form-urlencoded' ) ) ); - src/index.ts:455-460 (schema)Input schema for marketo_clone_program: programId (number), name (string), folderId (number), description (optional string).
{ programId: z.number(), name: z.string(), folderId: z.number(), description: z.string().optional(), }, - src/index.ts:23-53 (helper)The makeApiRequest helper function used to execute the API call. Handles token injection, content-type headers, URL-encoded form data for POST requests, and error handling.
async function makeApiRequest( endpoint: string, method: string, data?: any, contentType: string = 'application/json' ) { const token = await tokenManager.getToken(); const headers: Record<string, string> = { Authorization: `Bearer ${token}`, }; if (contentType) { headers['Content-Type'] = contentType; } try { const response = await axios({ url: `${MARKETO_BASE_URL}${endpoint}`, method, data: contentType === 'application/x-www-form-urlencoded' ? new URLSearchParams(data).toString() : data, headers, }); return response.data; } catch (error: any) { console.error('API request failed:', error.response?.data || error.message); throw error; } } - src/index.ts:55-73 (helper)The 'tool' wrapper function that wraps handlers with error handling and response formatting. Catches errors and returns them as isError responses.
function tool<T>(handler: (args: T) => Promise<unknown>) { return async (args: T) => { try { const response = await handler(args); return { content: [{ type: 'text' as const, text: JSON.stringify(response, null, 2) }], }; } catch (error: any) { return { content: [ { type: 'text' as const, text: `Error: ${error.response?.data?.message || error.message}`, }, ], isError: true, }; } };