GitHub Copilot
GitHub Copilot is an AI coding assistant that works inside VS Code, JetBrains IDEs, Eclipse, Xcode, and Visual Studio. In this guide, you’ll learn how to connect it with the Mailtrap MCP server, which allows you to, amongst other things, perform the following actions:
Prerequisites
Before you start, make sure to:
Set up your sending domain (this takes approximately 5 minutes).
Install the latest Node.js version since Mailtrap MCP is implemented as a Node.js command line utility.
Update VS Code to the latest version with GitHub Copilot enabled.
Step 1. Add Mailtrap MCP config to GitHub Copilot
To add Mailtrap MCP to GitHub Copilot in VS Code, you can use the quick install link or follow these steps:
Open VS Code and navigate to Settings
Search for MCP in the settings search bar

Tick the Chat > MCP: Enabled option
Click Edit in settings.json
You can also open the settings.json file by typing Preferences: Open User Settings (JSON) in the Command Palette.
Once you open settings.json, insert the following code snippet into the file:
Step 2. Insert Mailtrap credentials
Next, all you need to do is replace the following values in the settings.json file:
MAILTRAP_API_TOKEN— Required for all functionality, used to authenticate API requests, which you can copy/paste from the credentials tab.DEFAULT_FROM_EMAIL— Required for email sending. Make sure the email’s domain matches your own domain from the Sending Domains tab in Mailtrap.
You can find these credentials in your Mailtrap account by navigating to Sending Domains → Integration → API.

MAILTRAP_ACCOUNT_ID— This is required for template management purposes. You can find the account ID under Settings → Account Settings.

MAILTRAP_TEST_INBOX_ID— If you need sandbox email functionality, you can find this ID in your Sandbox.

Once you insert your Mailtrap credentials, make sure to refresh the page or reopen VS Code.
If you don’t add one or more variables, you’ll be prompted to do it to complete a specific action, and when given the variable, Copilot will ask you to update your .env file automatically.
GitHub Copilot + Mailtrap MCP server use cases
Connect Mailtrap to your project
Regardless of the IDE you are using Copilot in, you can prompt the agent to integrate Mailtrap into your project with a prompt like this one:
Integrate Mailtrap into my project, so that it can send emails through the Mailtrap email API.
Additionally, safely store the Mailtrap credentials from the MCP configuration into an .env file
GitHub Copilot’s agent will then go through the Mailtrap documentation, integrate the email API, and safely store your credentials in a .env file. Then, you can proceed to test the configuration.

Sandbox operations during code review
While you’re reviewing your email-sending code and working in a staging environment using Sandbox, you might want to try to trigger the logic to see if it works correctly or simply to verify the behavior, test emails, etc.
You can do all of this from your IDE connected to GitHub copilot with the following prompts:
Template validation
Using a Mailtrap template ID in your code, but you’re not sure whether it’s the correct one? Just request the list of available templates in your Mailtrap account from GitHub Copilot.

Sending emails to your teammate
You can also ask your teammates’ opinion on an email design or a template you’re working in your Sandbox by prompting GitHub Copilot, no need to leave the editor.

Last updated
Was this helpful?





