Marketo MCP in 15

Wondering what an MCP is and how that applies to your life as a Marketo user? In this blog we will start from the ground up by explaining what Model Context Protocol is and then we will set up a Marketo MCP server from a plug and play template that will allow us to build a personal assistant and AI agents that have access to 40+ different Marketo actions.

Model Context Protocol (MCP) is a standard that allows AI agents and LLMs to access and use external data and tools.

The way MCP is used in practice is that an MCP server is created (don’t be intimidated by the word server, think of this as any computer running code) to act as a middleman and translate the desired actions of an AI agent into API requests that carry out the actions in downstream platforms e.g. Marketo, Salesforce, Gmail.

Flow diagram showing an MCP server connecting an AI agent to Marketo, Salesforce, and Gmail
MCP server acting as a middleman to translate API tool calls into API requests
Flow diagram showing how the AI agent's MCP tool call request gets translated into a Marketo API request
Marketo MCP tool call translation into API request

In the mcp_server.py and mcp_server_auth.py scripts we can see that the way this translation is done is by using the FastMCP Python library to create wrappers around our Marketo functions. The AI agent can see all the tool call descriptions e.g. “”” Get a lead by email address from Marketo”””, so it knows when to use each tool. Once it chooses a tool to call, the mcp_server.py script then calls the corresponding Marketo function to make the necessary Marketo API request.

Screenshot of the FastMCP wrapper used to turn a function for a Marketo API request into an MCP tool
FastMCP wrappers to turn Marketo functions into MCP tools

The Marketo API is the foundation needed to build a Marketo MCP server. If you are unfamiliar with the Marketo API then you should check out the Marketo API Crash Course to learn what the Marketo API is, how to make your first API requests, and how to use the API to automate away repetitive tasks.

As already mentioned, each time an AI agent calls an MCP tool this calls one of our Marketo functions to make the required Marketo API request. The marketo_functions.py script shows all of the Marketo functions we have available and how each of them makes an API request to a particular endpoint to carry out a desired action.

N.B. The longer the time window and the more activity a lead has in this time window the longer the getLeadActivities function will need to process and the higher the likelihood that the AI agent using the Marketo MCP will throw an error because it is waiting too long.

Before we move on to the next section and test out our Marketo functions and our Marketo MCP we first need to get our Marketo API credentials by following the steps in this guide.

Screenshot of code defining Marketo functions for smart campaigns
Marketo functions to make smart campaign API requests

If you are new to programming the next part may seem intimidating but don’t let this put you off because you can use an LLM as your coding partner to help you set up the project.

Working with an LLM as your coding partner is the foundation for the Python for RevOps crash course which teaches you the programming terminology you need to communicate effectively with an LLM to write, test, and debug code. If you find yourself struggling with the setup below or you don’t know how to modify the code to add/remove tool calls then check out the course so you can remove the intimidation around coding and see how transformative it can be for your RevOps career.

To make setup as easy as possible I recommend installing an IDE like Cursor or Pycharm and paying for the feature to get an AI assistant embedded in the IDE that has access to the project files, can modify code on your behalf, and make terminal commands on your behalf. If you do not want to pay for the embedded AI assistant then you can work with an external LLM like OpenAI or Claude and give them the GitHub repo link and ask them to guide you through setup, testing, and modification.

Once you have your IDE setup then follow (or ask your LLM assistant to follow) the instructions in the README.md file:

  1. Clone the GitHub repository: https://github.com/tyron-pretorius/marketo-mcp.git
  2. Create a virtual environment and install the libraries from the requirements.txt file
  3. Fill out your Marketo client id, client secret, and base url in the .env file
  4. Run the mcp_server.py or mcp_server_auth.py scripts

The only difference between the mcp_server.py and mcp_server_auth.py scripts is that the mcp_server_auth.py script will require a token in order to connect with it. This helps ensure that if the URL for your Marketo MCP server became exposed bad actors would not be able to use your Marketo MCP because they wouldn’t have access to the token.

