marketo_delete_lead
Permanently remove a lead record from Marketo using its lead ID. This action is irreversible.
Instructions
Permanently delete a lead by its numeric ID. This action cannot be undone.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| leadId | Yes |
Implementation Reference
- src/index.ts:315-320 (registration)Registration of the 'marketo_delete_lead' tool with the MCP server, including description and Zod schema for leadId.
server.tool( 'marketo_delete_lead', 'Permanently delete a lead by its numeric ID. This action cannot be undone.', { leadId: z.number() }, tool(async ({ leadId }) => makeApiRequest(`/rest/v1/leads/${leadId}/delete.json`, 'POST')) ); - src/index.ts:318-318 (schema)Input schema for 'marketo_delete_lead': leadId is a required number (z.number()).
{ leadId: z.number() }, - src/index.ts:319-319 (handler)Handler for 'marketo_delete_lead': calls makeApiRequest to POST to /rest/v1/leads/{leadId}/delete.json. The 'tool' wrapper (lines 55-74) provides error handling and response formatting.
tool(async ({ leadId }) => makeApiRequest(`/rest/v1/leads/${leadId}/delete.json`, 'POST')) - src/index.ts:23-53 (helper)The makeApiRequest helper function used by the tool handler to make authenticated HTTP requests to the Marketo API.
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)The 'tool' wrapper function that wraps handler logic, captures errors, and formats the response as MCP content.
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, }; } }; }