Unlocking Sitecore Send for LLMs via the MCP Server

Sitecore Send AI Logo

Introduction

As LLMs become more popular, they face two main challenges: their knowledge is restricted to what they were trained on (with a knowledge cut-off), and their ability to interact with external tools is often limited.

Model Context Protocol (MCP) Servers address these issues by providing a unified interface for LLMs to communicate with custom APIs, enabling you to supply additional context and tools to the models.

For easy integration with Sitecore Send, I've created a Sitecore Send MCP Server.

In this article, I will show the details of the Sitecore Send MCP Server and provide an example of its usage.

Sitecore Send MCP Server (My Implementation)

My implementation of the Sitecore Send MCP Server can be found here:

Currently, the following tools are available:

  • send_smtp_email - send an email using SMTP
  • get_lists - get email lists
  • get_list_members - get email list members
  • add_list_member - add a subscriber to an email list
  • remove_list_member - remove a subscriber from an email list
  • send_transactional_email - send an email using the transactional email service

Use the following JSON to add the server to any LLM client supporting MCP (GitHub Copilot, Claude, or any other client):

{
    "send-mcp": {
        "command": "npx",
        "args": [
            "send-mcp"
        ],
        "env": {
            "API_KEY": "xxxxx",
            "TRANSACTIONAL_EMAILS_CAMPAIGN_ID": "xxxxx",
            "SMTP_ENABLED": "true",
            "SMTP_FROM": "xxxxx",
            "SMTP_USER": "xxxxx",
            "SMTP_PASSWORD": "xxxxx"
        }
    }
}

Connecting to the MCP server

For the LLM client, I use 5ire (which, of course, supports MCP).

MCP currently supports two transports:

  • stdio - connect to the server using standard input and output (run the server locally)
  • Streamable HTTP - uses HTTP POST requests for client-to-server communication and optional Server-Sent Events (SSE) streams for server-to-client communication (connect to a remote server)
stdio transport

If you are using the stdio mode, you can connect to the server using the following command:

Command:

npx -y send-mcp

The actual list of environment variables can be observed here.

connect to MCP stdio option

Streamable HTTP transport

If you are using the Streamable HTTP mode, you can start the server and connect to it.

  1. Create a .env file:
    # required properties
    API_KEY=[Sitecore Send API Key]
    TRANSACTIONAL_EMAILS_CAMPAIGN_ID=[Transactional Emails Campaign ID]
    # if you want to use SMTP
    SMTP_ENABLED=true
    SMTP_FROM=[SMTP email from]
    SMTP_USER=[SMTP connection user]
    SMTP_PASSWORD=[SMTP connection password]
    
    # optional properties: these are default values, but you can overwrite them
    SMTP_HOST=smtp.mailendo.com
    SMTP_PORT=25
    API_BASE_URL=https://api.sitecoresend.io/v3
    
  2. Start the server:

    npx send-mcp http --port 3000
    
  3. Connect to the server:

URL to connect (port is specified in CLI, 3000 by default):

http://localhost:3000/mcp

connect to MCP using http option

Retrieve lists and subscribers information

query information

Sending an email

As we have the tools send_smtp_email and send_transactional_email, we can ask the LLM to generate and send an email to a particular subscriber.

Here is an example. When we ask to send an email, the LLM chooses the correct tool and executes it.

LLM invokes MCP tool to send an email

When the email is sent, we get information about it.

the message from LLM, that email is sent

The email itself looks like this:

email generated by LLM and sent using Sitecore Send MCP server

Implementation details:

  • Language: TypeScript
  • Framework used: FastMCP
  • Sitecore Send API Client in TypeScript: git or npm

Conclusion

As I just showed, with an MCP server it's possible (and easy!) to connect any LLM to your Sitecore Send instance and use it to get lists and subscriber information, send emails, and much more.

If you have any ideas how this MCP server can be improved, please let me know (email me or find me in Sitecore Slack).