marketo_create_channel
Create a new marketing channel in Marketo to organize and manage campaigns, forms, and assets by defining its name, type, and description.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| description | No | ||
| type | Yes | ||
| applicationId | No |
Implementation Reference
- src/index.ts:298-319 (handler)The core handler function that implements the logic for creating a Marketo channel by preparing the request data and calling the makeApiRequest helper to POST to the Marketo API endpoint.async ({ name, description, type, applicationId }) => { try { const data = { name, description, type, applicationId, }; const response = await makeApiRequest('/asset/v1/channels.json', 'POST', data); return { content: [{ type: 'text', text: JSON.stringify(response, null, 2) }], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error: ${error.response?.data?.message || error.message}` }, ], }; } }
- src/index.ts:292-297 (schema)Zod input schema defining required parameters (name, type) and optional ones (description, applicationId) for the marketo_create_channel tool.{ name: z.string(), description: z.string().optional(), type: z.string(), applicationId: z.number().optional(), },
- src/index.ts:290-320 (registration)The server.tool() call that registers the marketo_create_channel tool with the MCP server, providing the name, input schema, and handler function.server.tool( 'marketo_create_channel', { name: z.string(), description: z.string().optional(), type: z.string(), applicationId: z.number().optional(), }, async ({ name, description, type, applicationId }) => { try { const data = { name, description, type, applicationId, }; const response = await makeApiRequest('/asset/v1/channels.json', 'POST', data); return { content: [{ type: 'text', text: JSON.stringify(response, null, 2) }], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error: ${error.response?.data?.message || error.message}` }, ], }; } } );
- src/index.ts:22-52 (helper)Helper function makeApiRequest used by the tool to perform authenticated HTTP requests to the Marketo API.async function makeApiRequest( endpoint: string, method: string, data?: any, contentType: string = 'application/json' ) { const token = await tokenManager.getToken(); const headers: any = { Authorization: `Bearer ${token}`, }; if (contentType) { headers['Content-Type'] = contentType; } try { const response = await axios({ url: `${MARKETO_BASE_URL}${endpoint}`, method: 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; } }