@aidalinfo/m365-mcp 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +279 -37
- package/dist/audit.js +11 -1
- package/dist/auth/token-provider.js +79 -3
- package/dist/config.js +77 -7
- package/dist/confirm.js +1 -1
- package/dist/context.js +48 -2
- package/dist/errors.js +1 -1
- package/dist/external/activity.js +253 -0
- package/dist/external/client.js +140 -0
- package/dist/external/exchange.js +104 -0
- package/dist/external/sharepoint.js +79 -0
- package/dist/graph-client.js +108 -4
- package/dist/index.js +1 -1
- package/dist/permissions.js +189 -1
- package/dist/register.js +23 -1
- package/dist/reports.js +138 -0
- package/dist/review/collect.js +238 -0
- package/dist/review/model.js +152 -0
- package/dist/tools/access-review.js +98 -0
- package/dist/tools/applications.js +101 -0
- package/dist/tools/capabilities.js +53 -11
- package/dist/tools/common.js +77 -1
- package/dist/tools/devices.js +40 -0
- package/dist/tools/entra-applications-write.js +193 -0
- package/dist/tools/entra-applications.js +239 -0
- package/dist/tools/phase2.js +235 -0
- package/dist/tools/reports.js +151 -0
- package/dist/tools/security.js +275 -0
- package/dist/tools/sites.js +231 -0
- package/dist/tools/teams-write.js +2 -1
- package/dist/tools/teams.js +39 -1
- package/dist/tools/write-flow.js +25 -6
- package/package.json +10 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aidalinfo / Pulse myIT
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
# @aidalinfo/m365-mcp
|
|
2
2
|
|
|
3
3
|
MCP server for **Microsoft 365** through **Microsoft Graph v1.0**: Entra ID users and groups,
|
|
4
|
-
licences, Microsoft Teams,
|
|
4
|
+
licences, Microsoft Teams, SharePoint, usage reports, service health, admin roles, MFA,
|
|
5
|
+
applications and consents, audit logs, Conditional Access, Intune — for **helpdesk support** and a
|
|
6
|
+
**periodic access review** (one-call snapshot compared with the previous one) — with targeted,
|
|
7
|
+
audited writes.
|
|
5
8
|
|
|
6
9
|
- **`readonly`** (default): read tools only. The write identity is **not even loaded**.
|
|
7
10
|
- **`full`**: read tools **plus** targeted write tools (user attributes from an allowlist,
|
|
8
11
|
enable/disable account, licences, group members, team members, channels, team settings),
|
|
9
|
-
signed by a **separate Entra application**, per family (`M365_WRITE_FAMILIES`).
|
|
12
|
+
signed by a **separate Entra application**, per family (`M365_WRITE_FAMILIES`). The optional
|
|
13
|
+
`entra-applications` family is absent by default and uses a third dedicated identity.
|
|
10
14
|
|
|
11
|
-
There is **no raw Graph request tool** (neither read nor write)
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
There is **no raw Graph request tool** (neither read nor write) and no `beta` endpoint. Entra
|
|
16
|
+
application management is limited to allowlisted application/service-principal properties. Public
|
|
17
|
+
certificate metadata and federated identity credentials are read-only in v1. V1 has no certificate
|
|
18
|
+
or federated-credential write, deletion, client-secret creation/return, private-key handling,
|
|
19
|
+
programmatic consent, app-role-assignment or OAuth2-grant write.
|
|
14
20
|
|
|
15
21
|
```text
|
|
16
22
|
Agent Pulse / Vulcain
|
|
@@ -22,11 +28,12 @@ Agent Pulse / Vulcain
|
|
|
22
28
|
Microsoft Graph v1.0
|
|
23
29
|
│
|
|
24
30
|
├── Entra app "m365-mcp-read" (every mode — read permissions only)
|
|
25
|
-
|
|
31
|
+
├── Entra app "m365-mcp-write" (full mode only — general write permissions)
|
|
32
|
+
└── Entra app "m365-mcp-entra" (optional entra-applications family only)
|
|
26
33
|
```
|
|
27
34
|
|
|
28
35
|
Do **not** reuse Pulse Chat's Microsoft SSO application, nor the application behind personal
|
|
29
|
-
Outlook / calendar connectors:
|
|
36
|
+
Outlook / calendar connectors: these identities are dedicated to this server.
|
|
30
37
|
|
|
31
38
|
## Tools
|
|
32
39
|
|
|
@@ -44,8 +51,54 @@ Outlook / calendar connectors: the two identities above are dedicated to this se
|
|
|
44
51
|
| `m365_teams` / `m365_team_info` | Teams, and one team's settings (member, guest, messaging, fun) |
|
|
45
52
|
| `m365_team_channels` | Channels (standard / private / shared) with ids |
|
|
46
53
|
| `m365_team_members` | Members with role (owner / member / guest) and membership id |
|
|
54
|
+
| `m365_channel_members` | Members of a channel — **private and shared channels** have their own members, absent from the team's; shared channels show the external tenant |
|
|
55
|
+
| `m365_usage_reports` | Storage per mailbox / OneDrive / SharePoint site (bytes **and** GB), mailbox type (`Recipient Type`: User, **Shared**, Room…), last activity per service — filters `search`, `recipientType`, `inactiveDays`, sort by size. Concealed (anonymised) names are detected and flagged |
|
|
56
|
+
| `m365_service_health` | Service state, open incidents / advisories, message center — "is it us or Microsoft?" |
|
|
57
|
+
| `m365_sites` / `m365_site_info` | Every SharePoint site (with or without Teams); one site's libraries with size / quota and its linked Microsoft 365 group |
|
|
58
|
+
| `m365_sharing_links` | Sharing links and external grants on **one folder** (bounded walk: depth ≤ 3, ≤ 200 items) — flags anonymous links, links without expiry, external people; link URLs are never returned |
|
|
59
|
+
| `m365_directory_roles` | Who is admin of what (active assignments with principal and scope); `view=eligible` = PIM (Entra ID P2) |
|
|
60
|
+
| `m365_user_auth_methods` | MFA methods of a user (types only — never a phone number or key); without `user`, the tenant MFA registration report (Entra ID P1) |
|
|
61
|
+
| `m365_user_activity` | Last sign-in of each account, dormant accounts (`inactiveDays`) — Entra ID P1 |
|
|
62
|
+
| `m365_directory_audit` | Who changed what in the directory (users, groups, roles, licences, apps) — 7 days of history without P1, 30 with; property values never returned |
|
|
63
|
+
| `m365_applications` | Enterprise applications (third party / own), application permissions granted to one, delegated consents (`DelegatedPermissionGrant.Read.All`) |
|
|
64
|
+
| `m365_conditional_access` | Conditional Access policies (Entra ID P1) and security defaults |
|
|
65
|
+
| `m365_intune_devices` | Intune managed devices: compliance, encryption, last sync, primary user — Intune licence |
|
|
66
|
+
| `m365_access_review_snapshot` | **Access review in one call** — see below |
|
|
47
67
|
| `m365_audit_signins` | Sign-in logs — **only with `M365_ENABLE_SIGNIN_AUDIT=true`**, needs Entra ID P1/P2 |
|
|
48
68
|
|
|
69
|
+
#### Tools that need a premium licence
|
|
70
|
+
|
|
71
|
+
| Licence | Tools (or parts) | Without it |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| **Entra ID P1** (Business Premium, E3/E5, standalone) | `m365_user_activity`, `m365_user_auth_methods` tenant view, `m365_conditional_access` policies, `m365_audit_signins`; in the snapshot: last sign-in and the tenant MFA report | `unsupported_by_tenant` (the snapshot falls back to the admins' own methods for MFA and marks inactivity as *not evaluated*) |
|
|
74
|
+
| **Entra ID P2** | `m365_directory_roles view=eligible` (PIM) | `unsupported_by_tenant` |
|
|
75
|
+
| **Intune** (Business Premium, EMS) | `m365_intune_devices` | `unsupported_by_tenant` |
|
|
76
|
+
|
|
77
|
+
The tools stay registered on every tenant. `m365_capabilities` reads the tenant's service plans
|
|
78
|
+
(`AAD_PREMIUM`, `AAD_PREMIUM_P2`, `INTUNE_*`) and reports such tools as
|
|
79
|
+
`unsupported_by_tenant (needs …)` rather than as a missing permission. `m365_directory_audit` works
|
|
80
|
+
without P1, with 7 days of retention.
|
|
81
|
+
|
|
82
|
+
#### Access review — `m365_access_review_snapshot`
|
|
83
|
+
|
|
84
|
+
One call (hundreds of Graph calls, at most 4 in flight) produces the full picture of the tenant:
|
|
85
|
+
users (state, type, licences, last sign-in with P1, MFA), subscribed licences, every group and team
|
|
86
|
+
with owners and members, members of private and shared channels, admin roles, enterprise
|
|
87
|
+
applications with their application permissions and delegated consents, storage per account and
|
|
88
|
+
per site.
|
|
89
|
+
|
|
90
|
+
- **Output**: a dated JSON file `m365-review-<tenant>-<timestamp>.json` in `M365_SNAPSHOT_DIR`
|
|
91
|
+
(mode `0600`: it holds names and memberships), plus a bounded summary (`maxItems` per list).
|
|
92
|
+
- **Comparison**: `compareWith: "latest"` (or a file name from that directory — never a path) lists
|
|
93
|
+
accounts created / deleted / disabled / re-enabled, new guests, entries and exits of groups, teams
|
|
94
|
+
and private channels, new and removed owners, new and removed admins, licences reassigned, new
|
|
95
|
+
applications and newly consented permissions.
|
|
96
|
+
- **Signals**: Microsoft 365 group or team without owner, guest owner, disabled account still member or
|
|
97
|
+
licensed, account inactive for 90+ days (`inactiveDays`), shared mailbox holding a licence or able
|
|
98
|
+
to sign in, admin without MFA, guest admin.
|
|
99
|
+
- A section that cannot be read (missing permission, licence) is listed under *Sections NOT read* and
|
|
100
|
+
its signals are *not evaluated* — never reported as "none".
|
|
101
|
+
|
|
49
102
|
Every list tool takes `limit` (default 25, **server maximum 100**), an opaque `cursor` for the
|
|
50
103
|
next page, structured filters (no free-form OData; strings are escaped server-side) and
|
|
51
104
|
`format: summary | json`. Selected fields come from a server-side allowlist: credentials,
|
|
@@ -53,7 +106,11 @@ authentication methods, personal phone numbers, alternate e-mails and on-premise
|
|
|
53
106
|
never requested.
|
|
54
107
|
|
|
55
108
|
HTTP redirects are **never followed** (`redirect: "error"`, Graph and token endpoint): only
|
|
56
|
-
validated Graph URLs are called, and a 307 could otherwise replay a mutation elsewhere.
|
|
109
|
+
validated Graph URLs are called, and a 307 could otherwise replay a mutation elsewhere. Single
|
|
110
|
+
exception, GET only: usage reports answer `302` to a pre-authenticated CSV download URL. That URL
|
|
111
|
+
must be `https` on a Microsoft reports host (`*.office.com`, `*.office.net`, `*.office365.com`,
|
|
112
|
+
`*.microsoft.com`); it is fetched **without** the Graph token, with redirects refused, and never
|
|
113
|
+
returned to the caller.
|
|
57
114
|
|
|
58
115
|
Cursors are **server-side**: the caller holds a random id, never a URL, so pagination cannot be
|
|
59
116
|
pointed at another resource; every `@odata.nextLink` is checked to stay on
|
|
@@ -88,10 +145,46 @@ Each error carries Microsoft's `request-id` (quote it to Microsoft support) and
|
|
|
88
145
|
| `m365_team_channel_create` | `teams` | Standard channel | No-op if the name exists; never retried on 5xx (no duplicate) |
|
|
89
146
|
| `m365_team_channel_update` | `teams` | Rename / describe a channel | General channel cannot be renamed |
|
|
90
147
|
| `m365_team_settings_update` | `teams` | Allowlisted member / guest / messaging / fun settings | Strict schema |
|
|
148
|
+
| `m365_entra_applications` / `_application_info` | `entra-applications` | Typed application-registration inventory/details | Dedicated identity; response and nested collections bounded; certificate material reduced to public metadata |
|
|
149
|
+
| `m365_entra_service_principals` / `_service_principal_info` | `entra-applications` | Typed enterprise-application inventory/details | Dedicated identity; allowlisted fields only |
|
|
150
|
+
| `m365_entra_application_requested_permissions` / `_service_principal_effective_permissions` | `entra-applications` | Requested permissions and read-only inspection of effective app-role assignments / delegated grants | Effective delegated grants additionally require read-only `Directory.Read.All`; never grants consent or writes assignments/grants |
|
|
151
|
+
| `m365_entra_application_federated_credentials` | `entra-applications` | First 20 federated identity credentials | Application ownership is verified first; no external token or secret is read |
|
|
152
|
+
| `m365_entra_application_create` / `_update` | `entra-applications` | Idempotent application upsert by URL-safe `uniqueName`, or update allowlisted scalar properties | `requiredResourceAccess` is deliberately absent from write schemas; ownership by the dedicated identity; no delete, secret or private key |
|
|
153
|
+
| `m365_entra_service_principal_create` / `_update` | `entra-applications` | Idempotent service-principal upsert by `appId`, or update allowlisted scalar properties | Both the linked application and service principal must be owned; no role assignment or consent write |
|
|
91
154
|
|
|
92
155
|
`m365_group_create` / `m365_team_create` are **not** in v1 (they would need `Group.ReadWrite.All`
|
|
93
156
|
/ `Team.Create`); add them later behind a dedicated flag if needed.
|
|
94
157
|
|
|
158
|
+
### `entra-applications` bootstrap and ownership boundary
|
|
159
|
+
|
|
160
|
+
Create a third single-tenant app for this family and grant it exactly
|
|
161
|
+
`Application.ReadWrite.OwnedBy` and read-only `Directory.Read.All` (admin consent). Any additional
|
|
162
|
+
Graph application role is refused. Its client id must differ from the read and write
|
|
163
|
+
identities. The family is not enabled unless `entra-applications` is explicitly present in
|
|
164
|
+
`M365_WRITE_FAMILIES`, `M365_ENTRA_*` contains exactly one credential, and
|
|
165
|
+
`M365_WRITE_KILL_SWITCH_FILE` is configured.
|
|
166
|
+
|
|
167
|
+
`Application.ReadWrite.OwnedBy` does not ownership-filter tenant-wide list responses. Therefore every
|
|
168
|
+
mutation of an existing application re-reads `/owners` during preview and again immediately before
|
|
169
|
+
the Graph mutation. Application creation with `Application.ReadWrite.OwnedBy` establishes ownership for the calling service principal by Graph; the server verifies that ownership after creation without requiring a broader owner-write permission;
|
|
170
|
+
service-principal writes require both a linked, owned local application registration and ownership of
|
|
171
|
+
the service principal itself. For a newly created service principal, the server establishes the
|
|
172
|
+
dedicated identity as owner when Graph did not do so automatically, then verifies ownership.
|
|
173
|
+
Federated-credential reads also verify ownership before reading the collection.
|
|
174
|
+
The dedicated identity service principal itself must already exist in the tenant (normal after admin
|
|
175
|
+
consent); inability to resolve it uniquely stops the operation. Newly created objects can be
|
|
176
|
+
eventually consistent: post-write verification is retried only three times with bounded delays. For
|
|
177
|
+
this family verification is fail-closed: if the mutation may have succeeded but ownership or the
|
|
178
|
+
requested resulting state cannot be verified, the tool returns an error and the audit result is
|
|
179
|
+
`success_unverified`, never the misleading values `success` or `failed`.
|
|
180
|
+
|
|
181
|
+
Hard exclusions remain: no deletion tools, no client-secret creation or return, no private-key input
|
|
182
|
+
or output, no certificate or federated-credential write, no programmatic consent, no
|
|
183
|
+
`appRoleAssignment`/`oAuth2PermissionGrant` write, and no raw
|
|
184
|
+
Graph tool. `Application.ReadWrite.All`, `AppRoleAssignment.ReadWrite.All`,
|
|
185
|
+
`DelegatedPermissionGrant.ReadWrite.All` and `Directory.ReadWrite.All` are refused for the dedicated
|
|
186
|
+
identity even when `M365_ALLOW_BROAD_PERMISSIONS=true`.
|
|
187
|
+
|
|
95
188
|
#### Two-step confirmation (every write tool)
|
|
96
189
|
|
|
97
190
|
1. **Preview** — call the tool **without** `confirmToken`. Nothing is changed: the target is
|
|
@@ -110,14 +203,13 @@ nothing by itself. **Pulse Chat must still obtain an explicit, traced human appr
|
|
|
110
203
|
second call**; pass its id as `approvalId` so the audit line can be correlated (it is recorded as
|
|
111
204
|
`approvalRef: { id, verified: false }` — a free string is never treated as an authorisation).
|
|
112
205
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
`missing on read identity (preview)` otherwise.
|
|
206
|
+
General write-family reads (resolution, state before/after) use the **read** identity and mutations
|
|
207
|
+
use the write identity. The `entra-applications` family instead uses its dedicated **entra** identity
|
|
208
|
+
for both its reads and its tightly scoped writes.
|
|
117
209
|
|
|
118
210
|
#### Audit trail
|
|
119
211
|
|
|
120
|
-
Every write attempt — `preview`, `success`, `noop`, `refused`, `failed` — produces one JSON line on
|
|
212
|
+
Every write attempt — `preview`, `success`, `success_unverified`, `noop`, `refused`, `failed` — produces one JSON line on
|
|
121
213
|
**stderr** (stdout is the MCP transport) and, with `M365_AUDIT_LOG_FILE`, appended to that file
|
|
122
214
|
(mode 0600):
|
|
123
215
|
|
|
@@ -141,29 +233,53 @@ permissions, granted per team instead of tenant-wide, work too but do not appear
|
|
|
141
233
|
|
|
142
234
|
### Read — read identity
|
|
143
235
|
|
|
144
|
-
| Tool | Endpoint(s) | Minimal application permission | Also accepted (broader) | Teams RSC |
|
|
145
|
-
|
|
146
|
-
| `m365_capabilities` | `(token claims only)` | — | — | — |
|
|
147
|
-
| `m365_organization` | `GET /organization` | `Organization.Read.All` | `Directory.Read.All` | — |
|
|
148
|
-
| `m365_users` | `GET /users` | `User.Read.All` | `Directory.Read.All` | — |
|
|
149
|
-
| `m365_user_info` | `GET /users/{id}`<br>`GET /subscribedSkus (licence names)` | `User.Read.All` | `Directory.Read.All` | — |
|
|
150
|
-
| `m365_subscribed_skus` | `GET /subscribedSkus` | `LicenseAssignment.Read.All` | `Organization.Read.All`, `Directory.Read.All` | — |
|
|
151
|
-
| `m365_license_assignments` | `GET /users/{id}?$select=licenseAssignmentStates,assignedPlans`<br>`GET /subscribedSkus (plan names)` | `User.Read.All` | `Directory.Read.All` | — |
|
|
152
|
-
| `m365_groups` | `GET /groups` | `GroupMember.Read.All` | `Group.Read.All`, `Directory.Read.All` | — |
|
|
153
|
-
| `m365_group_info` | `GET /groups/{id}`<br>`GET /groups/{id}/members/$count`<br>`GET /groups/{id}/owners` | `GroupMember.Read.All` | `Group.Read.All`, `Directory.Read.All` | — |
|
|
154
|
-
| `m365_group_members` | `GET /groups/{id}/members` | `GroupMember.Read.All` + `User.Read.All` | `Directory.Read.All` | — |
|
|
155
|
-
| `m365_teams` | `GET /teams` | `Team.ReadBasic.All` | `TeamSettings.Read.All`, `Directory.Read.All` | — |
|
|
156
|
-
| `m365_team_info` | `GET /teams/{id}` | `Team.ReadBasic.All` | `TeamSettings.Read.All`, `TeamSettings.ReadWrite.All`, `Directory.Read.All` | `TeamSettings.Read.Group` |
|
|
157
|
-
| `m365_team_channels` | `GET /teams/{id}/channels` | `Channel.ReadBasic.All` | `ChannelSettings.Read.All`, `Directory.Read.All` | `ChannelSettings.Read.Group` |
|
|
158
|
-
| `m365_team_members` | `GET /teams/{id}/members` | `TeamMember.Read.All` | `TeamMember.ReadWrite.All`, `Directory.Read.All` | `TeamMember.Read.Group` |
|
|
159
|
-
| `
|
|
236
|
+
| Tool | Endpoint(s) | Minimal application permission | Also accepted (broader) | Teams RSC | Parts needing more | Tenant licence |
|
|
237
|
+
|---|---|---|---|---|---|---|
|
|
238
|
+
| `m365_capabilities` | `(token claims only)` | — | — | — | — | — |
|
|
239
|
+
| `m365_organization` | `GET /organization` | `Organization.Read.All` | `Directory.Read.All` | — | — | — |
|
|
240
|
+
| `m365_users` | `GET /users` | `User.Read.All` | `Directory.Read.All` | — | — | — |
|
|
241
|
+
| `m365_user_info` | `GET /users/{id}`<br>`GET /subscribedSkus (licence names)` | `User.Read.All` | `Directory.Read.All` | — | — | — |
|
|
242
|
+
| `m365_subscribed_skus` | `GET /subscribedSkus` | `LicenseAssignment.Read.All` | `Organization.Read.All`, `Directory.Read.All` | — | — | — |
|
|
243
|
+
| `m365_license_assignments` | `GET /users/{id}?$select=licenseAssignmentStates,assignedPlans`<br>`GET /subscribedSkus (plan names)` | `User.Read.All` | `Directory.Read.All` | — | — | — |
|
|
244
|
+
| `m365_groups` | `GET /groups` | `GroupMember.Read.All` | `Group.Read.All`, `Directory.Read.All` | — | — | — |
|
|
245
|
+
| `m365_group_info` | `GET /groups/{id}`<br>`GET /groups/{id}/members/$count`<br>`GET /groups/{id}/owners` | `GroupMember.Read.All` | `Group.Read.All`, `Directory.Read.All` | — | — | — |
|
|
246
|
+
| `m365_group_members` | `GET /groups/{id}/members` | `GroupMember.Read.All` + `User.Read.All` | `Directory.Read.All` | — | — | — |
|
|
247
|
+
| `m365_teams` | `GET /teams` | `Team.ReadBasic.All` | `TeamSettings.Read.All`, `Directory.Read.All` | — | — | — |
|
|
248
|
+
| `m365_team_info` | `GET /teams/{id}` | `Team.ReadBasic.All` | `TeamSettings.Read.All`, `TeamSettings.ReadWrite.All`, `Directory.Read.All` | `TeamSettings.Read.Group` | — | — |
|
|
249
|
+
| `m365_team_channels` | `GET /teams/{id}/channels` | `Channel.ReadBasic.All` | `ChannelSettings.Read.All`, `Directory.Read.All` | `ChannelSettings.Read.Group` | — | — |
|
|
250
|
+
| `m365_team_members` | `GET /teams/{id}/members` | `TeamMember.Read.All` | `TeamMember.ReadWrite.All`, `Directory.Read.All` | `TeamMember.Read.Group` | — | — |
|
|
251
|
+
| `m365_channel_members` | `GET /teams/{id}/channels/{channelId}/members` | `ChannelMember.Read.All` | `ChannelMember.ReadWrite.All`, `Directory.Read.All` | `ChannelMember.Read.Group` | — | — |
|
|
252
|
+
| `m365_usage_reports` | `GET /reports/getMailboxUsageDetail(period='D7')`<br>`GET /reports/getOneDriveUsageAccountDetail(period=…)`<br>`GET /reports/getSharePointSiteUsageDetail(period=…)`<br>`GET /reports/getOffice365ActiveUserDetail(period=…)` | `Reports.Read.All` | — | — | — | — |
|
|
253
|
+
| `m365_service_health` | `GET /admin/serviceAnnouncement/healthOverviews`<br>`GET /admin/serviceAnnouncement/issues`<br>`GET /admin/serviceAnnouncement/messages` | `ServiceHealth.Read.All` | — | — | view=messages (message center): `ServiceMessage.Read.All` | — |
|
|
254
|
+
| `m365_sites` | `GET /sites/getAllSites`<br>`GET /sites?search=… (fallback: search=*)` | `Sites.Read.All` | `Sites.ReadWrite.All`, `Sites.FullControl.All` | — | — | — |
|
|
255
|
+
| `m365_site_info` | `GET /sites/{id} | /sites/{host}:/{path}: | /groups/{id}/sites/root`<br>`GET /sites/{id}/drives` | `Sites.Read.All` | `Sites.ReadWrite.All`, `Sites.FullControl.All` | — | — | — |
|
|
256
|
+
| `m365_sharing_links` | `GET /drives/{driveId}/root:/{path}:`<br>`GET /drives/{driveId}/items/{itemId}/children`<br>`GET /drives/{driveId}/items/{itemId}/permissions` | `Sites.Read.All` | `Sites.ReadWrite.All`, `Files.Read.All` | — | — | — |
|
|
257
|
+
| `m365_directory_roles` | `GET /roleManagement/directory/roleAssignments?$expand=principal`<br>`GET /roleManagement/directory/roleDefinitions`<br>`GET /roleManagement/directory/roleEligibilityScheduleInstances (view=eligible)` | `RoleManagement.Read.Directory` | `RoleManagement.Read.All`, `Directory.Read.All` | — | view=eligible (PIM): `RoleManagement.Read.Directory` (Entra ID P2) | — |
|
|
258
|
+
| `m365_user_auth_methods` | `GET /users/{id}/authentication/methods`<br>`GET /reports/authenticationMethods/userRegistrationDetails (tenant view)` | `UserAuthenticationMethod.Read.All` | — | — | tenant view (without user): `AuditLog.Read.All` (Entra ID P1) | — |
|
|
259
|
+
| `m365_user_activity` | `GET /users?$select=…,signInActivity` | `AuditLog.Read.All` + `User.Read.All` | — | — | — | Entra ID P1 |
|
|
260
|
+
| `m365_directory_audit` | `GET /auditLogs/directoryAudits` | `AuditLog.Read.All` | — | — | — | — |
|
|
261
|
+
| `m365_applications` | `GET /servicePrincipals`<br>`GET /servicePrincipals/{id}/appRoleAssignments`<br>`GET /oauth2PermissionGrants (view=delegated_grants)` | `Application.Read.All` | `Directory.Read.All` | — | view=delegated_grants: `DelegatedPermissionGrant.Read.All` | — |
|
|
262
|
+
| `m365_conditional_access` | `GET /identity/conditionalAccess/policies`<br>`GET /policies/identitySecurityDefaultsEnforcementPolicy` | `Policy.Read.All` | — | — | Conditional Access policies: `Policy.Read.All` (Entra ID P1) | — |
|
|
263
|
+
| `m365_intune_devices` | `GET /deviceManagement/managedDevices` | `DeviceManagementManagedDevices.Read.All` | — | — | — | Intune |
|
|
264
|
+
| `m365_access_review_snapshot` | `(aggregate) the endpoints of the users, groups, channel members, roles, MFA, applications and usage-report tools` | `User.Read.All` + `GroupMember.Read.All` + `LicenseAssignment.Read.All` + `ChannelMember.Read.All` + `Channel.ReadBasic.All` + `RoleManagement.Read.Directory` + `UserAuthenticationMethod.Read.All` + `Application.Read.All` + `Reports.Read.All` | — | — | last sign-in + tenant MFA report: `AuditLog.Read.All` (Entra ID P1)<br>delegated consents: `DelegatedPermissionGrant.Read.All` | — |
|
|
265
|
+
| `m365_audit_signins` | `GET /auditLogs/signIns` | `AuditLog.Read.All` | — | — | — | — |
|
|
160
266
|
|
|
161
267
|
Notes:
|
|
162
268
|
- `m365_license_assignments` — licenseAssignmentStates and assignedPlans are user properties, hence User.Read.All. GET /users/{id}/licenseDetails is not used: it supports delegated permissions only
|
|
163
269
|
- `m365_group_members` — without User.Read.All, user members come back with their id only
|
|
164
270
|
- `m365_team_info` — if the member/guest/messaging/fun settings come back empty, add TeamSettings.Read.All
|
|
271
|
+
- `m365_channel_members` — private and shared channels have their own members, absent from m365_team_members
|
|
272
|
+
- `m365_usage_reports` — CSV through a 302 to a pre-authenticated Microsoft download URL (fetched without the Graph token, never returned). Concealed names (admin center → Reports setting) are detected and flagged
|
|
273
|
+
- `m365_sharing_links` — bounded walk (depth ≤ 3, ≤ 200 items, target folder required); link URLs are never returned
|
|
274
|
+
- `m365_user_auth_methods` — method types only — phone numbers, e-mails and keys are never returned
|
|
275
|
+
- `m365_directory_audit` — retention 7 days without Entra ID P1, 30 days with; modified property values are never returned
|
|
276
|
+
- `m365_applications` — read identity; distinct from the entra-applications write family
|
|
277
|
+
- `m365_conditional_access` — without Entra ID P1 the policies part answers unsupported_by_tenant and the security defaults are still read
|
|
278
|
+
- `m365_access_review_snapshot` — writes a dated JSON file (0600) in M365_SNAPSHOT_DIR; a section that cannot be read is reported, never left empty
|
|
165
279
|
- `m365_audit_signins` — registered only with M365_ENABLE_SIGNIN_AUDIT=true; needs Entra ID P1/P2 (else unsupported_by_tenant). Microsoft documents Directory.Read.All alongside AuditLog.Read.All for this API — add it if Graph answers 403
|
|
166
280
|
|
|
281
|
+
Phase 2 tools (audit identity, APIs outside Graph): see *Phase 2* below.
|
|
282
|
+
|
|
167
283
|
### Write — write identity (M365_MODE=full)
|
|
168
284
|
|
|
169
285
|
| Tool | Family | Endpoint(s) | Write identity — minimal permission | Also accepted (broader) | Teams RSC | Read identity — needed by the preview |
|
|
@@ -191,6 +307,26 @@ Notes:
|
|
|
191
307
|
attributes of `m365_user_update` (the `User-*` permissions cover only phones, mail or password
|
|
192
308
|
profile). Drop the `users` family from `M365_WRITE_FAMILIES` if you do not need it.
|
|
193
309
|
|
|
310
|
+
### Entra applications — dedicated entra identity (preview and execution)
|
|
311
|
+
|
|
312
|
+
This identity must contain exactly `Application.ReadWrite.OwnedBy` plus read-only
|
|
313
|
+
`Directory.Read.All`; `M365_ALLOW_BROAD_PERMISSIONS` never expands this exact allowlist.
|
|
314
|
+
|
|
315
|
+
| Tool | Access | Endpoint(s) |
|
|
316
|
+
|---|---|---|
|
|
317
|
+
| inventory, info, requested permissions | read | `GET /applications`, `GET /applications/{id}`, `GET /servicePrincipals` |
|
|
318
|
+
| effective permissions | read | bounded `GET /servicePrincipals/{id}/appRoleAssignments` and `GET /oauth2PermissionGrants`; output includes `truncated` |
|
|
319
|
+
| federated credentials | read | `GET /applications/{id}/federatedIdentityCredentials` (`$select` only; no `$top`) |
|
|
320
|
+
| application create/upsert | write | `PATCH /applications(uniqueName='{uniqueName}')` with `Prefer: create-if-missing` (no owners `/$ref` call) |
|
|
321
|
+
| application update | write | `PATCH /applications/{id}` |
|
|
322
|
+
| service-principal create/upsert | write | `PATCH /servicePrincipals(appId='{appId}')` with `Prefer: create-if-missing`; `POST /servicePrincipals/{id}/owners/$ref` only when ownership was not established automatically |
|
|
323
|
+
| service-principal update | write | `PATCH /servicePrincipals/{id}` |
|
|
324
|
+
|
|
325
|
+
V1 can read `requiredResourceAccess`, certificates and federated credentials, but exposes no write
|
|
326
|
+
field or endpoint for them. Scalar PATCH operations re-read the targeted fields immediately before
|
|
327
|
+
the request and preserve unrelated fields. This implementation does not claim atomic concurrency
|
|
328
|
+
control: a narrow residual last-writer-wins window remains and is documented explicitly.
|
|
329
|
+
|
|
194
330
|
### Refused by default
|
|
195
331
|
|
|
196
332
|
The token provider **refuses** a token carrying any of: `Directory.ReadWrite.All`,
|
|
@@ -204,6 +340,76 @@ Every token is also checked for `tid` = `M365_TENANT_ID`, `appid` = the configur
|
|
|
204
340
|
`aud` = Microsoft Graph (`tenant_mismatch` / `auth_failed` otherwise). `M365_TENANT_ID` must be a
|
|
205
341
|
GUID: `common`, `organizations` or a domain name are refused — no implicit multi-tenant authority.
|
|
206
342
|
|
|
343
|
+
## Phase 2 — APIs outside Microsoft Graph (opt-in)
|
|
344
|
+
|
|
345
|
+
Three helpdesk / review questions have no Graph v1.0 answer. They are served by a **fourth,
|
|
346
|
+
dedicated identity** (`m365-mcp-audit`), each API enabled separately with `M365_AUDIT_APP_FEATURES`.
|
|
347
|
+
Without `M365_AUDIT_APP_CLIENT_ID` none of these tools exists.
|
|
348
|
+
|
|
349
|
+
| Tool | Feature | API | Permission on that API | What |
|
|
350
|
+
|---|---|---|---|---|
|
|
351
|
+
| `m365_mailbox_permissions` | exchange | Exchange Online `InvokeCommand` | `Exchange.ManageAsApp` + **read-only** Exchange role | Full Access, Send As, Send on behalf of a mailbox, or of every shared mailbox |
|
|
352
|
+
| `m365_activity_collect` | activity | Office 365 Management Activity | `ActivityFeed.Read` | Collects the unified audit log (SharePoint/OneDrive, Exchange, Entra, Teams) into a local store |
|
|
353
|
+
| `m365_activity_search` | activity | (local store) | `ActivityFeed.Read` | "Who deleted / shared / downloaded this file? who changed these rights?" over up to 180 days |
|
|
354
|
+
| `m365_site_permissions` | sharepoint | SharePoint REST `/_api` | `Sites.Selected` + per-site `fullcontrol` | Site admins, Owners / Members / Visitors and their members, Everyone claims, external users, libraries with broken inheritance |
|
|
355
|
+
|
|
356
|
+
With `exchange`, `m365_access_review_snapshot` also records the rights on every shared mailbox, raises
|
|
357
|
+
*disabled account still delegate of a shared mailbox*, and its comparison lists rights granted and removed.
|
|
358
|
+
|
|
359
|
+
### Security model
|
|
360
|
+
|
|
361
|
+
| Risk | Control |
|
|
362
|
+
|---|---|
|
|
363
|
+
| One identity reaching three APIs | Separate Entra app with **no Graph permission** (the server never even asks for a Graph token for it); one token per API, each checked for tenant, application, **audience** and an **exact** role set — any extra role ⇒ `forbidden_permission`, before any call |
|
|
364
|
+
| Weak credential | Certificate or workload identity federation only — a client secret is a startup error (and SharePoint refuses secret-based app-only tokens anyway) |
|
|
365
|
+
| Token sent elsewhere | Each API client is pinned to one origin (`outlook.office365.com`, `manage.office.com`, `M365_SHAREPOINT_HOST`) and a closed list of method + path, checked before the token is attached; encoded separators (`%2f`, `%5c`, `%2e`, `%25`), malformed encodings and OData `@` aliases are refused; `nextLink`, `NextPageUri` and audit blob URIs from Microsoft are re-checked; redirects are refused; answers are capped in size and pages in number |
|
|
366
|
+
| Exchange: `InvokeCommand` runs any cmdlet the role allows | Server side: three cmdlets only (`Get-Mailbox`, `Get-MailboxPermission`, `Get-RecipientPermission`), closed parameter list, validated values. Tenant side: a **read-only** role, so even a bypass cannot write. A token whose `wids` claim shows a write-capable directory role (Global, Exchange, SharePoint, User… Administrator) is refused; a custom Exchange role group is invisible in the token — keep it view-only |
|
|
367
|
+
| Exchange: endpoint not publicly documented | It is the endpoint of the official ExchangeOnlineManagement v3 module; the documented *Exchange Online Admin API* (preview) covers only Send on behalf and folder permissions, not Full Access / Send As. Validate on the tenant; switch when Microsoft publishes these cmdlets |
|
|
368
|
+
| SharePoint: reading role assignments needs full control | `Sites.Selected` + `fullcontrol` granted **site by site** on the reviewed sites only; `Sites.FullControl.All` is refused unless `M365_SHAREPOINT_ALLOW_FULLCONTROL_ALL=true` (warning at startup). The client only sends GET to seven `/_api/web…` paths |
|
|
369
|
+
| Audit data = personal data | Only allowlisted fields are stored: actor, operation, object / file / site, target, result, IP — the object id only for SharePoint / OneDrive / Entra / Exchange admin records (for mail items, Teams, Forms… it can carry titles). **Never** mail subjects, items, message bodies, modified **values** or cmdlet parameter **values** (names only). Store `0700`/`0600`, purged after `M365_ACTIVITY_RETENTION_DAYS` (default 180) |
|
|
370
|
+
| `ActivityFeed.ReadDlp` (DLP matches contain sensitive content) | Refused — not in the role set |
|
|
371
|
+
| Starting audit subscriptions is a configuration change | Off by default: the route is not even allowlisted unless `M365_ACTIVITY_START_SUBSCRIPTIONS=true`; when allowed it is written to the audit trail and stopped by the kill switch (`M365_WRITE_KILL_SWITCH_FILE`) |
|
|
372
|
+
| "No result" vs "not collected" | `m365_activity_search` says when the period precedes the store, or when the last collection is older than Microsoft's 7-day retention. A content type cut by the per-run blob budget (shared between types) is **not** marked collected |
|
|
373
|
+
| Audit data used as prompt injection | Search output is labelled as recorded data; records past the retention are never returned, even before the purge |
|
|
374
|
+
|
|
375
|
+
Why not Graph `auditLogQuery` for 180 days? Microsoft moved it back from v1.0 to beta in 2025 and
|
|
376
|
+
it is still unreliable there; this server never calls Graph beta. The Management Activity API keeps
|
|
377
|
+
content 7 days, so **schedule `m365_activity_collect` daily** (a Claude routine, a cron calling the MCP,
|
|
378
|
+
or the smoke script): history builds up to the retention. Unified audit must be enabled in Purview.
|
|
379
|
+
|
|
380
|
+
### Runbook — the audit identity
|
|
381
|
+
|
|
382
|
+
1. **Create** the Entra app `m365-mcp-audit` (single tenant), **certificate** credential (or federation).
|
|
383
|
+
Give it **no Microsoft Graph permission**.
|
|
384
|
+
2. **exchange**: *API permissions → APIs my organization uses → Office 365 Exchange Online →
|
|
385
|
+
Application → `Exchange.ManageAsApp`*, admin consent. Then a read-only role, preferably a custom
|
|
386
|
+
role group (least privilege), in Exchange Online PowerShell:
|
|
387
|
+
```powershell
|
|
388
|
+
New-ServicePrincipal -AppId <appId> -ObjectId <enterprise-app-object-id> -DisplayName m365-mcp-audit
|
|
389
|
+
New-RoleGroup -Name "m365-mcp-audit (read)" -Roles "View-Only Recipients"
|
|
390
|
+
Add-RoleGroupMember -Identity "m365-mcp-audit (read)" -Member <enterprise-app-object-id>
|
|
391
|
+
```
|
|
392
|
+
Check that the role covers the three cmdlets (`Get-ManagementRoleEntry "View-Only Recipients\Get-RecipientPermission"`);
|
|
393
|
+
if one is missing, add the view-only role that holds it — never a role with `Add-*`/`Set-*`.
|
|
394
|
+
Alternative: Entra role **Global Reader** on the service principal (read-only, but broader).
|
|
395
|
+
Never Exchange Administrator.
|
|
396
|
+
3. **activity**: *Office 365 Management APIs → Application → `ActivityFeed.Read`* only (not
|
|
397
|
+
`ActivityFeed.ReadDlp`), admin consent. Check that auditing is on (Purview → Audit). Start the
|
|
398
|
+
subscriptions once: `M365_ACTIVITY_START_SUBSCRIPTIONS=true` + `m365_activity_collect
|
|
399
|
+
startMissingSubscriptions=true`, then set the flag back to `false`.
|
|
400
|
+
4. **sharepoint**: *SharePoint → Application → `Sites.Selected`*, admin consent. Then grant full control
|
|
401
|
+
on each site to review (with an admin's own Graph access, not this server):
|
|
402
|
+
```http
|
|
403
|
+
POST https://graph.microsoft.com/v1.0/sites/{site-id}/permissions
|
|
404
|
+
{ "roles": ["fullcontrol"], "grantedToIdentities": [{ "application": { "id": "<appId>", "displayName": "m365-mcp-audit" } }] }
|
|
405
|
+
```
|
|
406
|
+
Revoke with `DELETE /sites/{site-id}/permissions/{permission-id}`.
|
|
407
|
+
5. **Configure** `M365_AUDIT_APP_CLIENT_ID`, `M365_AUDIT_APP_CERT_PATH` (or `_FEDERATED_TOKEN_FILE`),
|
|
408
|
+
`M365_AUDIT_APP_FEATURES`, and per feature `M365_ACTIVITY_DIR`, `M365_SHAREPOINT_HOST`.
|
|
409
|
+
6. **Verify** with `m365_capabilities`: the `audit` block shows one token per API with its exact role.
|
|
410
|
+
7. **Revoke**: remove the feature from `M365_AUDIT_APP_FEATURES` (tools disappear), or disable the
|
|
411
|
+
enterprise app in Entra (no token anywhere), and remove the role group / site grants.
|
|
412
|
+
|
|
207
413
|
## Environment
|
|
208
414
|
|
|
209
415
|
| Variable | Default | Meaning |
|
|
@@ -215,12 +421,22 @@ GUID: `common`, `organizations` or a domain name are refused — no implicit mul
|
|
|
215
421
|
| `M365_READ_CERT_PATH` / `M365_READ_KEY_PATH` | — | **2nd choice** — PEM certificate (+ unencrypted private key, in the same file or `KEY_PATH`) |
|
|
216
422
|
| `M365_READ_CLIENT_SECRET` | — | **Acceptance testing only** — warning printed at startup |
|
|
217
423
|
| `M365_WRITE_*` | — | Same variables for the write application, **read only when `M365_MODE=full`** — missing ⇒ startup failure; same client id as read ⇒ startup failure |
|
|
218
|
-
| `M365_WRITE_FAMILIES` |
|
|
219
|
-
| `
|
|
424
|
+
| `M365_WRITE_FAMILIES` | `users,licenses,groups,teams` | Comma list; add `entra-applications` explicitly to enable that high-risk family, or use `none` |
|
|
425
|
+
| `M365_ENTRA_*` | — | Third dedicated identity, loaded only for `entra-applications`; same credential forms as read/write; client id must differ from both |
|
|
426
|
+
| `M365_WRITE_KILL_SWITCH_FILE` | — | While this file exists, every write is refused (checked at each call); configuration is mandatory when `entra-applications` is enabled |
|
|
220
427
|
| `M365_AUDIT_LOG_FILE` | — | Also append the audit trail to this file |
|
|
221
428
|
| `M365_AUDIT_TARGET_ID` | `id` | `id` or `hash` (keyed HMAC-SHA256 of the object id — a plain hash of a GUID would be reversible by anyone who can list the directory) |
|
|
222
429
|
| `M365_AUDIT_HASH_KEY` | — | Required with `hash`: ≥ 16 characters, kept secret (redacted everywhere) |
|
|
223
430
|
| `M365_ENABLE_SIGNIN_AUDIT` | `false` | Register `m365_audit_signins` |
|
|
431
|
+
| `M365_AUDIT_APP_CLIENT_ID` | — | Phase 2: dedicated audit identity (certificate `M365_AUDIT_APP_CERT_PATH`/`_KEY_PATH` or `M365_AUDIT_APP_FEDERATED_TOKEN_FILE`; a secret is refused) |
|
|
432
|
+
| `M365_AUDIT_APP_FEATURES` | — | Required with the identity: comma list of `exchange`, `activity`, `sharepoint` |
|
|
433
|
+
| `M365_EXCHANGE_ORGANIZATION` | from Graph | Initial domain (`contoso.onmicrosoft.com`) used to route Exchange calls |
|
|
434
|
+
| `M365_ACTIVITY_DIR` | — | Required by `activity`: absolute directory of the collected audit records (`0700`/`0600`) |
|
|
435
|
+
| `M365_ACTIVITY_RETENTION_DAYS` | `180` | Collected records older than this are purged (7–3650) |
|
|
436
|
+
| `M365_ACTIVITY_START_SUBSCRIPTIONS` | `false` | Allow `m365_activity_collect` to start missing subscriptions |
|
|
437
|
+
| `M365_SHAREPOINT_HOST` | — | Required by `sharepoint`: `<tenant>.sharepoint.com`, the only host its token goes to |
|
|
438
|
+
| `M365_SHAREPOINT_ALLOW_FULLCONTROL_ALL` | `false` | Accept `Sites.FullControl.All` instead of `Sites.Selected` — discouraged |
|
|
439
|
+
| `M365_SNAPSHOT_DIR` | — | Absolute directory where `m365_access_review_snapshot` writes its dated JSON files (`0600`) and finds the previous ones; unset ⇒ the review is answered but not saved, and `compareWith` is refused |
|
|
224
440
|
| `M365_ALLOW_BROAD_PERMISSIONS` | `false` | Accept tokens with the refused permissions above |
|
|
225
441
|
|
|
226
442
|
Exactly one credential per identity: several ⇒ startup error. Tokens are cached **in memory only**
|
|
@@ -248,11 +464,12 @@ claude mcp add m365 --scope user \
|
|
|
248
464
|
|
|
249
465
|
## Runbook — Entra identities
|
|
250
466
|
|
|
251
|
-
### 1. Create the
|
|
467
|
+
### 1. Create the applications
|
|
252
468
|
|
|
253
|
-
Entra admin center → **Identity → Applications → App registrations → New registration
|
|
254
|
-
`m365-mcp-read` and `m365-mcp-write`,
|
|
255
|
-
|
|
469
|
+
Entra admin center → **Identity → Applications → App registrations → New registration**: create
|
|
470
|
+
`m365-mcp-read` and `m365-mcp-write`, plus `m365-mcp-entra` if the optional `entra-applications`
|
|
471
|
+
family is used. Choose *Accounts in this organizational directory only* (single tenant), with no
|
|
472
|
+
redirect URI. Note each **Application (client) ID** and the **Directory (tenant) ID**.
|
|
256
473
|
Set **Owners** to named administrators (not a technical account) and, under *Enterprise
|
|
257
474
|
applications → the app → Properties*, *Visible to users* = No.
|
|
258
475
|
|
|
@@ -263,6 +480,14 @@ matrix above — read permissions on `m365-mcp-read` only, write permissions on
|
|
|
263
480
|
only (plus `User.Read.All` there if you use `m365_user_set_account_enabled`). Remove the default
|
|
264
481
|
delegated `User.Read`, which is useless here. Nothing from the *Refused by default* list.
|
|
265
482
|
|
|
483
|
+
Full read set for every read tool (0.3.0): `User.Read.All`, `GroupMember.Read.All`,
|
|
484
|
+
`LicenseAssignment.Read.All`, `Organization.Read.All`, `Team.ReadBasic.All`, `TeamMember.Read.All`,
|
|
485
|
+
`TeamSettings.Read.All`, `Channel.ReadBasic.All`, `ChannelMember.Read.All`, `Reports.Read.All`,
|
|
486
|
+
`Sites.Read.All`, `RoleManagement.Read.Directory` (or `.All`), `AuditLog.Read.All`,
|
|
487
|
+
`UserAuthenticationMethod.Read.All`, `Application.Read.All`, `DelegatedPermissionGrant.Read.All`,
|
|
488
|
+
`Policy.Read.All`, `ServiceHealth.Read.All`, `ServiceMessage.Read.All`, and
|
|
489
|
+
`DeviceManagementManagedDevices.Read.All` on Intune tenants. All are read-only.
|
|
490
|
+
|
|
266
491
|
### 3. Grant admin consent
|
|
267
492
|
|
|
268
493
|
*API permissions → **Grant admin consent for <tenant>*** (Privileged Role Administrator or Global
|
|
@@ -326,10 +551,17 @@ The read identity is independent: revoking the write app keeps the diagnostics.
|
|
|
326
551
|
Copy `.env.example` to `.env`, fill it, build (`npm run build`), then:
|
|
327
552
|
|
|
328
553
|
```bash
|
|
329
|
-
node smoke.mjs # read identity: capabilities,
|
|
554
|
+
node smoke.mjs # read identity: capabilities, then one bounded call per read tool
|
|
555
|
+
node smoke.mjs --review # same, plus one full m365_access_review_snapshot
|
|
330
556
|
node smoke.mjs --write # write identity, on dedicated acceptance objects only
|
|
331
557
|
```
|
|
332
558
|
|
|
559
|
+
In read mode, `unsupported_by_tenant` is accepted for the tools needing Entra ID P1/P2 or Intune
|
|
560
|
+
(expected on a tenant without them, e.g. Business Basic / Standard), and `permission_missing` for
|
|
561
|
+
`m365_applications view=delegated_grants` until `DelegatedPermissionGrant.Read.All` is granted.
|
|
562
|
+
`M365_SMOKE_TEAM` adds the channel members of its first private channel, `M365_SMOKE_FOLDER` a
|
|
563
|
+
`m365_sharing_links` call on that folder of the first listed site.
|
|
564
|
+
|
|
333
565
|
`--write` requires `M365_MODE=full`, `M365_SMOKE_USER` and at least one of `M365_SMOKE_GROUP`,
|
|
334
566
|
`M365_SMOKE_TEAM`, `M365_SMOKE_SKU`. **Create dedicated acceptance objects** (user, security group,
|
|
335
567
|
team, a spare licence) whose names contain `M365_SMOKE_MARKER` (default `recette`); the script
|
|
@@ -361,10 +593,20 @@ mode and family gating, `full` without write identity, pagination / caps / curso
|
|
|
361
593
|
and bounded retries, Graph error normalisation, redaction of secrets and tokens, allowlists, ambiguous
|
|
362
594
|
targets, preview/confirmation bound to target and state, idempotence of members and licences,
|
|
363
595
|
`request-id` propagation, `@odata.nextLink` host pinning, certificate assertion signature, and the
|
|
364
|
-
compiled server started over MCP stdio.
|
|
596
|
+
compiled server started over MCP stdio. Every read tool added in 0.3.0 has tests on anonymised real
|
|
597
|
+
Graph payloads (usage-report CSV through the 302, concealed names, `unsupported_by_tenant` on tenants
|
|
598
|
+
without P1 / Intune, no phone number / link URL / audit value in any answer), the
|
|
599
|
+
`m365_team_members` non-regression (Graph's 400 on `$select=userId`), and the access-review
|
|
600
|
+
snapshot, signals and comparison end to end.
|
|
365
601
|
|
|
366
602
|
## Validation status
|
|
367
603
|
|
|
604
|
+
- 0.3.0 (support and access-review read tools): unit tests passing; **to validate on both tenants**
|
|
605
|
+
— Pulse myIT (without P1) and Pulse Group (with P1 + Intune) — with `m365_capabilities` then
|
|
606
|
+
`node smoke.mjs --review`. Behaviours only a real tenant shows: the `getAllSites` / `search=*`
|
|
607
|
+
fallback, the report download host, the exact Graph error of each P1 API on a non-P1 tenant
|
|
608
|
+
(mapped to `unsupported_by_tenant` from the subscribed service plans whatever its code).
|
|
609
|
+
|
|
368
610
|
- Unit and contract tests: passing, without tenant access.
|
|
369
611
|
- To confirm on a real tenant (Graph behaviours not testable offline): the advanced query
|
|
370
612
|
`GET /groups/{id}/members?$filter=id eq '…'` used for the membership pre-check, `GET /teams?$filter=displayName eq …`
|
package/dist/audit.js
CHANGED
|
@@ -24,7 +24,17 @@ export class AuditLogger {
|
|
|
24
24
|
tool: e.tool,
|
|
25
25
|
mode: this.ctx.mode,
|
|
26
26
|
tenant: this.ctx.tenant,
|
|
27
|
-
identity:
|
|
27
|
+
identity: e.identity === "audit"
|
|
28
|
+
? this.ctx.auditClientId
|
|
29
|
+
? { role: "audit", clientId: this.ctx.auditClientId }
|
|
30
|
+
: undefined
|
|
31
|
+
: e.identity === "entra"
|
|
32
|
+
? this.ctx.entraClientId
|
|
33
|
+
? { role: "entra", clientId: this.ctx.entraClientId }
|
|
34
|
+
: undefined
|
|
35
|
+
: this.ctx.writeClientId
|
|
36
|
+
? { role: "write", clientId: this.ctx.writeClientId }
|
|
37
|
+
: undefined,
|
|
28
38
|
targetType: e.targetType,
|
|
29
39
|
targetId,
|
|
30
40
|
operation: e.operation,
|