When we run the Marketo MCP server from our IDE it is running locally on one of the ports on our computer e.g. port 8000 –> http://0.0.0.0:8000/mcp, and it is not accessible to the public internet. Later on once we have thoroughly tested our Marketo MCP tool calls and functions, we will go through deploying this project to Replit so that we get a URL on the public internet https://marketo-mcp.replit.app/mcp that we can give to platforms like OpenAI and Claude to use our Marketo MCP tools.

In the meantime, we are going to use a tool call Ngrok which can expose a port on our computer to the public internet. Once you install ngrok and you have the mcp_server.py script running in one terminal all you have to do is open a new terminal and write ngrok http 8000 to expose the local port 8000 to the public internet.

It’s as simple at that to get your Marketo MCP server running and accessible to tools like OpenAI and Claude. Now check out the “Use Cases” section below if you want to start using it right away or check out the next section to see how to thoroughly test all the Marketo MCP tools and functions.

Flow diagram showing how Ngrok is used to expose the Marketo MCP server running on a local port to the internet
Exposing Marketo MCP server to the internet using Ngrok

The testing of our Marketo MCP server will be broken down into two parts:

  1. We will first test out all our Marketo functions using the test_marketo_functions.py script to make sure we can authenticate correctly and make API requests successfully
  2. Once we know the Marketo functions are working we are then going to run either the mcp_server.py or mcp_server_auth.py script in one terminal and then run the test_mcp_server.py script in another terminal, which will call each tool from the mcp server to make sure that the translation from MCP tool call to Marketo function call works successfully

When you run either of the test scripts you will be given the option of doing either a read, write, or full test:

  • Read-only tests â€” Safe, no modifications to your Marketo instance.
  • Write-only tests â€” Creates, updates, and clones test assets. Prompts for confirmation before destructive operations. Offers cleanup at the end to delete assets created during testing.
  • Full tests â€” Runs read-only tests followed by write tests.

Before we begin testing we need to create the following test assets which are safe for our test scripts to modify and clone:

  • “MCP Test Folder” folder to house all of the assets
  • “MCP Test Email Program” program to house our smart campaigns and email
  • “MCP Test Email” email
  • “MCP Test Batch Campaign” smart campaign
  • “MCP Test Trigger Campaign” smart campaign
  • “MCP Test Request Campaign” smart campaign
Screenshot of the Marketo folder hierarchy with the test program, email, and smart campaign assets
Marketo MCP test assets

The read test is completely safe to run. It merely browses emails, campaigns, programs, folders, and looks up a lead. There are no modifications made to your Marketo instance. During the course of running the read test you will be prompted to provide a lead email address to lookup the lead and their activity history.

Screenshot of the terminal when running the Marketo functions test script showing the available test options
Running the test_marketo_functions.py script
Screenshot of the read test showing the gathering of a test email address and the printing of the read test results
Read test information gathering and results

The write tests will:

  • Create, update, and clone assets
  • Approve and unapprove an email program
  • Activate and deactivate a smart campaign
  • Schedule a batch campaign
  • Request a trigger campaign on your test lead

You will first be prompted to enter the names of all the test assets that you created. The script then searches for the names of these assets so it can get their id for use in the subsequent tests. These ids are stored in the test_config.json file so that the next time you run the write or full test it will have all the test values saved so it won’t prompt you for any of these again.

If you want to change any of the test values then you can modify the JSON file directly or delete the file and then you will be prompted to enter all the asset names again the next time you run the test.

Screenshot of the terminal showing the gathering of information needed to carry out the write tests
Write test information gathering
Screenshot of the JSON file used to store the information of all the test assets
Storage of testing information
Screenshot of the terminal showing requests for permission to carry out certain actions
Write test requests for permission

Once all of the write tests have been completed you will then be able to see all of the assets that were created during the test. Conveniently, the script has a built-in cleanup mechanism that will ask you if you want all of the assets created during the test to be deleted.

Screenshot within Marketo showing the assets created during testing
Marketo assets created during write test
Screenshot of the terminal showing the deletion of Marketo assets created during testing
Cleanup of assets created during testing

The Marketo API docs have hundreds of API requests that can be made for leads or assets, the 40+ in this template are just a starting point.

