@aidalinfo/m365-mcp 0.4.3 → 0.5.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/README.md
CHANGED
|
@@ -150,11 +150,14 @@ Each error carries Microsoft's `request-id` (quote it to Microsoft support) and
|
|
|
150
150
|
| `m365_team_channel_create` | `teams` | Standard channel | No-op if the name exists; never retried on 5xx (no duplicate) |
|
|
151
151
|
| `m365_team_channel_update` | `teams` | Rename / describe a channel | General channel cannot be renamed |
|
|
152
152
|
| `m365_team_settings_update` | `teams` | Allowlisted member / guest / messaging / fun settings | Strict schema |
|
|
153
|
-
| `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 |
|
|
153
|
+
| `m365_entra_applications` / `_application_info` | `entra-applications` | Typed application-registration inventory/details; `_info` adds the OAuth configuration: `spa.redirectUris`, `web.redirectUris` (+ `homePageUrl`, `logoutUrl`, implicit grant), `identifierUris`, public scope metadata | Dedicated identity; response and nested collections bounded (50 URIs per list, 20 scopes, `oauthTruncated` when cut); certificate material reduced to public metadata; no secret, no pre-authorization detail |
|
|
154
154
|
| `m365_entra_service_principals` / `_service_principal_info` | `entra-applications` | Typed enterprise-application inventory/details | Dedicated identity; allowlisted fields only |
|
|
155
155
|
| `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 |
|
|
156
156
|
| `m365_entra_application_federated_credentials` | `entra-applications` | First 20 federated identity credentials | Application ownership is verified first; no external token or secret is read |
|
|
157
157
|
| `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 |
|
|
158
|
+
| `m365_entra_application_redirect_uris` | `entra-applications` | Add / remove SPA or Web redirect URIs (`platform`: `spa` or `web`, `changes: { add, remove }`) | Owned application only; targeted edit: other URIs and the other platform are preserved (the Web platform is sent back whole, `homePageUrl`, `logoutUrl`, implicit grant kept); https only, `http://localhost` / `127.0.0.1` / `[::1]` only with `allowLocalhost: true`; wildcards, fragments, query strings, userinfo, percent-encoding, dot segments, IP literals, non-ASCII / bidi / control characters and normalized duplicates (case of scheme/host, default port, trailing `/`) refused before any write; SAML-indexed `redirectUriSettings` refused |
|
|
159
|
+
| `m365_entra_application_identifier_uris` | `entra-applications` | Add / remove identifier URIs (Application ID URI) | Exactly `api://<appId of this application>` or https on a DNS name (verified domain enforced by Entra); removing the last one while scopes are enabled is refused |
|
|
160
|
+
| `m365_entra_application_oauth2_scope_upsert` | `entra-applications` | Create or update **one** delegated scope (`api.oauth2PermissionScopes`) keyed by its `value` | Stable id (existing id kept, otherwise derived from appId + value); other scopes, `preAuthorizedApplications` and API settings sent back unchanged; strict schema (no id, secret or consent field), bounded texts without control / bidi characters, reserved OIDC values refused; no deletion (`isEnabled: false` disables); **never** creates a consent or an OAuth2 permission grant |
|
|
158
161
|
| `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 |
|
|
159
162
|
| `m365_mailbox_delegation_add` / `_remove` | `exchange-delegation` | Give / remove a user's **Full Access** (with `autoMapping`, default true) or **Send As** on a shared mailbox; the preview lists who already holds the right | Shared mailboxes only (personal, room and equipment refused); guests and disabled accounts refused on add; explicit grants only (group-inherited rights untouched); dedicated identity, kill switch mandatory |
|
|
160
163
|
|
|
@@ -380,11 +383,20 @@ This identity must contain exactly `Application.ReadWrite.OwnedBy` plus read-onl
|
|
|
380
383
|
| federated credentials | read | `GET /applications/{id}/federatedIdentityCredentials` (`$select` only; no `$top`) |
|
|
381
384
|
| application create/upsert | write | `PATCH /applications(uniqueName='{uniqueName}')` with `Prefer: create-if-missing` (no owners `/$ref` call) |
|
|
382
385
|
| application update | write | `PATCH /applications/{id}` |
|
|
386
|
+
| redirect URIs | write | `PATCH /applications/{id}` with `spa` or `web` only |
|
|
387
|
+
| identifier URIs | write | `PATCH /applications/{id}` with `identifierUris` only |
|
|
388
|
+
| delegated scope upsert | write | `PATCH /applications/{id}` with `api` only (no `/oauth2PermissionGrants`, no `/appRoleAssignments`) |
|
|
383
389
|
| 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 |
|
|
384
390
|
| service-principal update | write | `PATCH /servicePrincipals/{id}` |
|
|
385
391
|
|
|
386
392
|
V1 can read `requiredResourceAccess`, certificates and federated credentials, but exposes no write
|
|
387
|
-
field or endpoint for them.
|
|
393
|
+
field or endpoint for them. Redirect URIs, identifier URIs and delegated scopes are written by the
|
|
394
|
+
three OAuth tools only: the preview binds the whole list (or the whole scope collection and API
|
|
395
|
+
settings), the execution re-reads it with ownership right before the `PATCH` and refuses
|
|
396
|
+
(`confirmation_invalid`) if it moved, and the post-write re-read must show exactly the expected
|
|
397
|
+
state — otherwise the call fails as `transient` (*changed the target but post-write verification
|
|
398
|
+
failed*): inspect the application before retrying. Client secrets, private keys, admin consent,
|
|
399
|
+
grants and application deletion stay out of scope. Scalar PATCH operations re-read the targeted fields immediately before
|
|
388
400
|
the request and preserve unrelated fields. This implementation does not claim atomic concurrency
|
|
389
401
|
control: a narrow residual last-writer-wins window remains and is documented explicitly.
|
|
390
402
|
|
|
@@ -609,6 +621,14 @@ From fastest to most definitive:
|
|
|
609
621
|
|
|
610
622
|
The read identity is independent: revoking the write app keeps the diagnostics.
|
|
611
623
|
|
|
624
|
+
`entra-applications` family (dedicated `m365-mcp-entra` identity): the kill switch covers it the same
|
|
625
|
+
way; to cut it at the source, disable the enterprise application `m365-mcp-entra` or revoke its
|
|
626
|
+
`Application.ReadWrite.OwnedBy` consent. To undo an OAuth change made by the server, call the same
|
|
627
|
+
tool with the opposite `changes` (`remove` the redirect / identifier URI it added, or upsert the scope
|
|
628
|
+
with `isEnabled: false`), or edit *App registrations → <app> → Authentication / Expose an API* in the
|
|
629
|
+
portal. The audit trail (`tool`, `targetId`, `graphRequestId`, `approvalRef`) gives the exact call to
|
|
630
|
+
reverse. These tools never create a consent or a grant: nothing else needs revoking.
|
|
631
|
+
|
|
612
632
|
## Smoke test (real tenant)
|
|
613
633
|
|
|
614
634
|
Copy `.env.example` to `.env`, fill it, build (`npm run build`), then:
|
package/dist/permissions.js
CHANGED
|
@@ -365,6 +365,9 @@ export const TOOL_SPECS = [
|
|
|
365
365
|
{ tool: "m365_entra_application_federated_credentials", access: "read", identity: "entra", family: "entra-applications", endpoints: ["GET /applications/{id}/federatedIdentityCredentials"], permissions: ["Application.ReadWrite.OwnedBy"] },
|
|
366
366
|
{ tool: "m365_entra_application_create", access: "write", identity: "entra", family: "entra-applications", planPermissions: ["Application.ReadWrite.OwnedBy"], endpoints: ["PATCH /applications(uniqueName='{uniqueName}') + Prefer: create-if-missing"], permissions: ["Application.ReadWrite.OwnedBy"] },
|
|
367
367
|
{ tool: "m365_entra_application_update", access: "write", identity: "entra", family: "entra-applications", planPermissions: ["Application.ReadWrite.OwnedBy"], endpoints: ["PATCH /applications/{id}"], permissions: ["Application.ReadWrite.OwnedBy"] },
|
|
368
|
+
{ tool: "m365_entra_application_redirect_uris", access: "write", identity: "entra", family: "entra-applications", planPermissions: ["Application.ReadWrite.OwnedBy"], endpoints: ["PATCH /applications/{id} (spa or web)"], permissions: ["Application.ReadWrite.OwnedBy"], note: "owned applications only; targeted add/remove, the other platform and existing URIs preserved; no consent" },
|
|
369
|
+
{ tool: "m365_entra_application_identifier_uris", access: "write", identity: "entra", family: "entra-applications", planPermissions: ["Application.ReadWrite.OwnedBy"], endpoints: ["PATCH /applications/{id} (identifierUris)"], permissions: ["Application.ReadWrite.OwnedBy"], note: "api://<appId> or https on a verified domain only" },
|
|
370
|
+
{ tool: "m365_entra_application_oauth2_scope_upsert", access: "write", identity: "entra", family: "entra-applications", planPermissions: ["Application.ReadWrite.OwnedBy"], endpoints: ["PATCH /applications/{id} (api.oauth2PermissionScopes)"], permissions: ["Application.ReadWrite.OwnedBy"], note: "one scope per call, stable id, no deletion; never creates a consent or an OAuth2 permission grant" },
|
|
368
371
|
{ tool: "m365_entra_service_principal_create", access: "write", identity: "entra", family: "entra-applications", planPermissions: ["Application.ReadWrite.OwnedBy"], endpoints: ["PATCH /servicePrincipals(appId='{appId}') + Prefer: create-if-missing", "POST /servicePrincipals/{id}/owners/$ref when Graph did not establish ownership"], permissions: ["Application.ReadWrite.OwnedBy"] },
|
|
369
372
|
{ tool: "m365_entra_service_principal_update", access: "write", identity: "entra", family: "entra-applications", planPermissions: ["Application.ReadWrite.OwnedBy"], endpoints: ["PATCH /servicePrincipals/{id}"], permissions: ["Application.ReadWrite.OwnedBy"] },
|
|
370
373
|
{
|
package/dist/register.js
CHANGED
|
@@ -10,6 +10,7 @@ import { registerGroupWriteTools } from "./tools/groups-write.js";
|
|
|
10
10
|
import { registerTeamWriteTools } from "./tools/teams-write.js";
|
|
11
11
|
import { registerEntraApplicationReadTools } from "./tools/entra-applications.js";
|
|
12
12
|
import { registerEntraApplicationWriteTools } from "./tools/entra-applications-write.js";
|
|
13
|
+
import { registerEntraApplicationOAuthTools } from "./tools/entra-applications-oauth.js";
|
|
13
14
|
import { registerExchangeDelegationWriteTools } from "./tools/exchange-delegation-write.js";
|
|
14
15
|
import { registerReportTools } from "./tools/reports.js";
|
|
15
16
|
import { registerSiteTools } from "./tools/sites.js";
|
|
@@ -67,6 +68,7 @@ export function registerTools(server, ctx, serverVersion) {
|
|
|
67
68
|
throw new Error("entra-applications requires the dedicated identity (M365_ENTRA_*)");
|
|
68
69
|
registerEntraApplicationReadTools(tracking, ctx);
|
|
69
70
|
registerEntraApplicationWriteTools(tracking, ctx);
|
|
71
|
+
registerEntraApplicationOAuthTools(tracking, ctx);
|
|
70
72
|
}
|
|
71
73
|
if (f.has("exchange-delegation")) {
|
|
72
74
|
if (!ctx.identities.exchange || !ctx.ext.delegation)
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { stableStringify } from "../confirm.js";
|
|
4
|
+
import { M365Error } from "../errors.js";
|
|
5
|
+
import { applicationParam, assertOwned, resolveApplication, safeOAuthConfig, safeScope } from "./entra-applications.js";
|
|
6
|
+
import { boundedAfter } from "./entra-applications-write.js";
|
|
7
|
+
import { confirmParams, rid, runWrite } from "./write-flow.js";
|
|
8
|
+
/**
|
|
9
|
+
* OAuth / OIDC configuration of owned Entra applications: SPA and Web redirect URIs, identifier URIs
|
|
10
|
+
* and delegated scopes exposed by the application. Targeted add / remove only (existing values are
|
|
11
|
+
* preserved), strict URI validation, no secret, no consent, no grant, no deletion of an application.
|
|
12
|
+
*/
|
|
13
|
+
const OAUTH_SELECT = "id,appId,displayName,identifierUris,spa,web,api";
|
|
14
|
+
/** Largest list a write tool accepts to rewrite (Graph replaces the whole collection). */
|
|
15
|
+
export const MAX_URIS = 100;
|
|
16
|
+
export const MAX_SCOPES = 50;
|
|
17
|
+
const MAX_CHANGES = 10;
|
|
18
|
+
const obj = (v) => (v && typeof v === "object" && !Array.isArray(v) ? v : {});
|
|
19
|
+
const strings = (v) => (Array.isArray(v) ? v.filter((x) => typeof x === "string") : []);
|
|
20
|
+
const equal = (a, b) => stableStringify(a) === stableStringify(b);
|
|
21
|
+
const refuse = (message) => {
|
|
22
|
+
throw new M365Error("refused", `refused: ${message}`);
|
|
23
|
+
};
|
|
24
|
+
// ── URI validation ───────────────────────────────────────────────────────────────────────────────
|
|
25
|
+
/** Visible ASCII only: no space, control, bidi, zero-width or other look-alike Unicode character. */
|
|
26
|
+
const VISIBLE_ASCII = /^[\x21-\x7e]+$/;
|
|
27
|
+
/** Control, zero-width, bidi-override and BOM characters, refused in any free text. */
|
|
28
|
+
const DECEPTIVE_RANGES = [[0x00, 0x1f], [0x7f, 0x9f], [0xad, 0xad], [0x200b, 0x200f], [0x2028, 0x202e], [0x2060, 0x206f], [0xfeff, 0xfeff]];
|
|
29
|
+
const DECEPTIVE = new RegExp(`[${DECEPTIVE_RANGES.map(([a, b]) => `${String.fromCharCode(a)}-${String.fromCharCode(b)}`).join("")}]`);
|
|
30
|
+
const LOOPBACK = new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
31
|
+
const IPV4 = /^\d{1,3}(\.\d{1,3}){3}$/;
|
|
32
|
+
const HOST = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)(\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)+$/;
|
|
33
|
+
const uriInput = z.string().min(1).max(256);
|
|
34
|
+
/**
|
|
35
|
+
* Validate a redirect URI (or an https identifier URI) and return its comparison key.
|
|
36
|
+
* https only; http is accepted for a loopback host only when `allowLocalhost` is true; no wildcard,
|
|
37
|
+
* fragment, query, userinfo, percent-encoding, backslash or non-ASCII character.
|
|
38
|
+
*/
|
|
39
|
+
export function checkUri(raw, allowLocalhost, what = "redirect URI") {
|
|
40
|
+
if (!VISIBLE_ASCII.test(raw))
|
|
41
|
+
refuse(`${what} ${JSON.stringify(raw)} contains spaces, control or non-ASCII characters`);
|
|
42
|
+
if (raw.includes("*"))
|
|
43
|
+
refuse(`${what} ${raw} contains a wildcard`);
|
|
44
|
+
if (raw.includes("#"))
|
|
45
|
+
refuse(`${what} ${raw} contains a fragment`);
|
|
46
|
+
if (raw.includes("?"))
|
|
47
|
+
refuse(`${what} ${raw} contains a query string`);
|
|
48
|
+
if (raw.includes("@"))
|
|
49
|
+
refuse(`${what} ${raw} contains user information`);
|
|
50
|
+
if (raw.includes("%"))
|
|
51
|
+
refuse(`${what} ${raw} contains percent-encoded characters`);
|
|
52
|
+
if (raw.includes("\\"))
|
|
53
|
+
refuse(`${what} ${raw} contains a backslash`);
|
|
54
|
+
if (!/^https?:\/\/[^/]/i.test(raw))
|
|
55
|
+
refuse(`${what} ${raw} must be an absolute https:// URI`);
|
|
56
|
+
let url;
|
|
57
|
+
try {
|
|
58
|
+
url = new URL(raw);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return refuse(`${what} ${raw} is not a valid absolute URI`);
|
|
62
|
+
}
|
|
63
|
+
const loopback = LOOPBACK.has(url.hostname);
|
|
64
|
+
if (loopback) {
|
|
65
|
+
if (!allowLocalhost)
|
|
66
|
+
refuse(`${what} ${raw} targets a loopback host; set allowLocalhost: true explicitly to accept it`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
if (url.protocol !== "https:")
|
|
70
|
+
refuse(`${what} ${raw} must use https`);
|
|
71
|
+
if (IPV4.test(url.hostname) || url.hostname.startsWith("["))
|
|
72
|
+
refuse(`${what} ${raw} uses an IP literal; use a DNS name`);
|
|
73
|
+
if (!HOST.test(url.hostname))
|
|
74
|
+
refuse(`${what} ${raw} has an invalid host name`);
|
|
75
|
+
}
|
|
76
|
+
if (/\/\.\.?(\/|$)/.test(raw.replace(/^https?:\/\//i, ""))) {
|
|
77
|
+
refuse(`${what} ${raw} contains dot segments`);
|
|
78
|
+
}
|
|
79
|
+
return key(url);
|
|
80
|
+
}
|
|
81
|
+
/** Comparison key: lower-case scheme and host, default port dropped, a lone trailing "/" ignored. */
|
|
82
|
+
const key = (url) => `${url.protocol}//${url.host}${url.pathname === "/" ? "" : url.pathname.replace(/\/$/, "")}`;
|
|
83
|
+
/** Key of a value already on the application (it may predate this validation): never throws. */
|
|
84
|
+
function lenientKey(raw) {
|
|
85
|
+
try {
|
|
86
|
+
if (/^https?:\/\//i.test(raw))
|
|
87
|
+
return key(new URL(raw));
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
/* fall through */
|
|
91
|
+
}
|
|
92
|
+
return raw.toLowerCase();
|
|
93
|
+
}
|
|
94
|
+
/** Identifier URI: exactly `api://<appId of this application>`, or an https URI validated like a redirect URI. */
|
|
95
|
+
export function checkIdentifierUri(raw, appId) {
|
|
96
|
+
if (/^api:/i.test(raw)) {
|
|
97
|
+
const m = /^api:\/\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i.exec(raw);
|
|
98
|
+
if (!m || m[1].toLowerCase() !== appId.toLowerCase())
|
|
99
|
+
refuse(`identifier URI ${JSON.stringify(raw)} must be exactly api://${appId} or an https URI on a verified domain`);
|
|
100
|
+
return raw.toLowerCase();
|
|
101
|
+
}
|
|
102
|
+
return checkUri(raw, false, "identifier URI");
|
|
103
|
+
}
|
|
104
|
+
const identifierKey = (raw) => (/^api:/i.test(raw) ? raw.toLowerCase() : lenientKey(raw));
|
|
105
|
+
export const uriChangesSchema = z
|
|
106
|
+
.object({
|
|
107
|
+
add: z.array(uriInput).max(MAX_CHANGES).default([]).describe("URIs to add; existing ones are kept"),
|
|
108
|
+
remove: z.array(uriInput).max(MAX_CHANGES).default([]).describe("URIs to remove (exact value, or same scheme/host/path); absent ones are ignored"),
|
|
109
|
+
})
|
|
110
|
+
.strict()
|
|
111
|
+
.refine((c) => c.add.length + c.remove.length > 0, "add or remove at least one URI");
|
|
112
|
+
/**
|
|
113
|
+
* Targeted edit of a URI list: keeps every current value (even one that would fail today's
|
|
114
|
+
* validation) except those explicitly removed; refuses a duplicate, a near-duplicate of an existing
|
|
115
|
+
* value, or the same URI both added and removed.
|
|
116
|
+
*/
|
|
117
|
+
export function planUriList(current, add, remove, check, currentKey, label) {
|
|
118
|
+
if (current.length > MAX_URIS)
|
|
119
|
+
refuse(`${label} already holds ${current.length} values (limit ${MAX_URIS} for this tool); edit it in the Entra portal`);
|
|
120
|
+
const addKeys = new Map();
|
|
121
|
+
for (const raw of add) {
|
|
122
|
+
const k = check(raw);
|
|
123
|
+
if (addKeys.has(k))
|
|
124
|
+
refuse(`${label}: ${raw} duplicates ${addKeys.get(k)} in the same request`);
|
|
125
|
+
addKeys.set(k, raw);
|
|
126
|
+
}
|
|
127
|
+
const removeKeys = new Set();
|
|
128
|
+
for (const raw of remove) {
|
|
129
|
+
if (!VISIBLE_ASCII.test(raw))
|
|
130
|
+
refuse(`${label}: ${JSON.stringify(raw)} contains spaces, control or non-ASCII characters`);
|
|
131
|
+
const k = currentKey(raw);
|
|
132
|
+
if (addKeys.has(k))
|
|
133
|
+
refuse(`${label}: ${raw} is both added and removed`);
|
|
134
|
+
removeKeys.add(k);
|
|
135
|
+
}
|
|
136
|
+
const removed = current.filter((c) => removeKeys.has(currentKey(c)));
|
|
137
|
+
const next = current.filter((c) => !removeKeys.has(currentKey(c)));
|
|
138
|
+
const added = [];
|
|
139
|
+
for (const [k, raw] of addKeys) {
|
|
140
|
+
const existing = next.find((c) => currentKey(c) === k);
|
|
141
|
+
if (existing === raw)
|
|
142
|
+
continue;
|
|
143
|
+
if (existing !== undefined)
|
|
144
|
+
refuse(`${label}: ${raw} is a normalized duplicate of the existing ${existing}`);
|
|
145
|
+
next.push(raw);
|
|
146
|
+
added.push(raw);
|
|
147
|
+
}
|
|
148
|
+
if (next.length > MAX_URIS)
|
|
149
|
+
refuse(`${label} would hold ${next.length} values (limit ${MAX_URIS})`);
|
|
150
|
+
return { next, added, removed };
|
|
151
|
+
}
|
|
152
|
+
// ── snapshots (state bound to the confirmation and compared again right before the PATCH) ──────────
|
|
153
|
+
const WEB_KEPT = ["homePageUrl", "logoutUrl", "implicitGrantSettings"];
|
|
154
|
+
const API_KEPT = ["acceptMappedClaims", "knownClientApplications", "preAuthorizedApplications", "requestedAccessTokenVersion"];
|
|
155
|
+
function platforms(app) {
|
|
156
|
+
const web = obj(app.web);
|
|
157
|
+
return {
|
|
158
|
+
spa: { redirectUris: strings(obj(app.spa).redirectUris) },
|
|
159
|
+
web: { redirectUris: strings(web.redirectUris), ...Object.fromEntries(WEB_KEPT.map((k) => [k, web[k] ?? null])) },
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const scopesOf = (app) => (Array.isArray(obj(app.api).oauth2PermissionScopes) ? obj(app.api).oauth2PermissionScopes : []);
|
|
163
|
+
const apiKept = (app) => Object.fromEntries(API_KEPT.map((k) => [k, obj(app.api)[k] ?? null]));
|
|
164
|
+
/** A scope as sent back to Graph: every writable field as read, `origin` (server-owned) left out. */
|
|
165
|
+
const writableScope = ({ origin: _origin, ...rest }) => rest;
|
|
166
|
+
async function ownedOAuthApplication(ctx, input) {
|
|
167
|
+
const app = await resolveApplication(ctx, input, OAUTH_SELECT);
|
|
168
|
+
await assertOwned(ctx, app);
|
|
169
|
+
if (!app.appId)
|
|
170
|
+
refuse("application has no appId");
|
|
171
|
+
return app;
|
|
172
|
+
}
|
|
173
|
+
const result = (app) => ({ id: app.id, appId: app.appId, displayName: app.displayName, ...safeOAuthConfig(app) });
|
|
174
|
+
/** Re-read, re-check ownership, then require the exact expected state (bounded retries). */
|
|
175
|
+
async function verified(ctx, id, ready) {
|
|
176
|
+
return result(await boundedAfter(ctx, async () => {
|
|
177
|
+
const app = await resolveApplication(ctx, id, OAUTH_SELECT);
|
|
178
|
+
await assertOwned(ctx, app);
|
|
179
|
+
return app;
|
|
180
|
+
}, ready));
|
|
181
|
+
}
|
|
182
|
+
/** Execute-time guard: ownership and the bound state must still hold right before the mutation. */
|
|
183
|
+
async function stillAsPreviewed(ctx, id, snapshot, before) {
|
|
184
|
+
const app = await resolveApplication(ctx, id, OAUTH_SELECT);
|
|
185
|
+
await assertOwned(ctx, app);
|
|
186
|
+
if (!equal(snapshot(app), before))
|
|
187
|
+
throw new M365Error("confirmation_invalid", "confirmation_invalid: the application OAuth configuration changed after confirmation — run the preview again");
|
|
188
|
+
return app;
|
|
189
|
+
}
|
|
190
|
+
// ── scopes ───────────────────────────────────────────────────────────────────────────────────────
|
|
191
|
+
const RESERVED_SCOPES = new Set(["openid", "profile", "email", "offline_access", "address", "phone"]);
|
|
192
|
+
const text = (max) => z
|
|
193
|
+
.string()
|
|
194
|
+
.trim()
|
|
195
|
+
.min(1)
|
|
196
|
+
.max(max)
|
|
197
|
+
.refine((s) => !DECEPTIVE.test(s), "control, zero-width or bidi characters are not allowed");
|
|
198
|
+
export const scopeSchema = z
|
|
199
|
+
.object({
|
|
200
|
+
value: z
|
|
201
|
+
.string()
|
|
202
|
+
.regex(/^[A-Za-z][A-Za-z0-9._-]{0,119}$/, "scope value: a letter then letters, digits, '.', '_' or '-' (120 max)")
|
|
203
|
+
.refine((v) => !RESERVED_SCOPES.has(v.toLowerCase()), "reserved OpenID Connect scope value")
|
|
204
|
+
.describe("Scope value as requested by clients (api://…/<value>); the key of the upsert"),
|
|
205
|
+
type: z.enum(["User", "Admin"]).describe("User = users may consent; Admin = admin consent required"),
|
|
206
|
+
adminConsentDisplayName: text(120),
|
|
207
|
+
adminConsentDescription: text(1024),
|
|
208
|
+
userConsentDisplayName: text(120).optional(),
|
|
209
|
+
userConsentDescription: text(1024).optional(),
|
|
210
|
+
isEnabled: z.boolean().default(true),
|
|
211
|
+
})
|
|
212
|
+
.strict()
|
|
213
|
+
.superRefine((s, issue) => {
|
|
214
|
+
if (s.type === "User" && (!s.userConsentDisplayName || !s.userConsentDescription)) {
|
|
215
|
+
issue.addIssue({ code: "custom", message: "type User requires userConsentDisplayName and userConsentDescription" });
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
/** Stable scope id derived from the application and the scope value: the same on preview and confirm. */
|
|
219
|
+
export function stableScopeId(appId, value) {
|
|
220
|
+
const h = createHash("sha256").update(`m365-mcp:oauth2PermissionScope:${appId.toLowerCase()}:${value}`).digest("hex");
|
|
221
|
+
const variant = ((parseInt(h[16], 16) & 0x3) | 0x8).toString(16);
|
|
222
|
+
return `${h.slice(0, 8)}-${h.slice(8, 12)}-5${h.slice(13, 16)}-${variant}${h.slice(17, 20)}-${h.slice(20, 32)}`;
|
|
223
|
+
}
|
|
224
|
+
// ── tools ────────────────────────────────────────────────────────────────────────────────────────
|
|
225
|
+
export function registerEntraApplicationOAuthTools(server, ctx) {
|
|
226
|
+
server.tool("m365_entra_application_redirect_uris", "[WRITE] Add / remove SPA or Web redirect URIs of an owned application (targeted: other URIs and the other platform are preserved). https only; http://localhost (loopback) only with allowLocalhost; wildcards, fragments, queries and userinfo refused. No secret, no consent.", {
|
|
227
|
+
application: applicationParam,
|
|
228
|
+
platform: z.enum(["spa", "web"]).describe("spa = Authorization Code + PKCE from a browser; web = confidential server-side client"),
|
|
229
|
+
changes: uriChangesSchema,
|
|
230
|
+
allowLocalhost: z.boolean().default(false).describe("Accept a loopback host (localhost, 127.0.0.1, [::1]), http allowed — for local development only"),
|
|
231
|
+
...confirmParams,
|
|
232
|
+
}, async ({ application, platform, changes, allowLocalhost, confirmToken, approvalId }) => runWrite({
|
|
233
|
+
tool: "m365_entra_application_redirect_uris",
|
|
234
|
+
ctx,
|
|
235
|
+
identity: "entra",
|
|
236
|
+
confirmToken,
|
|
237
|
+
approvalId,
|
|
238
|
+
verificationRequired: true,
|
|
239
|
+
plan: async () => {
|
|
240
|
+
const app = await ownedOAuthApplication(ctx, application);
|
|
241
|
+
const before = platforms(app);
|
|
242
|
+
const settings = obj(app.web).redirectUriSettings;
|
|
243
|
+
if (platform === "web" && Array.isArray(settings) && settings.some((s) => obj(s).index !== null && obj(s).index !== undefined)) {
|
|
244
|
+
refuse("web.redirectUriSettings carries SAML indexes; edit these redirect URIs in the Entra portal");
|
|
245
|
+
}
|
|
246
|
+
const { next, added, removed } = planUriList(before[platform].redirectUris, changes.add, changes.remove, (raw) => checkUri(raw, allowLocalhost), lenientKey, `${platform}.redirectUris`);
|
|
247
|
+
const noop = added.length === 0 && removed.length === 0;
|
|
248
|
+
return {
|
|
249
|
+
targetType: "application",
|
|
250
|
+
targetId: app.id,
|
|
251
|
+
targetLabel: app.displayName ?? app.id,
|
|
252
|
+
operation: `set_${platform}_redirect_uris`,
|
|
253
|
+
before,
|
|
254
|
+
change: { platform, add: added, remove: removed, redirectUris: next },
|
|
255
|
+
...(noop ? { noop: `${platform}.redirectUris already match the request` } : {}),
|
|
256
|
+
};
|
|
257
|
+
},
|
|
258
|
+
execute: async (plan) => {
|
|
259
|
+
const app = await stillAsPreviewed(ctx, plan.targetId, platforms, plan.before);
|
|
260
|
+
const { redirectUris } = plan.change;
|
|
261
|
+
// the whole platform object is sent (Graph may replace a complex property): its other fields are kept as read
|
|
262
|
+
const body = platform === "spa" ? { spa: { redirectUris } } : { web: { ...platforms(app).web, redirectUris } };
|
|
263
|
+
return [rid(await ctx.graph.request("PATCH", `/applications/${plan.targetId}`, { identity: "entra", body }))];
|
|
264
|
+
},
|
|
265
|
+
after: async (plan) => {
|
|
266
|
+
const expected = { ...plan.before, [platform]: { ...plan.before[platform], redirectUris: plan.change.redirectUris } };
|
|
267
|
+
return verified(ctx, plan.targetId, (app) => equal(platforms(app), expected));
|
|
268
|
+
},
|
|
269
|
+
}));
|
|
270
|
+
server.tool("m365_entra_application_identifier_uris", "[WRITE] Add / remove identifier URIs (Application ID URI) of an owned application: exactly api://<appId>, or an https URI on a verified domain. Targeted: other identifier URIs are preserved. No secret, no consent.", { application: applicationParam, changes: uriChangesSchema, ...confirmParams }, async ({ application, changes, confirmToken, approvalId }) => runWrite({
|
|
271
|
+
tool: "m365_entra_application_identifier_uris",
|
|
272
|
+
ctx,
|
|
273
|
+
identity: "entra",
|
|
274
|
+
confirmToken,
|
|
275
|
+
approvalId,
|
|
276
|
+
verificationRequired: true,
|
|
277
|
+
plan: async () => {
|
|
278
|
+
const app = await ownedOAuthApplication(ctx, application);
|
|
279
|
+
const before = { identifierUris: strings(app.identifierUris) };
|
|
280
|
+
const { next, added, removed } = planUriList(before.identifierUris, changes.add, changes.remove, (raw) => checkIdentifierUri(raw, app.appId), identifierKey, "identifierUris");
|
|
281
|
+
if (next.length === 0 && removed.length > 0 && scopesOf(app).some((s) => s.isEnabled !== false)) {
|
|
282
|
+
refuse("removing every identifier URI would orphan the enabled scopes of this application; disable them first");
|
|
283
|
+
}
|
|
284
|
+
const noop = added.length === 0 && removed.length === 0;
|
|
285
|
+
return {
|
|
286
|
+
targetType: "application",
|
|
287
|
+
targetId: app.id,
|
|
288
|
+
targetLabel: app.displayName ?? app.id,
|
|
289
|
+
operation: "set_identifier_uris",
|
|
290
|
+
before,
|
|
291
|
+
change: { add: added, remove: removed, identifierUris: next },
|
|
292
|
+
...(noop ? { noop: "identifierUris already match the request" } : {}),
|
|
293
|
+
};
|
|
294
|
+
},
|
|
295
|
+
execute: async (plan) => {
|
|
296
|
+
await stillAsPreviewed(ctx, plan.targetId, (app) => ({ identifierUris: strings(app.identifierUris) }), plan.before);
|
|
297
|
+
const { identifierUris } = plan.change;
|
|
298
|
+
return [rid(await ctx.graph.request("PATCH", `/applications/${plan.targetId}`, { identity: "entra", body: { identifierUris } }))];
|
|
299
|
+
},
|
|
300
|
+
after: async (plan) => verified(ctx, plan.targetId, (app) => equal(strings(app.identifierUris), plan.change.identifierUris)),
|
|
301
|
+
}));
|
|
302
|
+
server.tool("m365_entra_application_oauth2_scope_upsert", "[WRITE] Create or update ONE delegated scope exposed by an owned application (api.oauth2PermissionScopes), keyed by its value, with a stable id. Other scopes are preserved; nothing is deleted (disable with isEnabled: false). No consent or grant is created, no secret accepted.", { application: applicationParam, scope: scopeSchema, ...confirmParams }, async ({ application, scope, confirmToken, approvalId }) => runWrite({
|
|
303
|
+
tool: "m365_entra_application_oauth2_scope_upsert",
|
|
304
|
+
ctx,
|
|
305
|
+
identity: "entra",
|
|
306
|
+
confirmToken,
|
|
307
|
+
approvalId,
|
|
308
|
+
verificationRequired: true,
|
|
309
|
+
plan: async () => {
|
|
310
|
+
const app = await ownedOAuthApplication(ctx, application);
|
|
311
|
+
const scopes = scopesOf(app);
|
|
312
|
+
if (scopes.length > MAX_SCOPES)
|
|
313
|
+
refuse(`the application already exposes ${scopes.length} scopes (limit ${MAX_SCOPES} for this tool)`);
|
|
314
|
+
const existing = scopes.find((s) => s.value === scope.value);
|
|
315
|
+
const nearDuplicate = scopes.find((s) => s !== existing && typeof s.value === "string" && s.value.toLowerCase() === scope.value.toLowerCase());
|
|
316
|
+
if (nearDuplicate)
|
|
317
|
+
refuse(`scope ${scope.value} differs only by case from the existing scope ${String(nearDuplicate.value)}`);
|
|
318
|
+
const id = existing?.id ?? stableScopeId(app.appId, scope.value);
|
|
319
|
+
const clash = scopes.find((s) => s !== existing && typeof s.id === "string" && s.id.toLowerCase() === id.toLowerCase());
|
|
320
|
+
if (clash)
|
|
321
|
+
refuse(`scope id ${id} is already used by scope ${String(clash.value)}`);
|
|
322
|
+
const desired = {
|
|
323
|
+
id,
|
|
324
|
+
value: scope.value,
|
|
325
|
+
type: scope.type,
|
|
326
|
+
isEnabled: scope.isEnabled,
|
|
327
|
+
adminConsentDisplayName: scope.adminConsentDisplayName,
|
|
328
|
+
adminConsentDescription: scope.adminConsentDescription,
|
|
329
|
+
userConsentDisplayName: scope.userConsentDisplayName ?? null,
|
|
330
|
+
userConsentDescription: scope.userConsentDescription ?? null,
|
|
331
|
+
};
|
|
332
|
+
const current = existing ? safeScope(existing) : null;
|
|
333
|
+
const noop = current !== null && equal({ ...current, userConsentDisplayName: current.userConsentDisplayName ?? null, userConsentDescription: current.userConsentDescription ?? null }, desired);
|
|
334
|
+
const identifierUris = strings(app.identifierUris);
|
|
335
|
+
return {
|
|
336
|
+
targetType: "application",
|
|
337
|
+
targetId: app.id,
|
|
338
|
+
targetLabel: app.displayName ?? app.id,
|
|
339
|
+
operation: existing ? "update_oauth2_scope" : "add_oauth2_scope",
|
|
340
|
+
// the whole collection is bound: a concurrent change to any scope invalidates the confirmation
|
|
341
|
+
before: { scopes: scopes.map(writableScope), api: apiKept(app), identifierUris },
|
|
342
|
+
change: {
|
|
343
|
+
scope: desired,
|
|
344
|
+
...(identifierUris.length === 0 ? { note: "the application has no identifier URI yet: add one (m365_entra_application_identifier_uris) so clients can request this scope" } : {}),
|
|
345
|
+
},
|
|
346
|
+
...(noop ? { noop: `scope ${scope.value} already matches` } : {}),
|
|
347
|
+
};
|
|
348
|
+
},
|
|
349
|
+
execute: async (plan) => {
|
|
350
|
+
const snapshot = (app) => ({ scopes: scopesOf(app).map(writableScope), api: apiKept(app), identifierUris: strings(app.identifierUris) });
|
|
351
|
+
const app = await stillAsPreviewed(ctx, plan.targetId, snapshot, plan.before);
|
|
352
|
+
const { scope: desired } = plan.change;
|
|
353
|
+
const scopes = scopesOf(app).map(writableScope);
|
|
354
|
+
const index = scopes.findIndex((s) => s.id === desired.id);
|
|
355
|
+
const next = index >= 0 ? scopes.map((s, i) => (i === index ? { ...s, ...desired } : s)) : [...scopes, desired];
|
|
356
|
+
// every api field is sent back as read (Graph may replace a complex property); only the target scope differs
|
|
357
|
+
const body = { api: { ...Object.fromEntries(Object.entries(apiKept(app)).filter(([, v]) => v !== null)), oauth2PermissionScopes: next } };
|
|
358
|
+
return [rid(await ctx.graph.request("PATCH", `/applications/${plan.targetId}`, { identity: "entra", body }))];
|
|
359
|
+
},
|
|
360
|
+
after: async (plan) => {
|
|
361
|
+
const before = plan.before;
|
|
362
|
+
const { scope: desired } = plan.change;
|
|
363
|
+
return verified(ctx, plan.targetId, (app) => {
|
|
364
|
+
const scopes = scopesOf(app).map(writableScope);
|
|
365
|
+
const target = scopes.find((s) => s.id === desired.id);
|
|
366
|
+
if (!target || !equal(safeScope({ ...target, userConsentDisplayName: target.userConsentDisplayName ?? null, userConsentDescription: target.userConsentDescription ?? null }), desired))
|
|
367
|
+
return false;
|
|
368
|
+
const others = scopes.filter((s) => s.id !== desired.id);
|
|
369
|
+
return equal(others, before.scopes.filter((s) => s.id !== desired.id)) && equal(apiKept(app), before.api);
|
|
370
|
+
});
|
|
371
|
+
},
|
|
372
|
+
}));
|
|
373
|
+
}
|
|
@@ -16,7 +16,7 @@ const spChangesSchema = z.object({
|
|
|
16
16
|
preferredSingleSignOnMode: z.enum(["password", "saml", "notSupported", "oidc"]).nullable().optional(),
|
|
17
17
|
tags: z.array(z.string().min(1).max(128)).max(20).optional(),
|
|
18
18
|
}).strict().refine((value) => Object.keys(value).length > 0, "at least one allowlisted property is required");
|
|
19
|
-
const same = (left, right) => JSON.stringify(left) === JSON.stringify(right);
|
|
19
|
+
export const same = (left, right) => JSON.stringify(left) === JSON.stringify(right);
|
|
20
20
|
const fields = (record, keys) => Object.fromEntries(keys.map((key) => [key, record[key] ?? null]));
|
|
21
21
|
const delta = (record, changes) => Object.fromEntries(Object.entries(changes).filter(([key, value]) => !same(record[key] ?? null, value)));
|
|
22
22
|
const matches = (record, changes) => Object.entries(changes).every(([key, value]) => same(record[key] ?? null, value));
|
|
@@ -36,7 +36,7 @@ async function ownedApplication(ctx, input, select = "id,appId,displayName") {
|
|
|
36
36
|
await assertOwned(ctx, app);
|
|
37
37
|
return app;
|
|
38
38
|
}
|
|
39
|
-
async function boundedAfter(ctx, read, ready) {
|
|
39
|
+
export async function boundedAfter(ctx, read, ready) {
|
|
40
40
|
let last = new M365Error("transient", "transient: post-write verification did not observe the requested state");
|
|
41
41
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
42
42
|
try {
|
|
@@ -2,11 +2,13 @@ import { z } from "zod";
|
|
|
2
2
|
import { GUID_RE } from "../config.js";
|
|
3
3
|
import { M365Error } from "../errors.js";
|
|
4
4
|
import { cursorParam, errorResult, formatParam, jsonBlock, limitParam, listPage, odataString, or, renderList, searchText, textResult, } from "./common.js";
|
|
5
|
-
export const APPLICATION_SELECT = "id,appId,uniqueName,displayName,description,signInAudience,publisherDomain,createdDateTime,disabledByMicrosoftStatus,notes,tags,requiredResourceAccess,keyCredentials";
|
|
5
|
+
export const APPLICATION_SELECT = "id,appId,uniqueName,displayName,description,signInAudience,publisherDomain,createdDateTime,disabledByMicrosoftStatus,notes,tags,requiredResourceAccess,keyCredentials,identifierUris,spa,web,api";
|
|
6
6
|
export const SERVICE_PRINCIPAL_SELECT = "id,appId,displayName,description,servicePrincipalType,accountEnabled,appOwnerOrganizationId,homepage,loginUrl,notificationEmailAddresses,preferredSingleSignOnMode,tags,keyCredentials";
|
|
7
7
|
const APPLICATION_LIST_SELECT = "id,appId,displayName,description,signInAudience,publisherDomain,createdDateTime,disabledByMicrosoftStatus,tags";
|
|
8
8
|
const SERVICE_PRINCIPAL_LIST_SELECT = "id,appId,displayName,description,servicePrincipalType,accountEnabled,appOwnerOrganizationId,homepage,loginUrl,preferredSingleSignOnMode,tags";
|
|
9
9
|
const MAX_NESTED = 20;
|
|
10
|
+
/** Bound of the redirect / identifier URI lists returned by the read projection. */
|
|
11
|
+
export const MAX_URIS_SHOWN = 50;
|
|
10
12
|
const ADVANCED = { ConsistencyLevel: "eventual" };
|
|
11
13
|
export const applicationParam = z.string().min(1).max(256).describe("Application object id, application/client id, or exact display name");
|
|
12
14
|
export const servicePrincipalParam = z.string().min(1).max(256).describe("Service principal object id, application/client id, or exact display name");
|
|
@@ -19,6 +21,55 @@ const safeKeys = (keys) => (keys ?? []).slice(0, MAX_NESTED).map(({ keyId, displ
|
|
|
19
21
|
usage,
|
|
20
22
|
customKeyIdentifier,
|
|
21
23
|
}));
|
|
24
|
+
/** Public metadata of one delegated scope exposed by an application (no consent, no grant). */
|
|
25
|
+
export const safeScope = (s) => ({
|
|
26
|
+
id: s.id,
|
|
27
|
+
value: s.value,
|
|
28
|
+
type: s.type,
|
|
29
|
+
isEnabled: s.isEnabled,
|
|
30
|
+
adminConsentDisplayName: s.adminConsentDisplayName,
|
|
31
|
+
adminConsentDescription: s.adminConsentDescription,
|
|
32
|
+
userConsentDisplayName: s.userConsentDisplayName,
|
|
33
|
+
userConsentDescription: s.userConsentDescription,
|
|
34
|
+
});
|
|
35
|
+
const uriList = (v) => (Array.isArray(v) ? v.filter((x) => typeof x === "string") : []);
|
|
36
|
+
const obj = (v) => (v && typeof v === "object" && !Array.isArray(v) ? v : undefined);
|
|
37
|
+
/**
|
|
38
|
+
* Bounded projection of the OAuth / OIDC configuration of an application: SPA and Web redirect URIs,
|
|
39
|
+
* identifier URIs and the public metadata of the delegated scopes it exposes. Only present when the
|
|
40
|
+
* record was read with these properties.
|
|
41
|
+
*/
|
|
42
|
+
export function safeOAuthConfig(a) {
|
|
43
|
+
if (!("identifierUris" in a) && !("spa" in a) && !("web" in a) && !("api" in a))
|
|
44
|
+
return {};
|
|
45
|
+
const spa = uriList(obj(a.spa)?.redirectUris);
|
|
46
|
+
const web = obj(a.web);
|
|
47
|
+
const webUris = uriList(web?.redirectUris);
|
|
48
|
+
const identifierUris = uriList(a.identifierUris);
|
|
49
|
+
const api = obj(a.api);
|
|
50
|
+
const scopes = Array.isArray(api?.oauth2PermissionScopes) ? api.oauth2PermissionScopes : [];
|
|
51
|
+
const truncated = [
|
|
52
|
+
spa.length > MAX_URIS_SHOWN ? "spa.redirectUris" : "",
|
|
53
|
+
webUris.length > MAX_URIS_SHOWN ? "web.redirectUris" : "",
|
|
54
|
+
identifierUris.length > MAX_URIS_SHOWN ? "identifierUris" : "",
|
|
55
|
+
scopes.length > MAX_NESTED ? "api.oauth2PermissionScopes" : "",
|
|
56
|
+
].filter(Boolean);
|
|
57
|
+
return {
|
|
58
|
+
identifierUris: identifierUris.slice(0, MAX_URIS_SHOWN),
|
|
59
|
+
spa: { redirectUris: spa.slice(0, MAX_URIS_SHOWN) },
|
|
60
|
+
web: {
|
|
61
|
+
redirectUris: webUris.slice(0, MAX_URIS_SHOWN),
|
|
62
|
+
homePageUrl: web?.homePageUrl ?? null,
|
|
63
|
+
logoutUrl: web?.logoutUrl ?? null,
|
|
64
|
+
implicitGrantSettings: web?.implicitGrantSettings ?? null,
|
|
65
|
+
},
|
|
66
|
+
api: {
|
|
67
|
+
requestedAccessTokenVersion: api?.requestedAccessTokenVersion ?? null,
|
|
68
|
+
oauth2PermissionScopes: scopes.slice(0, MAX_NESTED).map(safeScope),
|
|
69
|
+
},
|
|
70
|
+
...(truncated.length ? { oauthTruncated: { fields: truncated, uriLimit: MAX_URIS_SHOWN, scopeLimit: MAX_NESTED } } : {}),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
22
73
|
export const safeApplication = (a) => ({
|
|
23
74
|
id: a.id,
|
|
24
75
|
appId: a.appId,
|
|
@@ -33,6 +84,7 @@ export const safeApplication = (a) => ({
|
|
|
33
84
|
tags: Array.isArray(a.tags) ? a.tags.slice(0, MAX_NESTED) : a.tags,
|
|
34
85
|
requiredResourceAccess: (a.requiredResourceAccess ?? []).slice(0, MAX_NESTED).map((r) => ({ ...r, resourceAccess: (r.resourceAccess ?? []).slice(0, MAX_NESTED) })),
|
|
35
86
|
keyCredentials: safeKeys(a.keyCredentials),
|
|
87
|
+
...safeOAuthConfig(a),
|
|
36
88
|
});
|
|
37
89
|
export const safeServicePrincipal = (s) => ({
|
|
38
90
|
id: s.id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aidalinfo/m365-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Microsoft 365 MCP server over Microsoft Graph — Entra ID users, groups and applications, licences, Teams, SharePoint, usage reports, service health, roles, MFA, audit, access review, shared mailbox delegation (Exchange Online). Read-only by default; full mode uses separate scoped identities with two-step confirmed, audited writes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|