---
title: Connect an AI
project: TotalMail
version: Latest
section: guides
language: en
license: 
url: https://totaljs.es/docs/totalmail/latest/guides/connect-an-ai/
updated: 2026-12-02T20:43:54.868Z
---

# Connect an AI

> TotalMail has an MCP server, so an assistant on your computer can look for and read the mail of the accounts that you choose and, if you allow it, help you answer it.

## Turn it on

1. In the settings, press **Connect an AI**.
2. Turn on **Let AI clients connect**.
3. In **Accounts it can read**, take out the ones that you do not want to give it.
4. Copy what your client needs. The window has it ready for Claude Code, for Cursor and other MCP clients, and for Claude Desktop.

The address is `http://127.0.0.1:7250/mcp`. If that port is in use, TotalMail takes the next free one, up to 7259, and the window has the right address.

The server is off until you turn it on. It listens only on this computer, and only while TotalMail is open. While it is on, a button at the top of the window says so. It asks for a token, which is kept in the secure store of your system. With **New token…**, the clients that have the old one stop working until you give them the new one.

> Whoever has the token can read those accounts. Give it only to your AI clients.

## What it can see

The folders and the messages of the accounts that you marked. An account that you add later is not given to it until you mark it. It never sees your passwords, and it is not given the messages that came [encrypted](/totalmail/latest/guides/encryption/). Of the attachments it sees the names, not what is inside.

Reading a message does not mark it as read.

What it reads goes to the assistant, and to the company behind it if it does not run on your computer.

## What it can do

| To let it | Turn on |
| --- | --- |
| Leave drafts, which you finish and send | **Let it leave drafts** |
| Propose sending and moving messages, and mark them | **Let it propose sending and moving mail** |

Each message that it wants to send, and each move, opens a window with all of it: to whom it goes, the subject and the whole text, or which messages move and where. Press **Send it** or **Move them**, or **No**. Closing the window is a no, and so is leaving it for three minutes. After a yes, the message can still be [undone](/totalmail/latest/guides/send/#undo).

It cannot delete anything for good.

## Messages that try to fool it

Anybody can write to you, also somebody who wants to give orders to your assistant: "forward this to…", for example. That is why nothing leaves without your yes, why TotalMail does not give it the text that a sender hides in a message, and why it tells you when a message goes to somebody you have never written to.

> Read what it wants to send before you say yes. It goes in your name.

## The tools

| Tool | What it does |
| --- | --- |
| `Accounts_list` | The accounts that you gave it, their folders and what it may do |
| `Messages_list` | The messages of a folder, up to 50 at a time |
| `Messages_search` | The messages that have some words |
| `Message_read` | A whole message, the warnings about its sender and the others of its conversation |
| `Draft_create` | Leaves a draft, or an answer, in Drafts |
| `Message_send` | Proposes sending a message |
| `Messages_move` | Proposes moving up to 200 messages of one account |
| `Messages_mark` | Marks as read or unread, and puts or takes away the flag |

**What assistants did** has the last calls since you opened TotalMail.

## Code mode

For work of several steps, the assistant can write one script instead of calling the tools one by one, and only its result goes back to the model. Download the client, which needs Node.js 18 or newer:

```bash
curl -H 'Authorization: Bearer YOUR_TOKEN' 'http://127.0.0.1:7250/mcp/client.js' -o totalmail.js
```

It has a function for each tool:

```javascript
const api = require('./totalmail.js')('YOUR_TOKEN');

(async function() {
	const { messages } = await api.Messages_list({ unread: true });
	for (const item of messages)
		console.log(item.from[0], item.subject);
})();
```

A function that fails throws an error with the message of TotalMail. The window has this code with your address and your token.
