集成

OfficeClaw

试用

让 OpenClaw 代理通过 Microsoft Graph API 接入个人微软账户,读写 Outlook 邮件、日历事件和 To Do 任务。

它能做什么

OfficeClaw 是一个 Python 命令行工具,基于 Microsoft Graph API 操作个人微软账户(Outlook.com、Hotmail、Live)。它提供 mail、calendar、tasks 三组子命令:mail 覆盖邮件列表/读取/发送/搜索/归档/标记已读;calendar 覆盖日程查询/创建/更新/删除;tasks 覆盖 To Do 任务清单与任务的查询/创建/完成/重新打开。鉴权采用 device code 流程,token 缓存在 ~/.officeclaw/token_cache.json(权限 600)。任意命令加 --json 即可输出结构化结果,便于代理程序解析。发送、删除等写操作默认关闭,需通过环境变量显式开启,并可配置收件人白名单做硬性限制。

什么时候用它

  • 通过 CLI 或 JSON 读取、筛选 Outlook 邮件
  • 在个人账户上创建、修改或取消日历日程
  • 管理 Microsoft To Do 的任务清单与待办项
  • 把邮件、日历、任务串成个人账户的自动化流程

技能文档

OfficeClaw: Microsoft Graph API Integration

Connect your OpenClaw agent to personal Microsoft accounts (Outlook.com, Hotmail, Live) to manage email, calendar, and tasks through the Microsoft Graph API.

Installation

Install from PyPI:

pip install officeclaw

Or with uv:

uv pip install officeclaw

Verify installation:

officeclaw --version

Setup (One-Time)

Quick start: OfficeClaw ships with a default app registration — just run officeclaw auth login and go. No Azure setup needed.

Advanced: Want full control? Create your own Azure App Registration (free, ~5 minutes) and set OFFICECLAW_CLIENT_ID in your .env. See Microsoft's guide or follow the steps below.

1. Create an Azure App Registration

  1. Go to entra.microsoft.com → App registrations → New registration
  2. Name: officeclaw (or anything you like)
  3. Supported account types: Personal Microsoft accounts only
  4. Redirect URI: leave blank (not needed for device code flow)
  5. Click Register
  6. Copy the Application (client) ID — this is your OFFICECLAW_CLIENT_ID
  7. Go to Authentication → Advanced settings → Allow public client flowsYes → Save
  8. Go to API permissions → Add permission → Microsoft Graph → Delegated permissions. Choose based on your needs:

Read-only (safest):

  • Mail.Read, Calendars.Read, Tasks.ReadWrite*

Full access (all features including send/delete):

  • Mail.Read, Mail.ReadWrite, Mail.Send
  • Calendars.Read, Calendars.ReadWrite
  • Tasks.ReadWrite

*Tasks.ReadWrite is the minimum available scope for Microsoft To Do — there is no read-only option.

Least privilege: Only grant the permissions you actually need. If you only want to read emails and calendar, skip Mail.ReadWrite, Mail.Send, and Calendars.ReadWrite. OfficeClaw will gracefully error on commands that require missing permissions.

2. Configure Environment

Create a .env file in your skill directory:

OFFICECLAW_CLIENT_ID=your-client-id-here

# Capability gates (disabled by default for safety)
# OFFICECLAW_ENABLE_SEND=true    # Allow sending/replying/forwarding emails
# OFFICECLAW_ENABLE_DELETE=true   # Allow deleting emails, events, and tasks

# Recipient allowlist — STRONGLY RECOMMENDED when sending is enabled
# OFFICECLAW_ALLOWED_RECIPIENTS=user1@example.com,user2@example.com

No client secret needed for device code flow. Write operations (send, delete) are disabled by default — enable only what you need.

⚠️ Recipient Allowlist (v1.0.4+): If you enable sending, configure OFFICECLAW_ALLOWED_RECIPIENTS to restrict which addresses can receive email. This is especially critical for AI agent workflows — the allowlist provides a hard, code-level boundary that prevents sending to unauthorized addresses regardless of what the agent is instructed to do. Blocked attempts are logged for auditing.

3. Authenticate

officeclaw auth login

This displays a URL and code. Open the URL in a browser, enter the code, and sign in with your Microsoft account. Tokens are stored securely in ~/.officeclaw/token_cache.json (permissions 600).

When to Use This Skill

Activate this skill when the user needs to:

Email Operations

  • Read emails: "Show me my latest emails", "Find emails from john@example.com"
  • Send emails: "Send an email to...", "Reply to the last email from..."
  • Manage inbox: "Mark emails as read", "Archive old emails", "Delete emails"

Calendar Operations

  • View events: "What's on my calendar today?", "Show meetings this week"
  • Create events: "Schedule a meeting with...", "Add dentist appointment on Friday"
  • Update events: "Move the 2pm meeting to 3pm", "Cancel tomorrow's standup"

Task Management

  • List tasks: "What's on my to-do list?", "Show incomplete tasks"
  • Create tasks: "Add 'buy groceries' to my tasks", "Create a task to review report"
  • Complete tasks: "Mark 'finish proposal' as done", "Complete all shopping tasks"

Available Commands

Authentication

officeclaw auth login       # Authenticate via device code flow
officeclaw auth status      # Check authentication status
officeclaw auth logout      # Clear stored tokens

Mail Commands

officeclaw mail list --limit 10                # List recent messages
officeclaw mail list --unread                   # List unread messages only
officeclaw mail get                # Get specific message
officeclaw mail send --to user@example.com --subject "Hello" --body "Message text"
officeclaw mail send --to user@example.com --subject "Report" --body "Attached" --attachment report.pdf
officeclaw mail search --query "from:boss@example.com"
officeclaw mail archive            # Archive a message
officeclaw mail mark-read          # Mark as read
officeclaw --json mail list                    # JSON output for parsing

