# Microsoft Graph MCP Server
Read-only access to Microsoft 365 suite via Model Context Protocol.
## Architecture

The diagram shows the complete system architecture including Claude Code integration, MCP server components, Azure AD authentication, Microsoft Graph API gateway, and M365 services (SharePoint, OneDrive, Outlook, Teams, Calendar).
## Features
- **SharePoint**: Search sites, list files, get content
- **OneDrive**: Browse user files, search
- **Outlook**: Search emails, read messages
- **Teams**: List teams/channels, read messages
- **Calendar**: View events, search calendar
## Setup
**đź“– For detailed setup instructions, see [SETUP.md](SETUP.md)**
### Quick Start
1. **Azure AD App Registration**: Register app with Application permissions
2. **Install**: `pip install -r requirements.txt`
3. **Configure**: Add credentials to `~/.claude.json`
4. **Test**: `msgraph.test_connection()`
### Required Azure AD Permissions
Register an Azure AD app with these **Application** permissions:
- `Sites.Read.All` - SharePoint
- `Files.Read.All` - OneDrive/SharePoint files
- `Mail.Read` - Outlook
- `ChannelMessage.Read.All` - Teams messages
- `Chat.Read.All` - Teams chats
- `Calendars.Read` - Calendar
- `User.Read.All` - User directory
- `Group.Read.All` - Teams/Groups
Grant admin consent for all permissions.
### 2. Install Dependencies
```bash
cd ~/.claude/mcp-servers/msgraph-mcp
pip install -r requirements.txt
```
### 3. Configure Claude
Add to `~/.claude.json`:
```json
{
"mcpServers": {
"msgraph-mcp": {
"type": "stdio",
"command": "python3",
"args": ["/Users/thianseongyee/.claude/mcp-servers/msgraph-mcp/server.py"],
"env": {
"AZURE_CLIENT_ID": "your-client-id",
"AZURE_TENANT_ID": "your-tenant-id",
"AZURE_CLIENT_SECRET": "your-client-secret"
}
}
}
}
```
## Usage
Access via `msgraph` module in code execution:
```python
# Test connection
result = msgraph.test_connection()
# Search SharePoint files
result = msgraph.search_files("formulation xlsx", limit=10)
# List recent emails
result = msgraph.list_recent_emails("user@company.com", limit=20)
# Get Teams channels
teams = msgraph.list_teams()
channels = msgraph.list_channels(teams['items'][0]['id'])
# View calendar
result = msgraph.list_events("user@company.com", days_ahead=7)
```
## Available Functions
### Connection
- `test_connection()` - Test API connectivity
- `list_users(query, limit)` - Search users
- `get_user(email)` - User details
### SharePoint
- `search_sites(query, limit)` - Find sites
- `list_site_contents(site_id, path)` - Browse folders
- `search_files(query, site_id, limit)` - Search files
- `get_file_content(site_id, item_id)` - Read file
- `get_file_metadata(site_id, item_id)` - File info
### OneDrive
- `list_user_files(email, path)` - Browse OneDrive
- `search_user_files(email, query, limit)` - Search files
### Outlook
- `search_emails(query, email, limit)` - Search mail
- `list_recent_emails(email, limit, folder)` - Recent mail
- `get_email(email, message_id)` - Full email
### Teams
- `list_teams(limit)` - List teams
- `list_channels(team_id)` - Team channels
- `get_channel_messages(team_id, channel_id, limit)` - Messages
- `search_channel_messages(team_id, channel_id, query)` - Search
### Calendar
- `list_events(email, days_ahead)` - Upcoming events
- `search_events(email, query, limit)` - Search calendar
- `get_event(email, event_id)` - Event details
## Security
- **Read-only**: No write permissions
- **Sandboxed**: Limited Python builtins
- **App-only auth**: No user credentials stored
- **Token managed**: Automatic refresh, never exposed