m365connector
v0.3.14
Published
MCP server for Microsoft 365 data via Edge CDP
Readme
m365connector
MCP server that lets AI agents search and read Microsoft 365 data through a local Edge browser profile and Chrome DevTools Protocol (CDP). No browser extension is required at runtime.
How It Works
MCP Client m365connector Microsoft Edge
(Claude Code) (this package) (user profile + CDP)
HTTP :52366 CDP :52367
───────────► ─────────────────►
Streamable HTTP Captures M365 tokens,
transport opens Office/OWA pagesThe server starts or connects to Edge with a persistent user profile. It captures Substrate tokens from M365 pages for search. Graph tokens are acquired from Graph Explorer by opening developer.microsoft.com/en-us/graph/graph-explorer and, if needed, tryit.graphexplorer.microsoft.com, then selecting a valid https://graph.microsoft.com access token rendered by the page.
Prerequisites
- Node.js 18+
- Microsoft Edge
- An M365 work or school account signed in within the configured Edge profile
Quick Start
npx m365connectorYou should see:
[m365connector] MCP HTTP listening on http://127.0.0.1:52366/mcpThen add to your MCP client config:
{
"mcpServers": {
"m365-connector": {
"type": "http",
"url": "http://127.0.0.1:52366/mcp"
}
}
}Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| M365C_MCP_PORT | 52366 | HTTP port for MCP clients |
| M365C_EDGE_DEBUG_PORT | 52367 | Edge CDP port |
| M365C_EDGE_PATH | auto-detected | Microsoft Edge executable path |
| M365C_EDGE_USER_DATA_DIR | phantomwright ud-m365 profile when present, else ~/.m365connector/edge-profile | Persistent Edge user data directory |
| M365C_EDGE_PROFILE_DIRECTORY | Default | Edge profile directory inside the user data dir |
| M365C_ALLOW_BROWSER_FOCUS | unset | Set to 1 to allow MCP-driven Edge tabs to come to the foreground for any active-tab request. By default Edge stays in the background unless Microsoft 365 requires user login, MFA, or consent. |
| M365C_NEVER_FOCUS_BROWSER | unset | Set to 1 to prevent MCP-driven Edge tabs from ever coming to the foreground. When user interaction is required, the operation will wait/fail instead of stealing focus. |
| M365C_TOKEN_REFRESH_WINDOW_SECONDS | 600 | Tool calls refresh Substrate and Graph tokens before execution when either token has less than this many seconds remaining. |
| M365C_WORK_ACCOUNT_HINT | unset | Optional comma-separated substring(s), e.g. @contoso.com, used to choose and validate the work/school account. Tokens from personal Microsoft accounts are rejected by default. |
| M365C_ALLOW_PERSONAL_ACCOUNT | unset | Set to 1 to allow personal Microsoft accounts. Not recommended for work connectors. |
| M365C_TOKEN_CACHE_PATH | ~/.m365connector/token-cache.json | Local token cache path; stores only current unexpired captured tokens |
Tools
search: Search emails, files, Teams chats, calendar events, and external connectors through Substrate.open: Read a search result. Office files and protected email can fall back to Edge-driven Office Online or OWA extraction.whoami: Read current user profile from Microsoft Graph.find_people: Find directory users with Graph filters.count_people: Count directory users with Graph filters.token_status: Inspect cached Substrate and Graph token state without forcing refresh.refresh_tokens: Force-refresh Substrate and Graph tokens by restarting the configured Edge profile, then capturing tokens from new browser tabs.
Security
- The MCP server binds to
127.0.0.1. - The Edge CDP port is local-only and uses the configured local user profile.
- Read handles are server-issued opaque UUIDs with 30-minute TTL.
- Access tokens are kept in server memory, cached locally with
0600permissions, and are not printed.
