GitHub Copilot

GitHub Copilotarrow-up-right 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:

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 linkarrow-up-right 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

circle-info

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 DomainsIntegrationAPI.

  • MAILTRAP_ACCOUNT_ID — This is required for template management purposes. You can find the account ID under SettingsAccount 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.

circle-info

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 Sandboxarrow-up-right, 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:

chevron-right"Get all messages from my sandbox inbox"hashtag
chevron-right"Show me the first page of sandbox messages"hashtag
chevron-right"Search for messages containing 'test' in my sandbox inbox"hashtag
chevron-right"Show me the details of sandbox message with ID XYZ"hashtag

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?