marketo_delete_channel
Remove a channel from Marketo by providing its ID. The deletion only succeeds if no programs are currently associated with the channel.
Instructions
Delete a channel by ID. Fails if any programs are currently using this channel.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channelId | Yes |
Implementation Reference
- src/index.ts:244-246 (handler)The handler function that executes the marketo_delete_channel tool logic. Makes a POST request to /asset/v1/channel/{channelId}/delete.json to delete a channel by its numeric ID.
tool(async ({ channelId }) => makeApiRequest(`/asset/v1/channel/${channelId}/delete.json`, 'POST') ) - src/index.ts:243-243 (schema)The input schema for marketo_delete_channel, defined using Zod. Accepts a single required parameter: channelId (number).
{ channelId: z.number() }, - src/index.ts:240-247 (registration)Registration of the tool on the McpServer via server.tool() with name 'marketo_delete_channel', description, Zod schema, and handler wrapped in the tool() error-handling helper.
server.tool( 'marketo_delete_channel', 'Delete a channel by ID. Fails if any programs are currently using this channel.', { channelId: z.number() }, tool(async ({ channelId }) => makeApiRequest(`/asset/v1/channel/${channelId}/delete.json`, 'POST') ) ); - src/index.ts:23-53 (helper)The makeApiRequest helper function used by the handler to make authenticated HTTP requests to Marketo REST API endpoints. Handles token injection, content-type formatting, and error logging.
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 helper that provides standardized error handling and response formatting for all tool handlers, including marketo_delete_channel.
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, }; } };