marketo_get_programs
List Marketo programs filtered by type, date range, or tag. Retrieve program metadata including channel, status, costs, and tags with pagination.
Instructions
List programs in Marketo. Filter by type (filterType: id, programType, folder, tag) with filterValues, or by date range (earliestUpdatedAt/latestUpdatedAt). Paginate with maxReturn/offset. Returns program metadata including channel, status, costs, and tags.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxReturn | No | ||
| offset | No | ||
| filterType | No | ||
| filterValues | No | ||
| earliestUpdatedAt | No | ||
| latestUpdatedAt | No |
Implementation Reference
- src/index.ts:432-443 (handler)Handler function for marketo_get_programs tool. Builds query params (maxReturn, offset, filterType, filterValues, earliestUpdatedAt, latestUpdatedAt) and calls makeApiRequest to GET /asset/v1/programs.json
tool(async ({ maxReturn = 200, offset = 0, filterType, filterValues, earliestUpdatedAt, latestUpdatedAt }) => { const params = new URLSearchParams({ maxReturn: maxReturn.toString(), offset: offset.toString(), }); if (filterType) params.append('filterType', filterType); if (filterValues) params.append('filterValues', filterValues); if (earliestUpdatedAt) params.append('earliestUpdatedAt', earliestUpdatedAt); if (latestUpdatedAt) params.append('latestUpdatedAt', latestUpdatedAt); return makeApiRequest(`/asset/v1/programs.json?${params.toString()}`, 'GET'); }) ); - src/index.ts:421-443 (registration)Registration of the marketo_get_programs tool using server.tool() with name, description, Zod schema for inputs (maxReturn, offset, filterType, filterValues, earliestUpdatedAt, latestUpdatedAt), and handler
server.tool( 'marketo_get_programs', 'List programs in Marketo. Filter by type (filterType: id, programType, folder, tag) with filterValues, or by date range (earliestUpdatedAt/latestUpdatedAt). Paginate with maxReturn/offset. Returns program metadata including channel, status, costs, and tags.', { maxReturn: z.number().optional(), offset: z.number().optional(), filterType: z.enum(['id', 'programType', 'folder', 'tag']).optional(), filterValues: z.string().optional(), earliestUpdatedAt: z.string().optional(), latestUpdatedAt: z.string().optional(), }, tool(async ({ maxReturn = 200, offset = 0, filterType, filterValues, earliestUpdatedAt, latestUpdatedAt }) => { const params = new URLSearchParams({ maxReturn: maxReturn.toString(), offset: offset.toString(), }); if (filterType) params.append('filterType', filterType); if (filterValues) params.append('filterValues', filterValues); if (earliestUpdatedAt) params.append('earliestUpdatedAt', earliestUpdatedAt); if (latestUpdatedAt) params.append('latestUpdatedAt', latestUpdatedAt); return makeApiRequest(`/asset/v1/programs.json?${params.toString()}`, 'GET'); }) ); - src/index.ts:424-431 (schema)Input schema for marketo_get_programs: maxReturn (optional number), offset (optional number), filterType (enum: id/programType/folder/tag), filterValues (optional string), earliestUpdatedAt (optional string), latestUpdatedAt (optional string)
{ maxReturn: z.number().optional(), offset: z.number().optional(), filterType: z.enum(['id', 'programType', 'folder', 'tag']).optional(), filterValues: z.string().optional(), earliestUpdatedAt: z.string().optional(), latestUpdatedAt: z.string().optional(), }, - src/index.ts:23-53 (helper)makeApiRequest helper function used by the handler to make HTTP requests to Marketo API with auth token
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-73 (helper)tool() wrapper helper function that wraps handlers with try/catch and formats responses as MCP content blocks
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, }; } };