Skip to main content
Glama
alexleventer

Marketo MCP Server

by alexleventer

marketo_get_lead_activities

Retrieve activity records for a specified lead. Optionally filter by activity type IDs to target specific actions. Uses cursor-based pagination for efficient data retrieval.

Instructions

Fetch activity records for a specific lead. Filter by activity type IDs (e.g., 1=Visit Webpage, 2=Fill Out Form, 6=Send Email). Supports cursor-based pagination via nextPageToken.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
leadIdYes
activityTypeIdsNo
nextPageTokenNo
batchSizeNo

Implementation Reference

  • src/index.ts:315-344 (registration)
    Registration of the 'marketo_get_lead_activities' tool on the MCP server using server.tool(), with input schema and handler.
    server.tool(
      'marketo_delete_lead',
      'Permanently delete a lead by its numeric ID. This action cannot be undone.',
      { leadId: z.number() },
      tool(async ({ leadId }) => makeApiRequest(`/rest/v1/leads/${leadId}/delete.json`, 'POST'))
    );
    
    // ============================================================================
    // Marketo Lead Database API — Activities
    // ============================================================================
    
    server.tool(
      'marketo_get_lead_activities',
      'Fetch activity records for a specific lead. Filter by activity type IDs (e.g., 1=Visit Webpage, 2=Fill Out Form, 6=Send Email). Supports cursor-based pagination via nextPageToken.',
      {
        leadId: z.number(),
        activityTypeIds: z.array(z.number()).optional(),
        nextPageToken: z.string().optional(),
        batchSize: z.number().optional(),
      },
      tool(async ({ leadId, activityTypeIds, nextPageToken, batchSize = 100 }) => {
        const params = new URLSearchParams({ batchSize: batchSize.toString() });
        if (activityTypeIds) params.append('activityTypeIds', activityTypeIds.join(','));
        if (nextPageToken) params.append('nextPageToken', nextPageToken);
        return makeApiRequest(
          `/rest/v1/activities/lead/${leadId}.json?${params.toString()}`,
          'GET'
        );
      })
    );
  • Handler logic: builds query parameters (batchSize, activityTypeIds, nextPageToken) and calls makeApiRequest to GET /rest/v1/activities/lead/{leadId}.json.
    tool(async ({ leadId, activityTypeIds, nextPageToken, batchSize = 100 }) => {
      const params = new URLSearchParams({ batchSize: batchSize.toString() });
      if (activityTypeIds) params.append('activityTypeIds', activityTypeIds.join(','));
      if (nextPageToken) params.append('nextPageToken', nextPageToken);
      return makeApiRequest(
        `/rest/v1/activities/lead/${leadId}.json?${params.toString()}`,
        'GET'
      );
    })
  • Input schema using Zod: leadId (number, required), activityTypeIds (optional array of numbers), nextPageToken (optional string), batchSize (optional number).
    {
      leadId: z.number(),
      activityTypeIds: z.array(z.number()).optional(),
      nextPageToken: z.string().optional(),
      batchSize: z.number().optional(),
    },
  • Helper function makeApiRequest that handles authentication, HTTP requests, and error formatting for all Marketo API calls.
    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;
      }
    }
  • Helper wrapper function 'tool' that wraps handlers with try/catch and formats the MCP response content.
    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,
          };
        }
      };
    }
Behavior3/5

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

No annotations are provided, so the description carries the burden. It discloses cursor-based pagination via nextPageToken but does not mention error handling, rate limits, or ordering. Reasonably transparent for a read operation.

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?

Two sentences are front-loaded: first declares purpose, second adds filtering and pagination. No redundant or verbose language.

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

Completeness3/5

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

For a tool with 4 parameters (1 required) and no output schema, the description explains three parameters but omits batchSize and does not describe the response format or limits. Adequate but with gaps.

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?

Schema description coverage is 0%. The description compensates by explaining activityTypeIds (with examples) and nextPageToken for pagination. However, batchSize is not explained, and leadId's purpose is implied. Adds significant meaning beyond the schema.

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?

Description clearly states 'Fetch activity records for a specific lead' with a specific verb and resource. It distinguishes from sibling tools like marketo_get_lead_by_id and marketo_get_lead_changes by focusing on activities.

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

Usage Guidelines4/5

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

The description mentions filtering by activity type IDs and cursor-based pagination, providing clear usage context. It does not explicitly state when not to use or mention alternatives, but the context is adequate.

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