If there is an action you want your AI agent to carry out and you are wondering if a tool call can be added to the MCP, the first place to check is the Marketo API docs or give a link to these docs to an LLM and explain the desired action you want to carry out and ask it if there is an API request corresponding to this action.

For example, let’s say you want your AI agent to be able to merge leads. A search of the docs will lead to this page: https://developer.adobe.com/marketo-apis/api/mapi#operation/mergeLeadsUsingPOST. You can then give this page to your AI coding partner and ask it to create a new tool. Once the new function has been added to marketo_functions.py and the new tool added to mcp_server.py then you can call the test scripts again to make sure that the new function and tool call are working correctly.

Screenshot of the Marketo API docs showing the configuration for the merge leads request
Marketo API docs for merging leads
Screenshot of a terminal showing Claude Code boot message and the user's prompt to add a new tool
Asking Claude Code to add a new tool
Screenshot of the Cursor IDE showing the change made by Claude code to add a new Marketo function
Claude code adding the new Marketo function
Screenshot of the Cursor IDE showing the change made by Claude code to add a new tool to the Marketo MCP server
Claude code adding the new Marketo MCP tool

You can use Ngrok to expose the Marketo MCP server running locally on your laptop to the internet and start using it in platforms like OpenAI and Anthropic. This is fine if you are just using the Marketo MCP as a connector in Claude desktop for example, however this approach is not suitable for building autonomous revenue operations workflows and giving AI agents access to Marketo because:

  • If your laptop gets turned off then the MCP server running locally on your laptop dies
  • If your laptop loses connection to the internet then no AI agent will be able to access the Marketo MCP
  • If you have the free version of Ngrok then each time you restart Ngrok you will be given a different forwarding URL which you will have to update in all the places you are referencing your Marketo MCP

Therefore, once you have tested the Marketo MCP using the test scripts and you are ready to start using it in revenue operations workflows and AI agents then you need to host this code online. My recommend platform for hosting is Replit because:

  • It connects to GitHub so it is easy to import GitHub repositories and then pull in future changes from GitHub
  • Deploying code is as easy as clicking a few buttons

I have created this Replit template for you to clone and get started. All you have to do is

  1. Enter your Marketo API credentials in the Replit secrets
    • If you intend on using the mcp_server_auth.py then you will also need to set MCP_API_KEY in the secrets
  2. Set the run command to either “python3 mcp_server.py” or “python3 mcp_server_auth.py”
  3. Hit deploy

If you need help going from your laptop to GitHub to Replit or need help deploying within Replit and choosing between the different deployment options e.g. Autoscale versus Reserved VM, then check out lesson 5 of the Python for RevOps course.

Screenshot showing the Marketo MCP replit app that people can clone
Marketo MCP Replit Template

Once you have successfully tested the Marketo MCP and functions it is time to explore what you can achieve when you give AI intelligence access to your Marketo instance.

In Lesson 5 of the AI for RevOps course, I show you how to build an MQL triaging agent that will empower your sales team to:

  • Know why a lead MQL’d by looking at their activity history
  • Assign the lead to their name in Salesforce
  • Draft and send emails to the lead using the Gmail API

As shown in the diagram below, this MQL triaging agent is built by using a “Slack listener” to forward messages from a Slack user to our AI brain and vice versa. The AI brain then decides whether it needs to use any of its Marketo, Salesforce, or Gmail tools or if it instead needs to communicate with the user in Slack to gather more information, return results, or seek approval for carrying out actions.

Screenshot of a Slack thread showing a human asking why a Marketo lead MQL'd and the AI agent responding with the lead's activity history
MQL triaging agent in Slack
Flow diagram showing how the requests from a user in Slack are forwarded by a listener server to an AI brain that has access to an MCP server connecting to Marketo, Salesforce, and Gmail
MQL triaging agent diagram