Calendar Commands

officeclaw calendar list --start 2026-02-01 --end 2026-02-28
officeclaw calendar create \
  --subject "Team Meeting" \
  --start "2026-02-15T10:00:00" \
  --end "2026-02-15T11:00:00" \
  --location "Conference Room"
officeclaw calendar get 
officeclaw calendar update  --subject "Updated Meeting"
officeclaw calendar delete 
officeclaw --json calendar list --start 2026-02-01 --end 2026-02-28

Task Commands

officeclaw tasks list-lists                              # List task lists
officeclaw tasks list --list-id                 # List tasks
officeclaw tasks list --list-id  --status active  # Active tasks only
officeclaw tasks create --list-id  --title "Complete report" --due-date "2026-02-20"
officeclaw tasks complete --list-id  --task-id 
officeclaw tasks reopen --list-id  --task-id 

Output Format

Use --json flag for structured JSON output:

officeclaw --json mail list

Returns:

{
  "status": "success",
  "data": [
    {
      "id": "AAMkADEzN...",
      "subject": "Meeting Notes",
      "from": {"emailAddress": {"address": "sender@example.com"}},
      "receivedDateTime": "2026-02-12T10:30:00Z",
      "isRead": false
    }
  ]
}

Error Handling

Common errors and solutions:

ErrorCauseSolution
AuthenticationErrorNot logged in or token expiredRun officeclaw auth login
AccessDeniedMissing permissionsRe-authenticate with required scopes
ResourceNotFoundInvalid IDVerify the ID exists
RateLimitErrorToo many API callsWait 60 seconds and retry

Guidelines for Agents

When using this skill:

  1. Confirm destructive actions: Ask before deleting or sending
  2. Summarize results: Don't show raw JSON, provide summaries
  3. Handle errors gracefully: Guide user through re-authentication
  4. Respect privacy: Don't log email content
  5. Use JSON mode: For programmatic parsing, use --json flag
  6. Batch operations: Process multiple items efficiently

Security & Privacy

  • Write operations disabled by default: Send, reply, forward, and delete are all blocked unless explicitly enabled via OFFICECLAW_ENABLE_SEND and OFFICECLAW_ENABLE_DELETE environment variables. This prevents accidental or unauthorised write actions.
  • Recipient allowlist (v1.0.4+): When OFFICECLAW_ALLOWED_RECIPIENTS is set, outbound email is restricted to listed addresses only. Blocked attempts are logged to email-blocked.log and an email-alert.json alert file is written for monitoring. If not set, a runtime warning is displayed on each send. Strongly recommended for any AI agent deployment.
  • No client secret required: Uses device code flow (public client) by default
  • Least-privilege permissions: You choose which Graph API scopes to grant — read-only is sufficient for most use cases. See the setup guide above.
  • Tokens stored securely: ~/.officeclaw/token_cache.json with 600 file permissions
  • No data storage: OfficeClaw passes data through, never stores email/calendar content
  • No telemetry: No usage data collected
  • Your own Azure app: Each user creates their own Azure app registration with their own client ID — no shared credentials

Troubleshooting

If the skill isn't working:

  1. Check authentication: Run officeclaw auth status
  2. Re-authenticate: Run officeclaw auth login
  3. Verify network: Ensure graph.microsoft.com is reachable
  4. Check environment: Verify OFFICECLAW_CLIENT_ID is set in .env

References

常见问题

支持哪类微软账户?
仅支持个人微软账户(Outlook.com、Hotmail、Live)。在 Azure 注册应用时,受支持账户类型需选择“仅个人 Microsoft 账户”。
不存密码如何登录?
使用 device code 流程:执行 officeclaw auth login,按提示在浏览器打开链接并输入设备码完成登录;token 保存在本机 ~/.officeclaw/token_cache.json,文件权限为 600。
发送和删除默认是开还是关?
默认关闭,需通过 OFFICECLAW_ENABLE_SEND 和 OFFICECLAW_ENABLE_DELETE 显式开启。开启发送后,可使用 OFFICECLAW_ALLOWED_RECIPIENTS 设置收件人白名单,被拦截的发送尝试会写入日志供审计。

相关技能

通过 Microsoft Graph 接入 Outlook,读取、发送、管理邮件、文件夹、日历事件和联系人,OAuth 由平台托管。

作者 byungkyu

Let your AI assistant manage your Outlook calendar for you. Just say what you need — add, change, or delete events, set up repeating meetings, or ask when you're free — and it happens on your own calendar.

Read and write the signed-in user's Microsoft 365 / Outlook.com personal calendar via Microsoft Graph. Calendar API surface only — but note: this skill shares one device-code login with the outlook-contacts and outlook-todo skills, so the shared consent also grants their Calendars/Tasks/Contacts read-write scopes (fully disclosed in the Scope table below). Use when the user wants to list today's events, look at next week, create / update / delete a single event by id, or check token status. Trigger keywords: "outlook calendar", "ms calendar", "graph calendar", "我的 outlook 日历", "微软日历".

Microsoft To Do (to-do.office.com). Use this skill for ANY Microsoft To Do request — reading, creating, updating, and deleting data. Whenever a task involves Microsoft To Do, use this skill instead of calling the API directly.

1 次安装

Read and write the signed-in user's Microsoft 365 / Outlook.com personal contacts via Microsoft Graph. No mail, no files, no directory access. Use when the user wants to list/search Outlook.com contacts, find phone numbers, or look up email addresses. Trigger keywords: "outlook contacts", "ms contacts", "graph contacts", "我的联系人", "查联系人", "outlook 联系人".

通过 CLI 或 MCP 服务器读写 Outlook 邮件、日历、联系人、任务和 OneDrive 文件。

作者 rlrghb23 次安装