marketo_get_program_by_id
Retrieve full program metadata including channel, status, costs, tags, and folder path by providing the program's numeric ID.
Instructions
Retrieve a single program by its numeric ID. Returns full program metadata including channel, status, costs, tags, and folder path.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| programId | Yes |
Implementation Reference
- src/index.ts:445-450 (registration)Registers the 'marketo_get_program_by_id' MCP tool with a programId parameter. The handler is an inline function that makes a GET request to the Marketo API endpoint /asset/v1/program/{programId}.json.
server.tool( 'marketo_get_program_by_id', 'Retrieve a single program by its numeric ID. Returns full program metadata including channel, status, costs, tags, and folder path.', { programId: z.number() }, tool(async ({ programId }) => makeApiRequest(`/asset/v1/program/${programId}.json`, 'GET')) ); - src/index.ts:448-448 (schema)Defines the input schema: a single required numeric parameter 'programId' validated via Zod.
{ programId: z.number() }, - src/index.ts:449-449 (handler)The handler logic wrapped by the 'tool' helper function. It calls makeApiRequest with the program endpoint using the provided programId.
tool(async ({ programId }) => makeApiRequest(`/asset/v1/program/${programId}.json`, 'GET')) - src/index.ts:55-73 (helper)The 'tool' helper that wraps handler functions, converting their return value into MCP text content or an error response.
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, }; } }; - src/index.ts:23-53 (helper)The makeApiRequest helper that authenticates via TokenManager and performs the HTTP request to the Marketo 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; } }