Here I will use the example of Claude desktop but you should be able to connect your Marketo MCP to the chat interface of many of the popular AI providers e.g. OpenAI, Grok.

  1. Click on your name at the bottom left hand corner of your Claude desktop window
  2. Click Settings > Connectors > Add custom connector
  3. Enter the name of your Marketo MCP
  4. Enter the URL of your Marketo MCP (either the Ngrok forwarding URL or your hosted/Replit URL)
    • Make sure you are using the mcp_server.py when connecting to Claude desktop because the authentication required for mcp_server_auth.py cannot be provided by Claude
  5. Click Add
  6. Click Configure besides the Marketo MCP connector
  7. You can then choose between
    • “Always allow” to allow Claude to make any tool request without permission
    • “Needs approval” to make Claude always ask for approval before calling any tool
    • “Blocked” will prevent Claude from making any tool call
    • “Custom” will allow you to configure each tool call individually to either “Always allow”, “Needs approval”, or “Blocked” e.g. read calls can be “Always allow” and write calls can be “Needs approval”

Combining your Marketo MCP with the intelligence of the Claude LLM and it’s ability to remember feedback will allow you to build your own self-improving personal Marketo assistant to help with campaign operations, lead management, and data extraction & analysis.

N.B. Go to Settings > Capabilities and toogle “Generate memory from chat history” to allow Claude to remember feedback you give it so it can become a better Marketo assistant over time.

To get the gears turning about what you can use Claude for here is a campaign operations example:

  1. Talk to Claude about how webinar and email programs are setup at your company e.g. what template program to clone etc
  2. Tell Claude to save this information
  3. Give Claude a webinar or email program brief in the form of a doc and ask it to build the webinar/email program for you
  4. Sit back and be amazed
Screenshot of Claude desktop showing how to access the settings by clicking on your name in the bottom left hand corner
Accessing Claude settings
Screenshot of Claude desktop showing the connectors section within settings
Navigating to Connectors
Screenshot of Claude desktop showing how to add a Marketo MCP server as a custom connector
Adding a custom connector
Screenshot of Claude desktop showing how to configure the permissions of each Marketo MCP tool
Tool call configuration
Screenshot of Claude desktop showing how to enable the Marketo MCP connector in the chat interface
Enabling the Marketo MCP connector
Screenshot of Claude desktop showing an example of using the Marketo MCP connector with the prompt "Please find the most recent activities for pretorit@tcd.ie"
Using a Marketo MCP tool
Screenshot of Claude desktop showing the results returned by the Marketo MCP tool when Claude was prompted for recent activity about a lead
Marketo MCP tool results

MQL scoring? Lead Routing? Duplicate Merging?

The world is your oyster now 🚀

Follow these steps to create an agent in the OpenAI playground:

  1. Click the “+ Create” button to create a new chat prompt
  2. Click “+ Add” in the “Tools” section
  3. Click “MCP server”
  4. Click “+ Server”
  5. Enter the URL of your Marketo MCP (either the Ngrok forwarding URL or your hosted/Replit URL)
  6. Enter the name of your Marketo MCP and an optional description
  7. Select “None” under the “Authentication” section if using mcp_server.py or select “Access token / API key” if using mcp_server_auth.py and provide the MCP_API_KEY that you have set in the .env file or Replit secrets
  8. Under the “Approval” section select either:
    • “Always” so that the agent always asks for permission before calling any tool
    • “Never” so that the agent will call any tool without seeking permission
    • “Configured” so that you can specify for each tool individually whether it requires approval e.g. write tools, or whether it can be called without permission e.g. read tools.

Once you have set your agent up with access to your Marketo MCP server you can then work on the system prompt and other tools you need so that you can build agents for your RevOps workflows. If you need some inspiration then check out the Marketo Lead Scoring Bible and the Automated Marketo Merging in Zapier post and think of ways to improve these workflows by bringing in AI intelligence.

Screenshot of the OpenAI playground showing the chat prompt interface
Building an agent in OpenAI playground
Screenshot of the OpenAI playground showing how to add an MCP server
Adding an MCP server
Screenshot of the OpenAI playground showing how to connect to the Marketo MCP server
Connecting to Marketo MCP server
Screenshot of the OpenAI playground showing how to configure Marketo MCP tool permissions
Configuring tool permissions

Now that you have your Marketo MCP server up and running you should check out the AI for RevOps crash course to see how to set up that Slack MQL agent and how to build agents for data categorization, ICP scoring, and sales qualification.