Connect n8n or your own code over MCP
In n8n, add an MCP Client node, choose HTTP Streamable transport and the URL https://mcp.xgenplus.com/mcp, and use header auth with name Authorization and value Bearer <TOKEN>. In your own code, connect with any MCP SDK's Streamable HTTP client and send the same header. Give automations narrow permissions, because nobody watches each step.
How to connect an automation
- Create an agent password in Settings › Security › AI Agents (MCP) with only the permissions the automation needs, and copy its token or make your token.
- In n8n: add an MCP Client node, set the transport to HTTP Streamable and the URL to
https://mcp.xgenplus.com/mcp. - Set authentication to header auth, with name
Authorizationand valueBearer <TOKEN>, saved as an n8n credential. - In your own code: connect with the MCP SDK's Streamable HTTP client and the same header.
- Test the connection first by calling the
get_mailbox_profiletool. It needs no permission and returns your permissions.
When to use it
Rohit builds an n8n workflow that runs every evening, lists the day's unread supplier mail and posts a summary to his team. Its agent has only Login, List folders, Search email and Read email.
Python example
Set the XGENPLUS_TOKEN environment variable to your token. In n8n, the token replaces <TOKEN>.
- In XgenPlus webmail, go to Settings › Security › AI Agents (MCP) and click Create agent password.
- On Your agent is ready, copy the Token for AI apps. It is already encoded, so paste it where this guide says
<TOKEN>, afterBearerwith one space.
Chose your own password, or need to make the token again? It is your email address and agent password joined by a colon, with no spaces, in base64. Replace the sample values with yours, run the command on your own computer, and copy the line it prints.
Windows (PowerShell):[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes('you@xgenplus.com:AGENT_PASSWORD'))Mac or Linux (Terminal):printf '%s' 'you@xgenplus.com:AGENT_PASSWORD' | base64 | tr -d '\n'For example, you@xgenplus.com:AGENT_PASSWORD becomes eW91QHhnZW5wbHVzLmNvbTpBR0VOVF9QQVNTV09SRA==. Base64 is not encryption: keep the token as secret as a password. Never paste it into a chat with the AI, a shared file or a code repository, and never use online base64 encoder websites, because they would receive your agent password. If your agent password contains a single quote ('), these commands break, so create a new agent password without one. More help: Make your MCP token.
Requires the MCP Python SDK 2.x (pip install "mcp>=2").
import asyncio, os
from mcp import ClientSession
from mcp.client.streamable_http import create_mcp_http_client, streamable_http_client
async def main():
headers = {"Authorization": "Bearer " + os.environ["XGENPLUS_TOKEN"]}
async with create_mcp_http_client(headers=headers) as http:
async with streamable_http_client("https://mcp.xgenplus.com/mcp", http_client=http) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
result = await session.call_tool("get_inbox_summary", {})
print(result.content)
asyncio.run(main())
Good to know
- Mail content is untrusted. Automations act without a person watching. Never let mail content decide where mail is sent.
- Keep the token in your automation tool's credential store or an environment variable, never in code.
- Respect the limits. A
RATE_LIMITEDerror says when to retry. - Pass the same
idempotency_keywhen you retry a send, so it is not sent twice. - More for developers: MCP notes for developers.
Common questions
Can an automation send mail on its own?
Only if you turn on Send & Save for its agent password. Risky sends, such as to a first-time external recipient, are still held as drafts for review.