# aniru18/m365_assistant architecture

> Architecture diagram of the GitHub repository aniru18/m365_assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aniru18/m365_assistant
- Repository: https://github.com/aniru18/m365_assistant

## Overview

M365 Assistant exposes Outlook and Calendar operations through an MCP server for Claude Desktop, with an optional agent that gathers Microsoft 365 context and produces a prioritized schedule. The graph preserves the README’s documented mail and calendar capabilities, although the supplied tool excerpt shows only some registrations. Agent execution and its MCP-tool dispatch are visible; unsampled integrations are not expanded beyond documented behavior.

Main entry points: [`m365_assistant/mcp/tools.py`](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/mcp/tools.py) (MCP tools), [`m365_assistant/agent/graph_builder.py`](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/agent/graph_builder.py) (LangGraph workflow), [`m365_assistant/core/graph_client.py`](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/core/graph_client.py) (Graph client), [`m365_assistant/core/auth_manager.py`](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/core/auth_manager.py) (Device-flow auth)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mcp["MCP interface"]
  node_server_entry["Server entry<br/>[main.py]"]
  node_tool_registry["MCP tools<br/>[tools.py]"]
end

subgraph group_m365["Microsoft 365 access"]
  node_mail["Mail operations<br/>[mail_service.py]"]
  node_calendar["Calendar operations"]
  node_settings["Settings<br/>[config.py]"]
  node_auth["Device-flow auth<br/>[auth_manager.py]"]
  node_graph_client["Graph client<br/>[graph_client.py]"]
end

subgraph group_agent["Optional agent"]
  node_agent_runner["Agent runner<br/>[runner.py]"]
  node_orchestrator["LangGraph workflow<br/>[graph_builder.py]"]
  node_agent_state["Agent state<br/>[state.py]"]
  node_prompts["Agent prompts<br/>[prompts.py]"]
  node_llm_clients["Groq model clients<br/>[client.py]"]
end

node_claude(("Claude Desktop"))
node_mcp_client["MCP client"]
node_graph_api["Microsoft Graph"]
node_mail_calendar[("Outlook mail and calendar")]
node_agent_user(("Planning requester"))
node_schedule["Daily schedule"]

node_claude -->|"initiates requests"| node_mcp_client
node_mcp_client -->|"connects to"| node_server_entry
node_server_entry -->|"runs server"| node_tool_registry
node_tool_registry -->|"loads settings"| node_settings
node_tool_registry -->|"creates auth"| node_auth
node_tool_registry -->|"creates client"| node_graph_client
node_tool_registry -->|"calls mail tools"| node_mail
node_tool_registry -->|"calls calendar tools"| node_calendar
node_mail -->|"requests tokens"| node_graph_client
node_mail -->|"reads and updates"| node_graph_api
node_calendar -->|"requests tokens"| node_graph_client
node_calendar -->|"lists events"| node_graph_api
node_graph_client -->|"acquires token"| node_auth
node_graph_client -->|"uses endpoint"| node_settings
node_auth -->|"uses credentials"| node_settings
node_graph_api -->|"accesses data"| node_mail_calendar
node_auth -->|"authenticates access"| node_graph_api
node_agent_user -->|"requests planning"| node_agent_runner
node_agent_runner -->|"builds workflow"| node_orchestrator
node_orchestrator -->|"creates models"| node_llm_clients
node_orchestrator -->|"uses prompts"| node_prompts
node_orchestrator -->|"uses workflow state"| node_agent_state
node_orchestrator -->|"invokes MCP tools"| node_tool_registry
node_orchestrator -->|"produces schedule"| node_schedule
node_llm_clients -.->|"calls Groq models"| node_graph_api

