marketo_get_channel_by_id
Retrieve a Marketo channel's metadata, including progression statuses and their step numbers, by providing the channel ID.
Instructions
Get a single Marketo channel by ID. Returns channel metadata including progression statuses and their step numbers.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Channel ID |
Implementation Reference
- src/tools/channels.ts:24-36 (handler)The tool 'marketo_get_channel_by_id' is defined as a server.tool() call. The handler (async callback) makes a GET request to /rest/asset/v1/channel/{id}.json to fetch a single Marketo channel by ID.
// ── marketo_get_channel_by_id ────────────────────────────────────────────── server.tool( "marketo_get_channel_by_id", "Get a single Marketo channel by ID. Returns channel metadata including progression statuses and their step numbers.", { id: z.number().describe("Channel ID"), }, async (args) => { try { return ok(await makeRequest(`/rest/asset/v1/channel/${args.id}.json`)); } catch (e) { return err(e); } } ); - src/tools/channels.ts:29-30 (schema)Input schema for the tool: requires a single numeric 'id' parameter.
id: z.number().describe("Channel ID"), }, - src/index.ts:11-11 (registration)The registerChannelTools function is imported from './tools/channels.js' and called on line 27 to register all channel tools including marketo_get_channel_by_id.
import { registerChannelTools } from "./tools/channels.js"; - src/index.ts:27-27 (registration)registerChannelTools(server) registers the channel tools on the MCP server.
registerChannelTools(server); - src/client.ts:21-49 (helper)The makeRequest helper function that the handler calls to make authenticated HTTP requests to the Marketo API.
export async function makeRequest<T = unknown>( endpoint: string, method: Method = "GET", data?: unknown, contentType?: string, ): Promise<T> { const token = await getAccessToken(); const config: AxiosRequestConfig = { url: `${MARKETO_BASE_URL}${endpoint}`, method, headers: { Authorization: `Bearer ${token}`, ...(contentType ? { "Content-Type": contentType } : {}), }, ...(data && method !== "GET" ? { data } : {}), ...(data && method === "GET" ? { params: data } : {}), }; const res = await axios(config); const body = res.data; // Marketo REST API returns errors inside the response body if (body?.errors?.length) { const e = body.errors[0]; throw new MarketoError(`${e.code}: ${e.message}`, res.status); } return body as T; }