marketo_remove_lead_from_list
Remove leads from a Marketo static list by specifying list ID and up to 300 lead IDs.
Instructions
Remove one or more leads from a static list. Accepts an array of lead IDs. Max 300 leads per call.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| listId | Yes | ||
| leadIds | Yes |
Implementation Reference
- src/index.ts:402-414 (registration)Registration of the 'marketo_remove_lead_from_list' tool using server.tool(). Defines tool name, description, input schema (listId: number, leadIds: array of numbers), and the handler.
server.tool( 'marketo_remove_lead_from_list', 'Remove one or more leads from a static list. Accepts an array of lead IDs. Max 300 leads per call.', { listId: z.number(), leadIds: z.array(z.number()), }, tool(async ({ listId, leadIds }) => makeApiRequest(`/rest/v1/lists/${listId}/leads/delete.json`, 'POST', { input: leadIds.map(id => ({ id })), }) ) ); - src/index.ts:409-413 (handler)Handler function for removing leads from a list. Wraps makeApiRequest to POST to /rest/v1/lists/{listId}/leads/delete.json with lead IDs mapped as input array.
tool(async ({ listId, leadIds }) => makeApiRequest(`/rest/v1/lists/${listId}/leads/delete.json`, 'POST', { input: leadIds.map(id => ({ id })), }) ) - src/index.ts:405-408 (schema)Zod schema defining input parameters: listId (z.number()) and leadIds (z.array(z.number())).
{ listId: z.number(), leadIds: z.array(z.number()), }, - src/index.ts:23-53 (helper)makeApiRequest helper function that handles authentication headers, HTTP method, and API calls to Marketo.
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)tool wrapper helper that invokes the handler, formats success/error responses for the MCP protocol.
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, }; } }; }