微软MCP
适用于Microsoft Graph API的强大MCP服务器-适用于Outlook、日历、OneDrive和联系人的完整人工智能助手工具包。
特性
- 电子邮件管理:读取、发送、回复、管理附件、组织文件夹
- 日历智能:创建、更新、检查可用性、回复邀请
- OneDrive文件:上传、下载、分页浏览
- 联系人:从通讯簿中搜索并列出联系人
- 多账户:支持多个Microsoft帐户(个人、工作、学校)
- 统一搜索:在电子邮件、文件、事件和人员中搜索
Claude Desktop快速入门
# Add Microsoft MCP server (replace with your Azure app ID)
claude mcp add microsoft-mcp -e MICROSOFT_MCP_CLIENT_ID=your-app-id-here -- uvx --from git+https://github.com/elyxlz/microsoft-mcp.git microsoft-mcp
# Start Claude Desktop
claude使用示例
# Email examples
> read my latest emails with full content
> reply to the email from John saying "I'll review this today"
> send an email with attachment to alice@example.com
# Calendar examples
> show my calendar for next week
> check if I'm free tomorrow at 2pm
> create a meeting with Bob next Monday at 10am
# File examples
> list files in my OneDrive
> upload this report to OneDrive
> search for "project proposal" across all my files
# Multi-account
> list all my Microsoft accounts
> send email from my work account可用工具
电子邮件工具
list_emails-列出包含可选正文内容的电子邮件get_email-获取带有附件的特定电子邮件create_email_draft-创建支持附件的电子邮件草稿send_email-立即发送带有CC/BCC和附件的电子邮件reply_to_email-回复维护线程上下文reply_all_email-回复帖子中的所有收件人update_email-将电子邮件标记为已读/未读move_email-在文件夹之间移动电子邮件delete_email-删除电子邮件get_attachment-获取电子邮件附件内容search_emails-按查询搜索电子邮件
日历工具
list_events-列出日历事件及其详细信息get_event-获取特定事件详细信息create_event-创建包含地点和与会者的活动update_event-重新安排或修改活动delete_event-取消活动respond_event-接受/拒绝/初步回应邀请check_availability-检查空闲/繁忙时间以进行日程安排search_events-搜索日历事件
联系工具
list_contacts-列出所有联系人get_contact-获取具体联系方式create_contact-创建新联系人update_contact-更新联系信息delete_contact-删除联系人search_contacts-按查询搜索联系人
文件工具
list_files-浏览OneDrive文件和文件夹get_file-下载文件内容create_file-将文件上传到OneDriveupdate_file-更新现有文件内容delete_file-删除文件或文件夹search_files-在OneDrive中搜索文件
实用工具
unified_search-在电子邮件、事件和文件中搜索list_accounts-显示经过身份验证的Microsoft帐户authenticate_account-启动新Microsoft帐户的身份验证complete_authentication-输入设备代码后完成身份验证过程
手动设置
1.Azure应用程序注册
- 首选 Azure门户 → 微软Entra ID→ 应用程序注册
- 新注册→ Name:
microsoft-mcp - 支持的帐户类型:个人+工作/学校
- 认证→ 允许公共客户端流:是
- API权限→ 添加这些委派权限:
- 邮件。读写 - 日历。读写 - 文件夹。读写 - 联络。阅读 - 人。阅读 - 用户。阅读
- 复制应用程序ID
2.安装
git clone https://github.com/elyxlz/microsoft-mcp.git
cd microsoft-mcp
uv sync3.身份验证
# Set your Azure app ID
export MICROSOFT_MCP_CLIENT_ID="your-app-id-here"
# Run authentication script
uv run authenticate.py
# Follow the prompts to authenticate your Microsoft accounts4.克劳德桌面配置
添加到您的Claude Desktop配置中:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json\ 视窗: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"microsoft": {
"command": "uvx",
"args": ["--from", "git+https://github.com/elyxlz/microsoft-mcp.git", "microsoft-mcp"],
"env": {
"MICROSOFT_MCP_CLIENT_ID": "your-app-id-here"
}
}
}
}或者为了当地发展:
{
"mcpServers": {
"microsoft": {
"command": "uv",
"args": ["--directory", "/path/to/microsoft-mcp", "run", "microsoft-mcp"],
"env": {
"MICROSOFT_MCP_CLIENT_ID": "your-app-id-here"
}
}
}
}多账户支持
所有工具都需要 account_id 参数作为第一个参数:
# List accounts to get IDs
accounts = list_accounts()
account_id = accounts[0]["account_id"]
# Use account for operations
send_email(account_id, "user@example.com", "Subject", "Body")
list_emails(account_id, limit=10, include_body=True)
create_event(account_id, "Meeting", "2024-01-15T10:00:00Z", "2024-01-15T11:00:00Z")发展
# Run tests
uv run pytest tests/ -v
# Type checking
uv run pyright
# Format code
uvx ruff format .
# Lint
uvx ruff check --fix --unsafe-fixes .示例:AI助手场景
智能电子邮件管理
# Get account ID first
accounts = list_accounts()
account_id = accounts[0]["account_id"]
# List latest emails with full content
emails = list_emails(account_id, limit=10, include_body=True)
# Reply maintaining thread
reply_to_email(account_id, email_id, "Thanks for your message. I'll review and get back to you.")
# Forward with attachments
email = get_email(email_id, account_id)
attachments = [get_attachment(email_id, att["id"], account_id) for att in email["attachments"]]
send_email(account_id, "boss@company.com", f"FW: {email['subject']}", email["body"]["content"], attachments=attachments)智能调度
# Get account ID first
accounts = list_accounts()
account_id = accounts[0]["account_id"]
# Check availability before scheduling
availability = check_availability(account_id, "2024-01-15T10:00:00Z", "2024-01-15T18:00:00Z", ["colleague@company.com"])
# Create meeting with details
create_event(
account_id,
"Project Review",
"2024-01-15T14:00:00Z",
"2024-01-15T15:00:00Z",
location="Conference Room A",
body="Quarterly review of project progress",
attendees=["colleague@company.com", "manager@company.com"]
)安全说明
- 令牌在本地缓存在
~/.microsoft_mcp_token_cache.json - 如果您启用了2FA,请使用特定于应用程序的密码
- 仅请求您的应用程序实际需要的权限
- 考虑使用专用的应用程序注册进行生产
故障排除
- 身份验证失败:检查您的CLIENT_ID是否正确
- “需要管理员批准”:使用
MICROSOFT_MCP_TENANT_ID=consumers个人账户 - 缺少权限:确保在Azure中授予所有必需的API权限
- 令牌错误:删除
~/.microsoft_mcp_token_cache.json并重新验证
许可证
麻省理工学院
