marketo_delete_lead
Permanently delete a Marketo lead by providing its lead ID. This irreversible tool removes the specified lead from your Marketo database.
Instructions
Delete a lead from Marketo by lead ID. This is permanent and cannot be undone.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Lead ID to delete |
Implementation Reference
- src/tools/leads.ts:64-75 (handler)The handler for 'marketo_delete_lead'. Registers a tool that accepts a numeric 'id' and makes a POST request to `DELETE /rest/v1/leads/{id}/delete.json` to permanently delete a Marketo lead.
server.tool( "marketo_delete_lead", "Delete a lead from Marketo by lead ID. This is permanent and cannot be undone.", { id: z.number().describe("Lead ID to delete"), }, async (args) => { try { return ok(await makeRequest(`/rest/v1/leads/${args.id}/delete.json`, "POST")); } catch (e) { return err(e); } } ); - src/tools/leads.ts:67-68 (schema)The input schema for 'marketo_delete_lead'. Defines a single required parameter 'id' of type number (Zod schema) representing the Marketo lead ID to delete.
{ id: z.number().describe("Lead ID to delete"), - src/index.ts:22-22 (registration)The registration call: `registerLeadTools(server)` is invoked in the main entry point, which causes the tool 'marketo_delete_lead' to be registered on the MCP server.
registerLeadTools(server); - src/client.ts:21-49 (helper)The `makeRequest` helper function used by the tool handler to make authenticated HTTP requests to the Marketo REST API. It handles OAuth token injection and error parsing.
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; }