Claude-Read-Outlook-Attachments

Claude-Read-Outlook-Attachments

A MCP server for Claude that reads Outlook emails its attachments through the Microsoft Graph API.

Category
访问服务器

README

M365 Attachment Reader MCP Local

A local stdio MCP server for Claude Desktop that reads Outlook emails and deeply parses email attachments through the Microsoft Graph API.

Status: Functional for personal single-user local use with Claude Desktop.


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 — running entirely on your local machine over stdio, with no public endpoints or tunnels required.


What It Does

This server runs as a local MCP process started by Claude Desktop. It:

  1. Authenticates with Microsoft 365 via device code flow
  2. Lists Outlook emails and their attachments through Microsoft Graph
  3. Downloads and parses attachment contents locally
  4. Returns structured text and image blocks directly to Claude Desktop

Supported Formats

Format What Gets Extracted
PDF 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

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

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."

HR / Recruiting

"Find emails from recruiting@company.com with attachments, read each resume PDF, and create a comparison table of candidates."


Prerequisites

  • Windows 10/11, macOS, or Linux
  • Node.js 20 or later
  • Claude Desktop
  • A Microsoft 365 / Outlook account
  • A Microsoft Entra app registration (see Step 1 below)

Setup

1. Create a Microsoft Entra App Registration

Go to Microsoft Entra admin centerApp registrationsNew registration.

  • Name: anything you like, e.g. m365-mcp-local
  • Supported account types: Accounts in any organizational directory and personal Microsoft accounts

Then:

  1. Copy the Application (client) ID from the Overview page
  2. Go to Authentication → enable Allow public client flowsSave
  3. Go to API permissionsAdd a permissionMicrosoft GraphDelegated permissions → add User.Read and Mail.ReadGrant admin consent

2. Clone and Install

git clone https://github.com/Zacccck/Claude-MCP-Read-Email-Attachments.git
cd Claude-MCP-Read-Email-Attachments
npm install

3. Configure Environment Variables

Copy the example file:

cp .env.example .env

Edit .env and fill in your client ID:

M365_CLIENT_ID=your-application-client-id-here
M365_TENANT_ID=common
M365_AUTO_OPEN_BROWSER=true

Variable reference:

Variable Required Description
M365_CLIENT_ID ✅ Yes Your Entra app's Application (client) ID
M365_TENANT_ID No Default common works for most accounts
M365_AUTO_OPEN_BROWSER No Set true to auto-open Microsoft login page
M365_MCP_DATA_DIR No Custom path for auth cache; auto-detected if omitted

4. Find Your Node.js Path

You'll need the full path to node.exe (Windows) or node (macOS/Linux) in the next step.

# Windows
where.exe node

# macOS / Linux
which node

Example output: C:\Program Files\nodejs\node.exe

5. Open Claude Desktop's Config File

Locate and open the config file for your platform:

Platform Path
Windows (standard) %APPDATA%\Claude\claude_desktop_config.json
Windows (Store) %LOCALAPPDATA%\Packages\Claude_pzs8sxrjxfjjc\LocalCache\Roaming\Claude\claude_desktop_config.json
macOS ~/Library/Application Support/Claude/claude_desktop_config.json

If the file does not exist yet, create it.

6. Add the Server to Claude Desktop

Add the following entry to claude_desktop_config.json:

{
  "mcpServers": {
    "m365-attachment-reader-local": {
      "command": "C:\\Program Files\\nodejs\\node.exe",
      "args": [
        "C:\\path\\to\\Claude-MCP-Read-Email-Attachments\\server.mjs"
      ],
      "env": {
        "M365_CLIENT_ID": "your-client-id",
        "M365_TENANT_ID": "common",
        "M365_AUTO_OPEN_BROWSER": "true"
      }
    }
  }
}

Tips:

  • Use the full absolute path from Step 4 for command.
  • Replace args[0] with the actual path to server.mjs on your machine.
  • If you already have other MCP servers in the config, merge this entry into the existing mcpServers object — do not overwrite the whole file.

7. Restart Claude Desktop

Completely quit Claude Desktop and reopen it. Claude Desktop starts the MCP server automatically — you do not need to run node server.mjs manually.

8. Authenticate with Microsoft 365

In Claude Desktop, type:

Please call begin_auth

A browser window will open (or you'll receive a login URL + device code). Complete the Microsoft login flow, then verify:

Please call auth_status

You should see your Microsoft account listed as authenticated.

9. Verify It Works

Run a quick health check:

Please call health_check

Then try a real request:

Show me my recent Outlook emails with attachments
Summarize the contents of the attachments from the latest email

Suggested Claude Prompts

Please call begin_auth
Please call auth_status
Show me my recent Outlook emails with attachments
Summarize the contents of the attachments from the email
Find the latest invoice email and extract the total amount, due date, and line items from the PDF attachment

Troubleshooting

Problem Solution
Claude cannot find MCP tools Restart Claude Desktop completely. Check that command and args paths in the config are correct and absolute.
invalid_grant error Re-check your Entra app: supported account types, public client flow enabled, User.Read and Mail.Read permissions granted.
Device code not showing Make sure begin_auth was called successfully. Do not manually enter a code.
Want to switch Microsoft accounts Restart Claude Desktop and call begin_auth again in a private browser window.
Debug log location <M365_MCP_DATA_DIR>\debug.log — defaults to a subdirectory auto-created next to server.mjs.

Manual Development Run

For debugging outside Claude Desktop, start the server manually:

cd Claude-MCP-Read-Email-Attachments
node .\server.mjs

Note: Do not type into that terminal. It is a stdio MCP process and expects an MCP client on standard input/output.


Docker

A Dockerfile is included for containerized testing:

docker build -t m365-attachment-reader-mcp-local .
docker run --rm -i `
  -e M365_CLIENT_ID=your-client-id `
  -e M365_TENANT_ID=common `
  -e M365_AUTO_OPEN_BROWSER=false `
  m365-attachment-reader-mcp-local

The container still runs as a stdio server. For everyday Claude Desktop use, the direct node approach in Step 6 is simpler.


Project Structure

Claude-MCP-Read-Email-Attachments/
├── server.mjs
├── package.json
├── manifest.json
├── server.json
├── glama.json
├── Dockerfile
├── .env.example
├── .gitignore
├── LICENSE
└── README.md

Limitations

  • Single-user only — one server instance supports one Microsoft account at a time
  • Auth state is in-memory — restarting the server requires re-authenticating
  • You must create your own Entra app and supply your own client ID
  • Very large images may be downscaled or skipped to stay within Claude Desktop payload limits
  • Legacy .xls parsing is best-effort and less reliable than .xlsx
  • Not suitable for public or multi-user hosting

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选