marketo_get_program_by_id
Retrieve a Marketo program by ID to access full metadata including channel, status, costs, tags, and folder location.
Instructions
Get a single Marketo program by ID. Returns full program metadata including channel, status, costs, tags, and folder location.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Program ID |
Implementation Reference
- src/tools/programs.ts:39-43 (handler)Handler function for markito_get_program_by_id — calls Marketo Asset API endpoint /rest/asset/v1/program/{id}.json with the program ID and returns the result.
async (args) => { try { return ok(await makeRequest(`/rest/asset/v1/program/${args.id}.json`)); } catch (e) { return err(e); } } - src/tools/programs.ts:36-38 (schema)Zod schema defining the input parameter: a single numeric 'id' field.
{ id: z.number().describe("Program ID"), }, - src/tools/programs.ts:33-44 (registration)Registration of the tool 'marketo_get_program_by_id' on the MCP server via server.tool() inside registerProgramTools().
server.tool( "marketo_get_program_by_id", "Get a single Marketo program by ID. Returns full program metadata including channel, status, costs, tags, and folder location.", { id: z.number().describe("Program ID"), }, async (args) => { try { return ok(await makeRequest(`/rest/asset/v1/program/${args.id}.json`)); } catch (e) { return err(e); } } ); - src/client.ts:21-49 (helper)Helper function makeRequest that handles authenticated HTTP requests to the Marketo API, used by the handler.
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; }