click node_server_entry "https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/main.py"
click node_tool_registry "https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/mcp/tools.py"
click node_mail "https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/services/mail_service.py"
click node_calendar "https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/services/calendar_service.py"
click node_settings "https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/core/config.py"
click node_auth "https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/core/auth_manager.py"
click node_graph_client "https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/core/graph_client.py"
click node_agent_runner "https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/agent/runner.py"
click node_orchestrator "https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/agent/graph_builder.py"
click node_agent_state "https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/agent/state.py"
click node_prompts "https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/agent/prompts.py"
click node_llm_clients "https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/agent/client.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server_entry,node_tool_registry,node_mcp_client toneBlue
class node_mail,node_calendar,node_settings,node_auth,node_graph_client,node_mail_calendar toneAmber
class node_agent_runner,node_orchestrator,node_agent_state,node_prompts,node_llm_clients,node_agent_user toneMint
class node_claude,node_graph_api,node_schedule toneIndigo
```

## Components

### MCP interface

- [Server entry](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/main.py): `m365_assistant/main.py`
- [MCP tools](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/mcp/tools.py): `m365_assistant/mcp/tools.py`

### Microsoft 365 access

- [Mail operations](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/services/mail_service.py): `m365_assistant/services/mail_service.py`
- [Calendar operations](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/services/calendar_service.py): `m365_assistant/services/calendar_service.py`
- [Settings](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/core/config.py): `m365_assistant/core/config.py`
- [Device-flow auth](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/core/auth_manager.py): `m365_assistant/core/auth_manager.py`
- [Graph client](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/core/graph_client.py): `m365_assistant/core/graph_client.py`

### Optional agent

- [Agent runner](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/agent/runner.py): `m365_assistant/agent/runner.py`
- [LangGraph workflow](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/agent/graph_builder.py): `m365_assistant/agent/graph_builder.py`
- [Agent state](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/agent/state.py): `m365_assistant/agent/state.py`
- [Agent prompts](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/agent/prompts.py): `m365_assistant/agent/prompts.py`
- [Groq model clients](https://github.com/aniru18/m365_assistant/blob/master/m365_assistant/agent/client.py): `m365_assistant/agent/client.py`

### Other components

- **Claude Desktop**
- **MCP client**
- **Microsoft Graph**
- **Outlook mail and calendar**
- **Planning requester**
- **Daily schedule**

## Connections

- Claude Desktop → MCP client: initiates requests (evidence: `README.md`)
- MCP client → Server entry: connects to (evidence: `README.md`)
- Server entry → MCP tools: runs server (evidence: `m365_assistant/main.py`)
- MCP tools → Settings: loads settings (evidence: `m365_assistant/mcp/tools.py`)
- MCP tools → Device-flow auth: creates auth (evidence: `m365_assistant/mcp/tools.py`)
- MCP tools → Graph client: creates client (evidence: `m365_assistant/mcp/tools.py`)
- MCP tools → Mail operations: calls mail tools (evidence: `m365_assistant/mcp/tools.py`)
- MCP tools → Calendar operations: calls calendar tools (evidence: `m365_assistant/mcp/tools.py`)
- Mail operations → Graph client: requests tokens (evidence: `m365_assistant/services/mail_service.py`)
- Mail operations → Microsoft Graph: reads and updates (evidence: `m365_assistant/services/mail_service.py`)
- Calendar operations → Graph client: requests tokens (evidence: `m365_assistant/services/calendar_service.py`)
- Calendar operations → Microsoft Graph: lists events (evidence: `m365_assistant/services/calendar_service.py`)
- Graph client → Device-flow auth: acquires token (evidence: `m365_assistant/core/graph_client.py`)
- Graph client → Settings: uses endpoint (evidence: `m365_assistant/core/graph_client.py`)
- Device-flow auth → Settings: uses credentials (evidence: `m365_assistant/core/auth_manager.py`)
- Microsoft Graph → Outlook mail and calendar: accesses data (evidence: `README.md`)
- Device-flow auth → Microsoft Graph: authenticates access (evidence: `README.md`)
- Planning requester → Agent runner: requests planning (evidence: `README.md`)
- Agent runner → LangGraph workflow: builds workflow (evidence: `m365_assistant/agent/runner.py`)
- LangGraph workflow → Groq model clients: creates models (evidence: `m365_assistant/agent/graph_builder.py`)
- LangGraph workflow → Agent prompts: uses prompts (evidence: `m365_assistant/agent/graph_builder.py`)
- LangGraph workflow → Agent state: uses workflow state (evidence: `m365_assistant/agent/graph_builder.py`)
- LangGraph workflow → MCP tools: invokes MCP tools (evidence: `m365_assistant/agent/graph_builder.py`)
- LangGraph workflow → Daily schedule: produces schedule (evidence: `m365_assistant/agent/graph_builder.py`)
- Groq model clients → Microsoft Graph: calls Groq models
