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.
What is MCP?
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.


Marketo MCP Server Setup
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.

Marketo API
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.

Setting up the Marketo MCP Project
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:
- Clone the GitHub repository: https://github.com/tyron-pretorius/marketo-mcp.git
- Create a virtual environment and install the libraries from the requirements.txt file
- Fill out your Marketo client id, client secret, and base url in the .env file
- 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.
Exposing Marketo MCP Server to the Internet
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.

Testing Marketo MCP Tool Calls & Functions
The testing of our Marketo MCP server will be broken down into two parts:
- 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
- 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.
Creating Test Assets in Marketo
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

Marketo MCP Read Tests
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.


Marketo MCP Write Tests
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.



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.


Adding/Removing/Modifying Tool Calls
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.




Hosting your Marketo MCP Server
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
- 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
- Set the run command to either “python3 mcp_server.py” or “python3 mcp_server_auth.py”
- 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.

Use Cases for Marketo MCP
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.
Building an MQL Triaging Agent in Slack
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.


Connecting Marketo MCP to your favorite chat agent
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.
- Click on your name at the bottom left hand corner of your Claude desktop window
- Click Settings > Connectors > Add custom connector
- Enter the name of your Marketo MCP
- 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
- Click Add
- Click Configure besides the Marketo MCP connector
- 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:
- Talk to Claude about how webinar and email programs are setup at your company e.g. what template program to clone etc
- Tell Claude to save this information
- 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
- Sit back and be amazed







Building an Agent in OpenAI
MQL scoring? Lead Routing? Duplicate Merging?
The world is your oyster now 🚀
Follow these steps to create an agent in the OpenAI playground:
- Click the “+ Create” button to create a new chat prompt
- Click “+ Add” in the “Tools” section
- Click “MCP server”
- Click “+ Server”
- Enter the URL of your Marketo MCP (either the Ngrok forwarding URL or your hosted/Replit URL)
- Enter the name of your Marketo MCP and an optional description
- 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
- 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.




What’s Next
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.
