marketo_get_bulk_export_file
Retrieve the CSV or TSV file from a completed bulk export job in Marketo. Specify the export job ID to download its data. Only works when the job status is Completed.
Instructions
Download the file from a completed bulk export job. Returns CSV/TSV content. Only works when job status is Completed. Large files may be clipped in MCP response.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exportId | Yes | Export job ID (must be in Completed status) |
Implementation Reference
- src/tools/bulkExport.ts:64-75 (handler)The handler function for the 'marketo_get_bulk_export_file' tool. Defines the schema (exportId required), and calls makeRequest to GET /bulk/v1/leads/export/{exportId}/file.json, returning the CSV/TSV file content.
server.tool( "marketo_get_bulk_export_file", "Download the file from a completed bulk export job. Returns CSV/TSV content. Only works when job status is Completed. Large files may be clipped in MCP response.", { exportId: z.string().describe("Export job ID (must be in Completed status)"), }, async (args) => { try { return ok(await makeRequest(`/bulk/v1/leads/export/${args.exportId}/file.json`)); } catch (e) { return err(e); } } ); - src/tools/bulkExport.ts:67-69 (schema)Input schema for the tool: requires an 'exportId' string describing the export job ID (must be in Completed status).
{ exportId: z.string().describe("Export job ID (must be in Completed status)"), }, - src/tools/bulkExport.ts:64-75 (registration)Tool registered via server.tool() call within registerBulkExportTools function, using the name 'marketo_get_bulk_export_file'.
server.tool( "marketo_get_bulk_export_file", "Download the file from a completed bulk export job. Returns CSV/TSV content. Only works when job status is Completed. Large files may be clipped in MCP response.", { exportId: z.string().describe("Export job ID (must be in Completed status)"), }, async (args) => { try { return ok(await makeRequest(`/bulk/v1/leads/export/${args.exportId}/file.json`)); } catch (e) { return err(e); } } ); - src/index.ts:29-29 (registration)Registration entry point: registerBulkExportTools(server) is called from index.ts to register all bulk export tools including marketo_get_bulk_export_file.
registerBulkExportTools(server); - src/client.ts:21-49 (helper)The makeRequest helper used by the handler. Handles authentication (via getAccessToken), constructs the API call, and processes Marketo error responses.
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; }