marketo_clone_form
Clone a Marketo form with all fields and settings intact. Specify a new name, destination folder, and optional description to create an identical copy.
Instructions
Clone an existing Marketo form. Creates a new form with the same fields and settings under the specified name and folder.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the form to clone | |
| name | Yes | Name for the cloned form | |
| folderId | Yes | Destination folder ID | |
| folderType | No | Type of destination folder | Folder |
| description | No | Description for the cloned form |
Implementation Reference
- src/tools/forms.ts:51-66 (handler)The handler function for marketo_clone_form. Accepts id, name, folderId, folderType, and optional description. Makes a POST request to /rest/asset/v1/form/{id}/clone.json with the form data as x-www-form-urlencoded.
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/form/${args.id}/clone.json`, "POST", body, "application/x-www-form-urlencoded" )); } catch (e) { return err(e); } } ); - src/tools/forms.ts:44-50 (schema)Input schema for marketo_clone_form using Zod: id (number), name (string), folderId (number), folderType (enum 'Folder'|'Program', default 'Folder'), description (optional string).
{ id: z.number().describe("ID of the form to clone"), name: z.string().describe("Name for the cloned form"), 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 form"), }, - src/tools/forms.ts:40-66 (registration)Registration of the 'marketo_clone_form' tool via server.tool(), with description and schema, inside registerFormTools() function.
// ── marketo_clone_form ───────────────────────────────────────────────────── server.tool( "marketo_clone_form", "Clone an existing Marketo form. Creates a new form with the same fields and settings under the specified name and folder.", { id: z.number().describe("ID of the form to clone"), name: z.string().describe("Name for the cloned form"), 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 form"), }, 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/form/${args.id}/clone.json`, "POST", body, "application/x-www-form-urlencoded" )); } catch (e) { return err(e); } } ); - src/client.ts:21-49 (helper)The makeRequest helper used by the handler to send authenticated HTTP requests to the Marketo Asset API.
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; } - src/tools/forms.ts:5-9 (registration)The registerFormTools function that registers all form-related tools, including marketo_clone_form, onto the MCP server.
export function registerFormTools(server: McpServer) { // ── marketo_get_forms ────────────────────────────────────────────────────── server.tool( "marketo_get_forms", "List forms in Marketo. Supports pagination via maxReturn (max 200) and offset. Optionally filter by status (approved/draft). Returns form metadata including name, URL, status, and folder.",