Skip to main content
Glama
alexleventer

Marketo MCP Server

by alexleventer

marketo_get_program_members

Retrieve leads that are members of a specified program, including member status. Optionally select fields and use cursor-based pagination for efficient data retrieval.

Instructions

Get leads that are members of a specific program. Optionally specify which fields to return. Supports cursor-based pagination via nextPageToken. Returns member status alongside lead data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
programIdYes
fieldsNo
batchSizeNo
nextPageTokenNo

Implementation Reference

  • src/index.ts:475-493 (registration)
    Registration of the 'marketo_get_program_members' tool with server.tool(), including schema definition and handler wiring.
    server.tool(
      'marketo_get_program_members',
      'Get leads that are members of a specific program. Optionally specify which fields to return. Supports cursor-based pagination via nextPageToken. Returns member status alongside lead data.',
      {
        programId: z.number(),
        fields: z.array(z.string()).optional(),
        batchSize: z.number().optional(),
        nextPageToken: z.string().optional(),
      },
      tool(async ({ programId, fields, batchSize = 200, nextPageToken }) => {
        const params = new URLSearchParams({ batchSize: batchSize.toString() });
        if (fields) params.append('fields', fields.join(','));
        if (nextPageToken) params.append('nextPageToken', nextPageToken);
        return makeApiRequest(
          `/rest/v1/leads/programs/${programId}.json?${params.toString()}`,
          'GET'
        );
      })
    );
  • Schema definition for the tool's parameters: programId (required number), fields (optional string array), batchSize (optional number), nextPageToken (optional string).
    {
      programId: z.number(),
      fields: z.array(z.string()).optional(),
      batchSize: z.number().optional(),
      nextPageToken: z.string().optional(),
    },
  • Handler function that builds query params, calls Marketo REST API endpoint /rest/v1/leads/programs/{programId}.json via GET request to retrieve program members.
    tool(async ({ programId, fields, batchSize = 200, nextPageToken }) => {
      const params = new URLSearchParams({ batchSize: batchSize.toString() });
      if (fields) params.append('fields', fields.join(','));
      if (nextPageToken) params.append('nextPageToken', nextPageToken);
      return makeApiRequest(
        `/rest/v1/leads/programs/${programId}.json?${params.toString()}`,
        'GET'
      );
    })
  • The 'tool' helper function wraps the handler to convert its return value into an MCP text content response, with error handling.
    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,
          };
        }
      };
    }
  • The makeApiRequest helper function that performs the actual HTTP call to the Marketo API with authentication and error handling.
    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;
      }
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Mentions pagination and return data but lacks explicit read-only indication, rate limits, or side effects. No annotations to offset.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

21-word sentence packed with essential information without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers required and optional parameters, pagination, and return data. No output schema, but description adequately specifies output.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Adds meaning for programId, fields, and nextPageToken beyond the schema. batchSize is not described but can be inferred from pagination context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states the action ('Get leads'), the resource ('members of a specific program'), and optional features (field selection, pagination). Distinguishes from siblings like marketo_get_programs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tells when to use (get program members) and mentions options, but no exclusions, prerequisites, or alternatives for cases like leads not in a program.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/alexleventer/marketo-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server