marketo_approve_form
Approve a draft form to make it available for use in landing pages and embeds. Optionally include an approval comment.
Instructions
Approve a draft form, making it available for use in landing pages and embeds. Optionally include an approval comment.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| formId | Yes | ||
| comment | No |
Implementation Reference
- src/index.ts:129-143 (registration)Tool registration for 'marketo_approve_form' via server.tool() on the McpServer instance. Defines name, description, schema, and handler.
server.tool( 'marketo_approve_form', 'Approve a draft form, making it available for use in landing pages and embeds. Optionally include an approval comment.', { formId: z.number(), comment: z.string().optional(), }, tool(async ({ formId, comment }) => makeApiRequest( `/asset/v1/form/${formId}/approve.json`, 'POST', comment ? { comment } : undefined ) ) ); - src/index.ts:136-142 (handler)The handler function wrapped by the 'tool' helper. Calls makeApiRequest to POST to the Marketo form approve endpoint, optionally including a comment.
tool(async ({ formId, comment }) => makeApiRequest( `/asset/v1/form/${formId}/approve.json`, 'POST', comment ? { comment } : undefined ) ) - src/index.ts:23-53 (helper)General-purpose helper that handles all Marketo API requests. Prepares headers with Bearer token, sends the request via axios, and returns response data.
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-74 (helper)Wrapper function that converts a handler's return value into MCP content blocks and catches errors to return structured error 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, }; } }; } - src/index.ts:132-135 (schema)Input schema for the tool: formId (number, required) and comment (string, optional). Validated with Zod.
{ formId: z.number(), comment: z.string().optional(), },