Skip to main content
Glama
alexleventer

Marketo MCP Server

by alexleventer

marketo_get_lead_changes

Retrieve field-change history for a lead to audit data changes and track lifecycle progression. Optionally filter by specific fields.

Instructions

Fetch field-change history for a specific lead. Optionally filter to specific field names. Useful for auditing data changes and tracking lead lifecycle progression.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
leadIdYes
fieldsNo
nextPageTokenNo
batchSizeNo

Implementation Reference

  • The handler function for the marketo_get_lead_changes tool. It constructs query parameters (batchSize, fields, nextPageToken) and makes a GET request to the Marketo API endpoint /rest/v1/activities/lead/{leadId}/changes.json.
    tool(async ({ leadId, fields, nextPageToken, batchSize = 100 }) => {
      const params = new URLSearchParams({ batchSize: batchSize.toString() });
      if (fields) params.append('fields', fields.join(','));
      if (nextPageToken) params.append('nextPageToken', nextPageToken);
      return makeApiRequest(
        `/rest/v1/activities/lead/${leadId}/changes.json?${params.toString()}`,
        'GET'
      );
    })
  • Input schema for the tool, using Zod validation: leadId (number, required), fields (array of strings, optional), nextPageToken (string, optional), batchSize (number, optional).
    {
      leadId: z.number(),
      fields: z.array(z.string()).optional(),
      nextPageToken: z.string().optional(),
      batchSize: z.number().optional(),
  • src/index.ts:346-364 (registration)
    Registration of the marketo_get_lead_changes tool on the MCP server via server.tool() with its name, description, schema, and handler.
    server.tool(
      'marketo_get_lead_changes',
      'Fetch field-change history for a specific lead. Optionally filter to specific field names. Useful for auditing data changes and tracking lead lifecycle progression.',
      {
        leadId: z.number(),
        fields: z.array(z.string()).optional(),
        nextPageToken: z.string().optional(),
        batchSize: z.number().optional(),
      },
      tool(async ({ leadId, fields, nextPageToken, batchSize = 100 }) => {
        const params = new URLSearchParams({ batchSize: batchSize.toString() });
        if (fields) params.append('fields', fields.join(','));
        if (nextPageToken) params.append('nextPageToken', nextPageToken);
        return makeApiRequest(
          `/rest/v1/activities/lead/${leadId}/changes.json?${params.toString()}`,
          'GET'
        );
      })
    );
  • Helper function makeApiRequest that adds bearer token authentication, sends the HTTP request via axios, and returns the response data.
    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?

With no annotations, the description must carry the full burden. It correctly implies a read operation but does not detail pagination behavior, sorting, or date ranges. Adequate but not comprehensive.

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, no filler. The first sentence states the core action, the second adds optional filtering and use cases. Efficient and front-loaded.

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

Completeness2/5

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

No output schema, yet the description does not mention what the response contains (e.g., list of changes with fields like timestamp, old/new values). Missing essential info for the agent to understand the return value.

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

Parameters2/5

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

With 0% schema description coverage, the description must compensate. It explains 'leadId' and 'fields' filtering but omits 'nextPageToken' (pagination) and 'batchSize'. Only partial value added.

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?

The verb 'Fetch' and resource 'field-change history' are specific and clear. It distinguishes itself from siblings like marketo_get_lead_by_id (current state) and marketo_get_lead_activities (activities, not changes).

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?

States it's 'useful for auditing data changes and tracking lead lifecycle progression', providing clear context for when to use. It does not explicitly exclude cases, but the purpose is well-implied given sibling names.

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