2025-05-22

CloudMailin MCP - Let AI interact with your CloudMailin Email Address

CloudMailin MCP - Let AI / LLMs interact with your CloudMailin Email Address

The CloudMailin MCP is a new way to interact with your CloudMailin email address account from inside tools like Claude AI and Cursor.

I've been hearing about MCPs for a little while but never really understood the power until creating an example. In this article we'll show you just how powerful even a simple example can be and take a look at how the CloudMailin MCP works and where it might be heading.

Just a note, this is moving fast, this article is probably out of date by the time you read it but hopefully it gives a good overview.

What is an MCP?

MCPs are an interesting new development in the world of AI and Large Language Models (LLMs). MCPs give you an API to make calls from your AI LLM to an external service.

The CloudMailin MCP allows you to interact with your CloudMailin email address from your LLM. MCPs aren't really much more than a way to make an API call from within the LLM to an external service.

An example

The easiest way to understand what we can do with the MCP is to look at an example.

After setting up and installing the CloudMailin MCP we thought we'd take a look at an example email address and do some analysis. We're going to use the demo address on the CloudMailin landing page. It's not used that often but it's a good example of being able to not only pull data but make some inferences from it too.

The prompt

Can you show me a graph of the demo address over the last 7 days, obfuscate the
names and tag the ones that look like they're spam.

The result in Claude

Claude's Render of the Demo Address

Wow! Claude pulled the email's for this address, obfuscated the names and tagged the ones that look like they're spam, provided a graph and some examples of the emails. I'd say it's done a pretty good job of finding the SPAM examples too!

Cursor

With Cursor, we can also call the MCP to make code modifications or suggestions. In our case, this is less useful, but I can certainly see a future where you can just point Cursor at your error logs and the CloudMailin MCP to fix any error cases. You can also pull a range of emails that have been rejected and get Cursor to help understand why, too.

Building an MCP - How does it work?

Although MCPs are a new development most of the concepts are pretty similar to existing standards. You can even generally use LLMs to create the MCP for you.

MCPs actually use JSON RPC 2.0 under the hood. They're therefore able to use a few different transports.

The most common is stdio at the moment, meaning that you'll mostly have to run the MCP locally. However, the future looks like there may be better options for remotely hosting and authenticating MCPs. Cloudflare has a blog post titled "Build a Remote MCP Server", outlining how you can do this currently.

Exposing tools to the LLM

The definition of tools vs resources is a confusing topic. I actually got the most help from reddit (MCP Resources vs Tools). In CloudMailin we're exposing two tools to the LLM:

  1. listAddresses - List the email addresses in your CloudMailin account.
  2. listMessages - fetches the list of messages from a specific email address. We're also able to pass a query parameter to filter the messages returned.

Being able to pass a query parameter to filter the messages returned allows us to make queries such as find me all messages that failed in the last 24 hours from customer@example.com on my production address.

We also pass the address ID to the listMessages tool so that we can get the messages from the specific address. Because we expose both tools, the LLM can use the first tool to get the address ID given the production nickname and then pass that to the second tool to get the messages.

The code

We've tried to keep the code as simple as possible so that it's easy to understand and modify.

The MCP is written in Typescript and can be found on GitHub here: cloudmailin-mcp.

The core of the MCP is to import the McpServer and StdioServerTransport, and then expose the tools to wrap the standard CloudMailin API:

import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';

/// Constants, implementation of API calls etc.

server.tool(
    "listMessages",
    {
// The rest of the implementation...

We actually generated a significant amount of the code using cursor and the plan.md file.

Running the MCP

The MCP is designed to be run locally. It's a simple Typescript application that can be run using Node.js.

For up-to-date instructions, see the cloudmailin-mcp README. However, the process is as simple as configuring either Claude (claude_desktop_config.json) or Cursor (.cursor/mcp.json) to use the MCP:

{
  "mcpServers": {
    "cloudmailin": {
      "type": "stdio",
      "command": "npm",
      "args": [
        "--prefix",
        "/Users/steve/Projects/mcp/cloudmailin-mcp",
        "run",
        "dev"
      ],
      "env": {
        "CLOUDMAILIN_ACCOUNT_ID": "YOUR ACCOUNT ID",
        "CLOUDMAILIN_API_KEY": "YOUR API KEY (Sign-up for the Beta for Access)"
      }
    }
  }
}

You'll also be able to run the MCP via npx soon.

What's next?

We're really excited about the future of MCPs and where they might take us. We'll be expanding the capabilities of both our API and the MCP to allow more complex interactions.

Some MCP servers we like

For now, we'll highlight a few of the MCP servers we like:


2025-05-22
Steve Smith