marketo_get_channels
Retrieve all program channels in your Marketo instance to see available progression statuses for program types, such as Webinar with Invited, Registered, and Attended.
Instructions
List all program channels in the instance. Channels define the progression statuses available to programs (e.g., Webinar: Invited > Registered > Attended).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxReturn | No | ||
| offset | No |
Implementation Reference
- src/index.ts:185-191 (handler)The handler function that executes the 'marketo_get_channels' tool logic. It takes optional maxReturn and offset parameters, constructs a query string, and calls the Marketo Asset API GET /asset/v1/channels.json endpoint.
tool(async ({ maxReturn = 200, offset = 0 }) => { const params = new URLSearchParams({ maxReturn: maxReturn.toString(), offset: offset.toString(), }); return makeApiRequest(`/asset/v1/channels.json?${params.toString()}`, 'GET'); }) - src/index.ts:181-184 (schema)Input schema for the tool: optional 'maxReturn' (number) and 'offset' (number) parameters, defined using Zod.
{ maxReturn: z.number().optional(), offset: z.number().optional(), }, - src/index.ts:178-192 (registration)Registration of the 'marketo_get_channels' tool with the MCP server using server.tool(), including name, description, schema, and handler.
server.tool( 'marketo_get_channels', 'List all program channels in the instance. Channels define the progression statuses available to programs (e.g., Webinar: Invited > Registered > Attended).', { maxReturn: z.number().optional(), offset: z.number().optional(), }, tool(async ({ maxReturn = 200, offset = 0 }) => { const params = new URLSearchParams({ maxReturn: maxReturn.toString(), offset: offset.toString(), }); return makeApiRequest(`/asset/v1/channels.json?${params.toString()}`, 'GET'); }) ); - src/index.ts:23-53 (helper)The makeApiRequest helper function that handles authentication token injection, HTTP request execution via Axios, and error handling for all API calls including this tool.
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)The 'tool' wrapper function that wraps handlers with error handling and formats responses into 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, }; } };