marketo_get_forms
List Marketo forms filtered by approval status and paginated. Retrieve form metadata including URL, status, and folder location.
Instructions
List forms in the Marketo instance. Filter by approval status (approved/draft) and paginate with maxReturn/offset. Returns form metadata including URL, status, and folder location.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxReturn | No | ||
| offset | No | ||
| status | No |
Implementation Reference
- src/index.ts:81-97 (registration)Registration of the 'marketo_get_forms' tool via server.tool(), defining its description, schema (maxReturn, offset, status), and binding it to the handler function.
server.tool( 'marketo_get_forms', 'List forms in the Marketo instance. Filter by approval status (approved/draft) and paginate with maxReturn/offset. Returns form metadata including URL, status, and folder location.', { maxReturn: z.number().optional(), offset: z.number().optional(), status: z.enum(['approved', 'draft']).optional(), }, tool(async ({ maxReturn = 200, offset = 0, status }) => { const params = new URLSearchParams({ maxReturn: maxReturn.toString(), offset: offset.toString(), }); if (status) params.append('status', status); return makeApiRequest(`/asset/v1/forms.json?${params.toString()}`, 'GET'); }) ); - src/index.ts:84-88 (schema)Input schema definition for marketo_get_forms: maxReturn (optional number), offset (optional number), status (optional enum: 'approved'|'draft').
{ maxReturn: z.number().optional(), offset: z.number().optional(), status: z.enum(['approved', 'draft']).optional(), }, - src/index.ts:89-96 (handler)Handler function for marketo_get_forms. Constructs query params from inputs, calls Marketo API GET /asset/v1/forms.json with pagination and optional status filter.
tool(async ({ maxReturn = 200, offset = 0, status }) => { const params = new URLSearchParams({ maxReturn: maxReturn.toString(), offset: offset.toString(), }); if (status) params.append('status', status); return makeApiRequest(`/asset/v1/forms.json?${params.toString()}`, 'GET'); }) - src/index.ts:23-53 (helper)makeApiRequest helper function that performs authenticated HTTP requests to the Marketo API using an access token fetched via TokenManager.
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-74 (helper)The 'tool' wrapper function that wraps handler functions with try/catch, returning success JSON content or error responses with isError flag.
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, }; } }; }