This skill should be used when the user asks to "read my emails", "check my calendar", "get calendar events", "search emails", "list mail folders", "show unread messages", "what meetings do I have", "fetch emails from Microsoft", "access Outlook", or mentions Microsoft Graph, Office 365 email, or Outlook calendar integration.
/plugin marketplace add BLTGV/agent-skills/plugin install bltgv-api-skills@BLTGV/agent-skillsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/graph-api.mdscripts/auth.tsscripts/calendar.tsscripts/emails.tsscripts/lib/credentials.tsscripts/lib/graph-client.tsscripts/lib/types.tsAccess Microsoft 365 emails and calendar through TypeScript scripts executed via Bun. The scripts handle OAuth authentication, token management, and API requests.
This skill provides guided access to Microsoft Graph API for:
All scripts are located at ${CLAUDE_PLUGIN_ROOT}/skills/microsoft-graph/scripts/.
Before accessing emails or calendar, authenticate using the device code flow:
bun run ${CLAUDE_PLUGIN_ROOT}/skills/microsoft-graph/scripts/auth.ts
The script displays a URL and code. Open the URL in a browser, enter the code, and sign in with a Microsoft account. Credentials are stored in ~/.config/api-skills/credentials.json.
Store multiple accounts using profiles:
# Authenticate with work account
bun run auth.ts --profile work
# Authenticate with personal account
bun run auth.ts --profile personal
# List all profiles
bun run auth.ts --list
# Delete a profile
bun run auth.ts --delete --profile old-account
Credentials are stored at ~/.config/api-skills/credentials.json:
{
"microsoft-graph": {
"default": {
"accessToken": "...",
"refreshToken": "...",
"expiresAt": "2024-01-15T10:30:00.000Z",
"account": "user@example.com",
"scopes": ["Mail.Read", "Calendars.Read", "User.Read"]
}
}
}
Tokens are automatically refreshed when expired.
Use emails.ts to interact with emails:
# List inbox (default)
bun run ${CLAUDE_PLUGIN_ROOT}/skills/microsoft-graph/scripts/emails.ts list
# List from specific folder
bun run emails.ts list --folder "Sent Items"
bun run emails.ts list --folder drafts --top 5
# Use different profile
bun run emails.ts list --profile work
bun run emails.ts read --id AAMkAG...
Get the ID from the list command output.
# Search by sender
bun run emails.ts search --query "from:boss@company.com"
# Search by subject
bun run emails.ts search --query "subject:quarterly report"
# Combined search
bun run emails.ts search --query "from:hr@company.com subject:benefits"
# Search with attachments
bun run emails.ts search --query "hasAttachments:true"
bun run emails.ts folders
Shows folder names, IDs, and message counts.
Add --format json for machine-readable output:
bun run emails.ts list --format json
Use calendar.ts to view calendar events:
# Default: next 30 days
bun run ${CLAUDE_PLUGIN_ROOT}/skills/microsoft-graph/scripts/calendar.ts list
# Today's events
bun run calendar.ts today
# This week's events
bun run calendar.ts week
# Custom date range
bun run calendar.ts list --start tomorrow --end +7d
bun run calendar.ts list --start 2024-02-01 --end 2024-02-28
today, tomorrow, +7d, +1m, +1y2024-01-15bun run calendar.ts view --id AAMkAG...
Shows full details including attendees and description.
bun run calendar.ts search --query "team standup"
bun run calendar.ts search --query "1:1"
# Unread from specific sender
bun run emails.ts search --query "from:ceo@company.com isRead:false"
# Recent urgent emails
bun run emails.ts search --query "subject:urgent" --top 5
bun run calendar.ts today
# Search for meeting
bun run calendar.ts search --query "project kickoff"
# Get full details with attendees
bun run calendar.ts view --id <event-id>
# Personal inbox
bun run emails.ts list --profile personal
# Work calendar
bun run calendar.ts today --profile work
If token is expired or invalid:
Error: No valid token for profile "default". Run auth first:
bun run auth.ts --profile default
Re-run authentication to refresh credentials.
Common Graph API errors:
Different operations require different scopes:
Mail.Read or Mail.ReadBasicCalendars.ReadUser.ReadTo request specific scopes:
bun run auth.ts --scopes Mail.Read,Calendars.Read
All scripts support --help for detailed usage:
| Script | Purpose |
|---|---|
auth.ts | OAuth authentication and credential management |
emails.ts | Email list, read, search, and folder operations |
calendar.ts | Calendar view and search operations |
For detailed API reference and advanced patterns, see:
references/graph-api.md - Microsoft Graph API endpoints and parameters