M365 Attachment Reader MCP
A remote MCP server for Claude that reads Outlook emails and deeply parses email attachments through the Microsoft Graph API.
Supported attachment handling now includes PDF, scanned PDF with OCR, Word, PowerPoint, Excel, CSV, plain text, images, archives, and Outlook .msg files.
Status: Early Windows-based testing version. Functional for personal use and private workflows, but not yet a production multi-user service.
Why This Exists
Claude's built-in Microsoft 365 connector can list emails, read message bodies, and check calendars. But it cannot read the actual content inside email attachments.
That means when you say "What does the PDF in my latest email say?", Claude can see the attachment metadata, but not the text, tables, images, or nested documents inside it.
This project fills that gap.
What It Does
This server sits between Claude and Microsoft 365 as a remote HTTP MCP endpoint. It:
- Authenticates with Microsoft 365 via device code flow
- Lists Outlook emails and their attachments through Microsoft Graph
- Downloads attachments on the backend
- Parses file contents and returns structured text and image blocks directly to Claude
Supported Formats
| Format | What Gets Extracted |
|---|---|
| Full text content | |
| Scanned PDF | OCR text, plus optional rendered page images |
| DOCX | Text and embedded images |
| DOC | Text content |
| PPTX / PPTM / PPSX / POTX | Slide text, notes, and embedded images |
| PPT | Best-effort legacy text extraction |
| XLSX / XLS / CSV | All sheets converted to CSV |
| JPG / JPEG / PNG / GIF / WEBP / BMP / TIFF | Returned as MCP image blocks for visual analysis |
| ZIP / RAR / 7Z | Archive contents recursively parsed file by file |
| MSG | Subject, sender, body, and embedded attachments |
| TXT / MD / JSON / XML / HTML | Raw text |
Outlook itemAttachment | Text content |
The image handling is a key differentiator: the server can return standalone image attachments as MCP image blocks, extract embedded images from DOCX and PPTX files, and fall back to OCR for scanned PDFs when no text layer exists.
MCP Tools
| Tool | Description |
|---|---|
health_check | Check if the server is alive |
begin_auth | Start device code login flow |
auth_status | Check authentication status |
list_recent_messages | List recent Outlook emails |
list_email_attachments | List attachments for a specific email |
read_email_attachment | Download, parse, and return attachment content |
These short tool names are aliases for the underlying m365_* tools registered by the server.
Real-World Use Cases
Retail / Sales Operations
"Pull the last 5 Daily Dashboard emails, read the Excel attachments, and analyze the sales trend across all store locations over the past week."
Finance / Accounting
"Find the latest email from our vendor with 'Invoice' in the subject, read the PDF attachment, and extract the total amount, due date, and line items."
Legal / Contract Review
"Open the most recent email from legal@partner.com, read the Word or PowerPoint attachment, and summarize the key terms."
Executive Reporting
"Read the weekly board report attachment from the latest CFO email and summarize the charts and key metrics."
HR / Recruiting
"Find emails from recruiting@company.com with attachments, read each resume PDF, and create a comparison table of candidates."
Supply Chain / Procurement
"Read the latest supplier quote archive, extract the spreadsheets inside it, and compare unit prices against the previous quote."
Architecture
Claude Chat -> Cloudflare Tunnel -> Local Express Server -> Microsoft Graph API
(public URL) (localhost:8080) (Outlook data)
|
Parse attachments
(pdf-parse, tesseract.js,
mammoth, xlsx, adm-zip,
msgreader, archive tools)
For local testing, Cloudflare Quick Tunnel exposes the local server to the internet. Claude connects via a Custom Connector pointed at the tunnel URL.
Prerequisites
- Windows 10/11 with PowerShell
- Node.js
- A Microsoft 365 / Outlook account
- A Claude account with Custom Connector support
Setup
1. Create a Microsoft Entra App Registration
Go to Microsoft Entra admin center -> App registrations -> New registration.
- Name:
m365-mcp-remote - Supported account types: Accounts in any organizational directory and personal Microsoft accounts
Then:
- Copy the Application (client) ID and Directory (tenant) ID from the Overview page
- Go to Authentication -> Enable Allow public client flows -> Save
- Go to API permissions -> Add a permission -> Microsoft Graph -> Delegated permissions -> Add
User.ReadandMail.Read-> Grant admin consent
2. Clone and Install
git clone https://github.com/Zacccck/MCP.git
cd MCP
npm install
3. Configure Environment
cp .env.example .env
Edit .env and fill in your Application client ID:
M365_CLIENT_ID=your-application-client-id-here
M365_TENANT_ID=common
4. Start the Server
npm start
You should see:
Custom M365 HTTP MCP server listening at http://127.0.0.1:8080/mcp
5. Expose via Cloudflare Tunnel
In a new PowerShell window:
winget install --id Cloudflare.cloudflared
Then run:
cloudflared tunnel --url http://127.0.0.1:8080
Copy the generated https://xxxxx.trycloudflare.com URL.
6. Add to Claude as a Custom Connector
In Claude Chat:
- Click the
+button near the input area - Open Connectors -> Add connector -> Custom Connector
- Enter URL:
https://xxxxx.trycloudflare.com/mcp
Use https:// and include /mcp at the end. Do not use http://127.0.0.1:8080/mcp.
7. Authenticate
In Claude, say:
Please call begin_auth
Claude will return a login URL and a device code. Open the URL, enter the code, and complete the Microsoft login. Then verify with:
Please call auth_status
8. Use It
Show me my recent outlook emails with attachments
Summarize the contents of the attachments from the email
Important Limitations
- Single-user: Auth state is stored in memory. One server instance equals one Microsoft account.
- Two processes required: Both
node server.mjsandcloudflared tunnelmust stay running during use. - Quick Tunnel is for testing only: The Cloudflare URL changes every time you restart
cloudflared. - Manual setup required: Azure app registration,
.envconfiguration, and connector setup are still manual.
Troubleshooting
| Problem | Solution |
|---|---|
| Claude cannot find MCP tools | Check that both the Node server and Cloudflare tunnel are still running. The tunnel URL may have changed after restart. |
invalid_grant error | Re-check your app registration: supported account types, allow public client flows enabled, and User.Read plus Mail.Read permissions granted. |
| Device code not showing | Make sure begin_auth was called successfully. Do not manually invent a code. |
| Want to switch accounts | Stop the Node server, restart with npm start, and use a private browser window for login. |
Project Structure
MCP/
|-- server.mjs
|-- package.json
|-- .env.example
|-- .gitignore
|-- LICENSE
`-- README.md
Roadmap
- Easier first-time setup
- Account logout and switching without restart
- Windows background service mode
- Production deployment guide
- Multi-user session architecture
- Deeper OCR language coverage and better large-file summarization
Security Notes
This is a local testing and prototype implementation. It is not production-ready for public deployment. Before deploying publicly, you would need authentication in front of /mcp, per-user session isolation, secure token storage, rate limiting, and proper infrastructure.