Read, search, and manage emails in Microsoft Outlook through a standardized interface.
A comprehensive Model Context Protocol (MCP) server that provides secure, efficient access to Microsoft Outlook functionality through Python COM automation. This server enables AI assistants and applications to interact with Outlook emails, folders, and contacts programmatically while maintaining enterprise-grade security and performance.
The Outlook MCP Server bridges the gap between AI systems and Microsoft Outlook, providing a standardized interface for email operations. Built on the Model Context Protocol, it offers both programmatic API access and interactive CLI usage patterns.
fastmcp
: MCP server frameworkpywin32
: Windows COM automationargparse
, csv
, datetime
, logging
, typing
# Clone the repository
git clone https://github.com/marlonluo2018/outlook-mcp-server.git
cd outlook-mcp-server
# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install requirements
pip install -r requirements.txt
Add to your MCP client configuration (e.g., Claude Desktop settings.json):
{
"mcpServers": {
"outlook": {
"type": "stdio",
"command": "python",
"args": ["C:\\Project\\outlook-mcp-server\\outlook_mcp_server.py"]
}
}
}
The CLI interface is designed exclusively for human users, not LLMs:
# Start interactive session (human only)
python cli_interface.py
Note: For LLM integration, use the MCP server interface instead.
# Install development dependencies
pip install -e ".[dev]"
# Optional: Set log level
export OUTLOOK_MCP_LOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERROR
# Optional: Set cache timeout
export OUTLOOK_MCP_CACHE_TIMEOUT=300 # seconds
Located in backend/shared.py
:
Constant | Default | Description |
---|---|---|
MAX_DAYS | 30 | Maximum days to look back for emails |
MAX_EMAILS | 1000 | Maximum emails to process in one operation |
MAX_LOAD_TIME | 58 | Maximum processing time per operation (seconds) |
CONNECT_TIMEOUT | 30 | Connection timeout for Outlook |
MAX_RETRIES | 3 | Maximum retry attempts for failed operations |
Tool Call Sequence:
list_recent_emails_tool
to load recent emails into cachesearch_emails_tool
to load matching emails into cacheview_email_cache_tool
to identify specific email to work withreply_to_email_by_number_tool
(requires user confirmation)Key Points:
The CLI interface follows a strict email cache workflow:
Cache Population:
Cache Operations:
Cache Management:
# Start interactive session
python cli_interface.py
{
"tool": "get_folder_list_tool",
"parameters": {}
}
// Returns: {"content": [{"type": "text", "text": "['Inbox', 'Sent Items', 'Drafts', ...]"}]}
{
"tool": "list_recent_emails_tool",
"parameters": {
"days": 7,
"folder_name": "Inbox"
}
}
// Returns count and first page preview
{
"tool": "search_emails_tool",
"parameters": {
"search_term": "meeting notes",
"days": 14,
"folder_name": "Inbox",
"match_all": true
}
}
{
"tool": "view_email_cache_tool",
"parameters": {
"page": 1
}
}
{
"tool": "get_email_by_number_tool",
"parameters": {
"email_number": 3
}
}
// Returns full email with body and attachments
{
"tool": "reply_to_email_by_number_tool",
"parameters": {
"email_number": 5,
"reply_text": "Thank you for your message...",
"to_recipients": ["custom@example.com"],
"cc_recipients": ["boss@example.com"]
}
}
// ⚠️ Requires explicit user confirmation
{
"tool": "compose_email_tool",
"parameters": {
"recipient_email": "client@example.com",
"subject": "Project Update",
"body": "Dear team,\n\nHere's the latest update...",
"cc_email": "manager@example.com"
}
}
// ⚠️ Requires explicit user confirmation
Workflow:
Note: Batch operations require working with the email cache and are only available through interactive CLI.
Outlook COM → Session Manager → Email Parser → Cache → API Response
Operation → Try/Catch → Retry Logic → User-friendly Error → Logging
# Fork and clone
git clone https://github.com/marlonluo2018/outlook-mcp-server.git
cd outlook-mcp-server
# Install development dependencies
pip install -e ".[dev]"
### Pull Request Guidelines
1. **Tests**: Add tests for new functionality
2. **Documentation**: Update README for API changes
3. **Error Handling**: Include proper error handling
4. **Performance**: Consider impact on large email volumes
5. **Security**: Validate all user inputs
### Code Style
- **PEP 8**: Follow Python style guidelines
- **Type Hints**: Use typing module for all functions
- **Docstrings**: Google-style docstrings for all public APIs
- **Error Messages**: User-friendly error messages
## 📋 Changelog
### v1.0.0 (Current)
- **Initial Release**: Complete MCP server implementation
- **Core Features**: Email retrieval, search, composition, and batch operations
- **Security**: User confirmation for email sending
- **Performance**: Email caching and timeout handling
- **CLI**: Interactive and command-line interfaces
### Planned Features
- [ ] Attachment upload/download support
- [ ] Calendar integration
- [ ] Contact management
- [ ] Email rules/filters
- [ ] Multi-account support
- [ ] Webhook notifications
## 📄 License
MIT License - see [LICENSE](LICENSE) file for details.
## 🆘 Support
- **Issues**: [GitHub Issues](https://github.com/marlonluo2018/outlook-mcp-server/issues)
- **Discussions**: [GitHub Discussions](https://github.com/marlonluo2018/outlook-mcp-server/discussions)
- **Documentation**: This README and inline code documentation
Enables interactive LLM workflows by adding local user prompts and chat capabilities directly into the MCP loop.
Provides audio input and output capabilities for AI assistants.
Transcribe audio files using OpenAI's Speech-to-Text API.
Integrates with Mailtrap Email API.
An MCP server for interacting with the Warpcast social network.
Send Instagram DMs via your LLM
Enables AI models to prompt users for input directly within their code editor for interactive conversations.
A server for interacting with the AgentMail API for email communication. Requires an API key.
Simple MCP Server to enable a human-in-the-loop workflow in tools like Cline and Cursor.
A text-to-speech (TTS) server using the VOICEVOX engine. Requires a running VOICEVOX instance and is currently macOS only.