marketo_clone_form
Clone Marketo forms to create duplicates with new names and descriptions while maintaining original structure and settings.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| formId | Yes | ||
| name | Yes | ||
| description | No | ||
| folderId | Yes |
Implementation Reference
- src/index.ts:128-153 (handler)The async handler function that implements the core logic for cloning a Marketo form by making a POST request to the API endpoint `/asset/v1/form/{formId}/clone.json` with the provided name, description, and folder.async ({ formId, name, description, folderId }) => { try { const formData = { name, description, folder: JSON.stringify({ id: folderId, type: 'Folder' }), }; const response = await makeApiRequest( `/asset/v1/form/${formId}/clone.json`, 'POST', formData, 'application/x-www-form-urlencoded' ); return { content: [{ type: 'text', text: JSON.stringify(response, null, 2) }], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error: ${error.response?.data?.message || error.message}` }, ], }; } }
- src/index.ts:123-127 (schema)Zod input schema validating the parameters: formId (number), name (string), description (optional string), folderId (number).formId: z.number(), name: z.string(), description: z.string().optional(), folderId: z.number(), },
- src/index.ts:120-154 (registration)Registration of the 'marketo_clone_form' tool on the MCP server using server.tool(), including inline schema and handler.server.tool( 'marketo_clone_form', { formId: z.number(), name: z.string(), description: z.string().optional(), folderId: z.number(), }, async ({ formId, name, description, folderId }) => { try { const formData = { name, description, folder: JSON.stringify({ id: folderId, type: 'Folder' }), }; const response = await makeApiRequest( `/asset/v1/form/${formId}/clone.json`, 'POST', formData, 'application/x-www-form-urlencoded' ); return { content: [{ type: 'text', text: JSON.stringify(response, null, 2) }], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error: ${error.response?.data?.message || error.message}` }, ], }; } } );
- src/index.ts:22-52 (helper)Shared helper function for making authenticated HTTP requests to the Marketo API, used by the marketo_clone_form handler to perform the clone operation.async function makeApiRequest( endpoint: string, method: string, data?: any, contentType: string = 'application/json' ) { const token = await tokenManager.getToken(); const headers: any = { Authorization: `Bearer ${token}`, }; if (contentType) { headers['Content-Type'] = contentType; } try { const response = await axios({ url: `${MARKETO_BASE_URL}${endpoint}`, method: 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; } }