ForIT Microsoft Graph
Provides direct access to Microsoft Graph API with multi-tenant account management, allowing users to interact with Microsoft 365 services across multiple tenants through a single flexible graph-request tool.
README
Microsoft Master (MM)
Unified Microsoft 365 MCP server for AI assistants. One server, two tools, all of M365.
History
This repo originally contained four separate MCP servers:
| Server | Purpose | Status |
|---|---|---|
| graph | Microsoft Graph REST API (TypeScript) | Archived |
| pnp | CLI for Microsoft 365 / SharePoint (TypeScript) | Archived |
| pwsh-manager | PowerShell session management (Python/Docker) | Archived |
| registry | Connection registry management (Python) | Archived |
In February 2026, these were consolidated into a single mm server with two tools:
mm__run— PowerShell commands via a Docker session poolmm__graph_request— Direct Microsoft Graph REST API calls via MSAL
The old servers are preserved in _archived/ for reference.
Architecture
┌─────────────────────────────────────────────────────────┐
│ AI Assistant │
└─────────────────────┬───────────────────────────────────┘
│ MCP Protocol (stdio)
▼
┌─────────────┐
│ mm/server │ Python MCP server
│ │ - graph_request (MSAL → Graph API)
│ │ - run (HTTP → session pool)
└──────┬──────┘
│ HTTP :5200
▼
┌───────────────────────┐
│ session-pool/ │ Docker container(s)
│ session_pool.py │ - PowerShell processes per module
│ │ - Native device code auth
│ Modules: │ - Session persistence
│ exo, pnp, azure, │ - Command guardrails
│ teams │ - Comprehensive logging
└───────────────────────┘
│
┌───────────┴───────────┐
│ ~/.m365-connections │ Connection registry (READ-ONLY)
│ ~/.mm-graph-tokens/ │ Graph MSAL token cache
│ ~/.m365-logs/ │ Persistent logs
│ ~/.m365-state/ │ Session state persistence
└───────────────────────┘
Quick Start
1. Start the session pool
# Unified mode — single container, all connections (recommended for dev/small servers)
cd session-pool
docker compose -p m365-session-pool -f docker-compose.unified.yml up -d
# Isolated mode — one container per connection (recommended for production/32GB+ RAM)
docker compose -p m365-session-pool -f docker-compose.isolated.yml up -d
2. Register with MCPJungle
mcpjungle register --conf mm/mcpjungle-config.json
3. Use it
# List connections
mcpjungle invoke mm run '{}'
# PowerShell (Exchange)
mcpjungle invoke mm run '{"connection":"ForIT-GA","module":"exo","command":"Get-Mailbox -ResultSize 1"}'
# Graph API
mcpjungle invoke mm graph_request '{"connection":"ForIT-GA","endpoint":"/me"}'
# Power Automate (Flow API)
mcpjungle invoke mm graph_request '{"connection":"ForIT-GA","endpoint":"/providers/Microsoft.ProcessSimple/environments","resource":"flow"}'
Auth is automatic — if a connection isn't authenticated, the tool returns a device code. No pre-auth step needed.
Connection Registry
All connections live in ~/.m365-connections.json (read-only to MCPs):
{
"connections": {
"ForIT-GA": {
"appId": "your-app-id",
"tenant": "forit.io",
"tenantId": "guid-here",
"expectedEmail": "user@domain.com",
"description": "ForIT Global Admin"
}
}
}
Every command requires a connection parameter. There are no defaults.
Tools
mm__run — PowerShell via Session Pool
Execute PowerShell commands through persistent Docker-hosted sessions.
| Parameter | Description |
|---|---|
connection |
Connection name (e.g., ForIT-GA) |
module |
exo (Exchange), pnp (SharePoint), azure, teams |
command |
PowerShell command to execute |
Omit all parameters to list available connections.
mm__graph_request — Microsoft Graph REST API
Direct HTTP requests to Microsoft Graph (or Flow API) via MSAL tokens.
| Parameter | Description |
|---|---|
connection |
Connection name |
endpoint |
API path (e.g., /me/messages) |
method |
GET, POST, PATCH, PUT, DELETE (default: GET) |
body |
Request body for POST/PATCH/PUT |
resource |
graph (default) or flow for Power Automate |
Session Pool
The session pool manages PowerShell processes with native device code authentication.
Deployment Modes
| Mode | File | Use Case | RAM |
|---|---|---|---|
| Unified | docker-compose.unified.yml |
Dev, small servers | ~1-2GB total |
| Isolated | docker-compose.isolated.yml |
Production, multi-user | ~512MB per connection |
Features
- Session persistence — Authenticated sessions survive container restarts. Session metadata saved to
~/.m365-state/, PowerShell token caches persisted via Docker volumes. Azure sessions restore from cached tokens; EXO/Teams require re-auth (in-process only). - Command guardrails — Blocks dangerous operations:
Install-Module(container integrity),New-AzRoleAssignment(access escalation), raw OAuth requests, app registration modifications. Warned but allowed:Remove-Az*, mail forwarding rules. - Azure context isolation — In unified mode,
Disable-AzContextAutosave+Select-AzContextby expectedEmail prevents cross-tenant context contamination when multiple Azure sessions share~/.Azure. - Comprehensive logging — Dual output: stdout (docker logs) + persistent files (
~/.m365-logs/). Every command's output content logged. AADSTS and auth error patterns flagged at WARNING level. - Keepalive — Background thread pings authenticated sessions every 5 minutes to prevent token expiry. Stale sessions (auth_pending > 15 min) automatically reaped.
- Metrics —
/metricsendpoint with request counts, error rates, response times, session states.
Session Pool API
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/status |
GET | All session states |
/connections |
GET | List registry connections |
/run |
POST | Execute a command |
/reset |
POST | Reset a connection's sessions |
/metrics |
GET | Performance metrics |
Host Directories
| Path | Purpose |
|---|---|
~/.m365-connections.json |
Connection registry (read-only) |
~/.m365-logs/ |
Persistent log files |
~/.m365-state/ |
Session state for restart persistence |
~/.mm-graph-tokens/ |
MSAL token cache for Graph API |
Monitoring
# Container health
docker ps --format "{{.Names}}\t{{.Status}}" | grep m365
# Live logs
docker logs -f m365-pool
# Persistent logs (survive container restarts)
tail -f ~/.m365-logs/session-pool-unified.log
# Session status
curl http://localhost:5200/status | jq
# Metrics
curl http://localhost:5200/metrics | jq
App Registration
The PnP multi-tenant app was retired September 9, 2024. You must create your own Azure AD app registration. See docs/M365-CLI-SETUP.md for instructions.
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.