Skip to main content
Glama
alexleventer

Marketo MCP Server

by alexleventer

marketo_create_or_update_lead

Bulk create or update Marketo leads (upsert) using an array of records. Deduplicates by specified lookup field, defaulting to email. Supports up to 300 leads per call.

Instructions

Bulk create or update leads (upsert). Accepts an array of lead records with standard and custom fields. Deduplicates by lookupField (default: email). Max 300 leads per call.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYes
lookupFieldNo
partitionNameNo

Implementation Reference

  • src/index.ts:286-313 (registration)
    Registration of the 'marketo_create_or_update_lead' tool on the MCP server via server.tool(). Defines the tool name, description, schema, and handler.
    server.tool(
      'marketo_create_or_update_lead',
      'Bulk create or update leads (upsert). Accepts an array of lead records with standard and custom fields. Deduplicates by lookupField (default: email). Max 300 leads per call.',
      {
        input: z.array(
          z.object({
            email: z.string().email(),
            firstName: z.string().optional(),
            lastName: z.string().optional(),
            company: z.string().optional(),
            title: z.string().optional(),
            phone: z.string().optional(),
            address: z.string().optional(),
            city: z.string().optional(),
            state: z.string().optional(),
            zipCode: z.string().optional(),
            country: z.string().optional(),
            website: z.string().optional(),
            customFields: z.record(z.string(), z.any()).optional(),
          })
        ),
        lookupField: z.enum(['email', 'id', 'cookie']).optional(),
        partitionName: z.string().optional(),
      },
      tool(async ({ input, lookupField = 'email', partitionName }) =>
        makeApiRequest('/rest/v1/leads.json', 'POST', { input, lookupField, partitionName })
      )
    );
  • The actual handler function for the tool. Makes a POST request to Marketo's /rest/v1/leads.json endpoint with the input leads, lookupField, and partitionName parameters via makeApiRequest.
    tool(async ({ input, lookupField = 'email', partitionName }) =>
      makeApiRequest('/rest/v1/leads.json', 'POST', { input, lookupField, partitionName })
    )
  • Zod schema definitions for the tool's input parameters: input (array of lead objects with standard fields and optional customFields), lookupField (enum: email/id/cookie), and partitionName (optional string).
    {
      input: z.array(
        z.object({
          email: z.string().email(),
          firstName: z.string().optional(),
          lastName: z.string().optional(),
          company: z.string().optional(),
          title: z.string().optional(),
          phone: z.string().optional(),
          address: z.string().optional(),
          city: z.string().optional(),
          state: z.string().optional(),
          zipCode: z.string().optional(),
          country: z.string().optional(),
          website: z.string().optional(),
          customFields: z.record(z.string(), z.any()).optional(),
        })
      ),
      lookupField: z.enum(['email', 'id', 'cookie']).optional(),
      partitionName: z.string().optional(),
    },
  • The makeApiRequest helper function that executes the actual HTTP request. It obtains a Bearer token via TokenManager, then makes the axios call to the Marketo API endpoint.
    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;
      }
    }
  • The 'tool' wrapper helper that wraps the handler to return a formatted response object with content array for the MCP protocol, including 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,
          };
        }
      };
    }
Behavior3/5

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

No annotations are provided, so the description must carry the burden. It discloses upsert behavior, dedup logic, and batch limit, but lacks details on merge semantics for existing fields, authorization needs, rate limits, or error handling. Adequate but could be richer.

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?

The description is two sentences, front-loaded with the core action 'upsert'. Every word adds value: verb, resource, limit, dedup key. No redundancy.

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?

Missing output schema and annotations, the description covers input and constraints but omits response format (e.g., success/error status for each lead) and partial failure behavior. It is adequate for a simple batch tool but not fully complete.

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

Parameters3/5

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

Schema description coverage is 0%, so the description must compensate. It explains the 'input' parameter as an array of lead records with standard and custom fields, and mentions lookupField and default email. However, it does not detail 'partitionName' or customFields structure, leaving gaps.

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 description clearly states 'Bulk create or update leads (upsert)' and specifies accepting arrays with standard/custom fields, dedup by lookupField, and max 300 leads. This distinctly separates it from sibling tools like marketo_add_lead_to_list or marketo_delete_lead.

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 explicitly indicates when to use this tool (for upserting leads) and provides constraints (max 300 per call). It implicitly suggests batch usage, but does not explicitly state when not to use it or mention alternatives, though sibling list provides context.

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