The MCP Email Server is a Model Context Protocol server that enables Large Language Models (LLMs) to compose and send emails, as well as search for attachments within specified directories. It provides a simple way to add email functionality to AI assistants through standardized tools.
Install the required dependencies:
pip install pydantic python-dotenv
Create an email.json
file with SMTP server configurations:
[
{
"domain": "@gmail.com",
"server": "smtp.gmail.com",
"port": 587
},
{
"domain": "@outlook.com",
"server": "smtp.office365.com",
"port": 587
},
{
"domain": "@yahoo.com",
"server": "smtp.mail.yahoo.com",
"port": 587
}
]
Start the MCP Email Server with the following command:
python -m mcp_email_server (--dir /path/to/attachment/directory)
The --dir
parameter is optional and specifies the directory where attachments can be found.
Add the following configuration to your Claude settings:
{
"mcpServers": {
"email": {
"command": "D:\\conda\\envs\\mcp\\python.exe",
"args": [
"C:\\Users\\YourUserName\\Desktop\\servers\\src\\email\\src\\mcp_server_email",
"--dir",
"C:\\Users\\YourUserName\\Desktop"
],
"env": {
"SENDER": "[email protected]",
"PASSWORD": "your-password-or-app-password"
}
}
}
}
{
"mcpServers": {
"email": {
"command": "uv",
"args": [
"~\\servers\\src\\email\\src\\mcp_server_email",
"--dir",
"C:\\Users\\YourUserName\\Desktop"
],
"env": {
"SENDER": "[email protected]",
"PASSWORD": "your-password-or-app-password"
}
}
}
}
The server provides two main tools:
Sends emails with the following parameters:
receiver
(array of strings, required): List of recipient email addressesbody
(string, required): The main content of the emailsubject
(string, required): The subject line of the emailattachments
(array of strings or string, optional): Email attachments (filenames)Searches for files in a specified directory:
pattern
(string, required): The text pattern to search for in file names{
"receiver": ["[email protected]"],
"subject": "Test Email from MCP Server",
"body": "This is a test email sent via the MCP Email Server.",
"attachments": ["document.pdf", "image.jpg"]
}
{
"pattern": "report"
}
The server supports the following attachment file types:
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.