Learn how to quickly migrate your email templates to Knock using our MCP server.
Storing your email templates in Knock comes with many advantages. In this tutorial, we'll walk you through how to leverage Knock's MCP server with the large language model (LLM) of your choice as a low-effort solution to quickly migrate your email templates to Knock.
Prerequisites
#
Before getting started, you'll need access to the following:
A configured email provider in your Knock account. Navigate to Integrations > Channels in your dashboard to set this up if you haven't already done so.
An MCP-compatible client (such as Cursor or Claude Desktop). We recommend Cursor for working with a large collection of HTML files.
For the purposes of this tutorial, we will assume that you're familiar with prompting an agentic LLM and understand how to provide access to files as context for your prompts. If you're not sure what this means, we recommend checking out this guide on working with context from Cursor.
Your existing email template files. Your templates will be upserted to Knock as HTML, so if you're using a format like MJML or React Email, you'll want to convert them to HTML before you begin.
For more information on setting up the Knock MCP server, see the Get started section of the MCP documentation.
Required MCP tools
#
When working with MCP servers, it's recommended that you expose only the tools you need for your use case to your LLM. The steps in this tutorial will require access to the following tools:
documentation.*
channels.*
commits.*
emailLayouts.*
partials.*
workflows.*
users.*
Learn more about configuring these tools in your MCP-compatible client here. If you're using Cursor or Claude Desktop, you can simply copy and paste the relevant configuration below into your MCP settings, under the mcpServers key. Be sure to update the configuration with your own service token.
Background
#
While not required reading, you may want to familiarize yourself with the following Knock concepts before beginning your migration so that you can understand more about the prompts you'll be providing to your LLM and the resources that you'll be creating:
Now that you have everything you need for your migration, you're ready to get started!
Each step below contains a prompt that you can provide to your LLM. These prompts are designed to be run one at a time in order to provide the LLM with discrete tasks, thus improving the accuracy of the output.
1
Analyze your existing email templates
Before creating any resources in Knock, you'll need to analyze your existing email templates to extract layouts and shared components. Copy the prompt below and provide it to your LLM along with access to your template files. We recommend limiting your prompt to 5-10 template files at a time to avoid exceeding the context window limit.
Repeat this prompt as many times as necessary until you've analyzed all of your templates.
Prompt:
2
Create partials
Based on your analysis, you'll now create the identified partials. Copy the prompt below and provide it to your LLM along with access to the partials.md file generated in the previous step.
Prompt:
3
Create email layouts
Now you'll create the email layouts identified in your analysis. We'll do this in two parts; first we'll identify any duplicated layouts and determine which of the layouts should be used as your account's "default" layout, then we'll create all of the layouts in Knock. Provide the prompts below to your LLM one at a time, along with access to the layouts.md file generated in step 1.
Prompt:
4
Create workflows
For each email template, you'll create a workflow with an email step whose template leverages the layouts and partials noted in our analysis.
Prompt:
5
Summarize the successful migration
After creating all resources, you need to verify that the migration was successful. We'll ask our LLM to provide a summary report of the migration to ensure that nothing was missed.
Provide the prompt below to your LLM along with access to the templates.md file.
Prompt:
6
Test the migrated templates
Once you've summarized the migration and verified that you've created all of the resources identified, you can use the Knock MCP server to test the migrated templates. Make sure that you update the prompt to target the correct test user's ID.
You can use the MCP server to create a user that you'd like to send the test emails to, if you don't already have one in your development environment. You should update the example prompt to use a real email address and ID for the user so that you can view the test emails in your inbox.