marketo_create_channel
Creates a new Marketo program channel with a unique name and type. The type determines which program types can use this channel.
Instructions
Create a new program channel. Channels must have a unique name and type. The type determines which program types can use this channel.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| description | No | ||
| type | Yes | ||
| applicationId | No |
Implementation Reference
- src/index.ts:210-217 (handler)The function that executes the Marketo create channel API call. It's an inline async handler that takes (name, description, type, applicationId) and sends a POST request to /asset/v1/channels.json with those fields.
tool(async ({ name, description, type, applicationId }) => makeApiRequest('/asset/v1/channels.json', 'POST', { name, description, type, applicationId, }) ) - src/index.ts:204-209 (schema)Zod schema defining the input parameters for the create channel tool: name (string, required), description (string, optional), type (string, required), applicationId (number, optional).
{ name: z.string(), description: z.string().optional(), type: z.string(), applicationId: z.number().optional(), }, - src/index.ts:201-218 (registration)Registration of the 'marketo_create_channel' tool with the MCP server via server.tool(), including its description, input schema, and handler.
server.tool( 'marketo_create_channel', 'Create a new program channel. Channels must have a unique name and type. The type determines which program types can use this channel.', { name: z.string(), description: z.string().optional(), type: z.string(), applicationId: z.number().optional(), }, tool(async ({ name, description, type, applicationId }) => makeApiRequest('/asset/v1/channels.json', 'POST', { name, description, type, applicationId, }) ) ); - src/index.ts:23-53 (helper)The makeApiRequest helper function used by the handler to perform the actual HTTP request to the Marketo REST API.
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; } }