@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.
@@ -22,6 +22,7 @@ export const confirmParams = {
22
22
  */
23
23
  export async function runWrite(spec) {
24
24
  const { ctx, tool, approvalId } = spec;
25
+ const identity = spec.identity ?? "write";
25
26
  let plan;
26
27
  const requestIds = [];
27
28
  try {
@@ -29,14 +30,24 @@ export async function runWrite(spec) {
29
30
  throw new M365Error("refused", `refused: writes are disabled by the kill switch (${ctx.config.killSwitchFile} exists)`);
30
31
  }
31
32
  plan = await spec.plan();
32
- const binding = { tool, targetId: plan.targetId, state: plan.before, plan: plan.change };
33
+ const identityHandle = ctx.identities[identity];
34
+ if (!identityHandle)
35
+ throw new M365Error("refused", `refused: ${identity} identity is not loaded`);
36
+ const binding = {
37
+ tool,
38
+ identity: { role: identityHandle.role, clientId: identityHandle.clientId },
39
+ approvalId: approvalId ?? null,
40
+ targetId: plan.targetId,
41
+ state: plan.before,
42
+ plan: plan.change,
43
+ };
33
44
  const head = `Target: ${plan.targetType} ${plan.targetLabel} (${plan.targetId})\nOperation: ${plan.operation}`;
34
45
  if (plan.refuse) {
35
- ctx.audit.log({ tool, targetType: plan.targetType, targetId: plan.targetId, operation: plan.operation, result: "refused", errorCode: "refused", approvalId });
46
+ ctx.audit.log({ tool, targetType: plan.targetType, targetId: plan.targetId, operation: plan.operation, result: "refused", errorCode: "refused", approvalId, identity });
36
47
  return errorResult(new M365Error("refused", `refused: ${plan.refuse}`));
37
48
  }
38
49
  if (!spec.confirmToken) {
39
- ctx.audit.log({ tool, targetType: plan.targetType, targetId: plan.targetId, operation: plan.operation, result: "preview", approvalId });
50
+ ctx.audit.log({ tool, targetType: plan.targetType, targetId: plan.targetId, operation: plan.operation, result: "preview", approvalId, identity });
40
51
  if (plan.noop) {
41
52
  return textResult(`# Preview — ${tool}\n\n${head}\n\nNothing to do: ${plan.noop}\n\nCurrent state:\n${jsonBlock(plan.before)}`);
42
53
  }
@@ -51,18 +62,25 @@ export async function runWrite(spec) {
51
62
  throw new M365Error("refused", `refused: writes are disabled by the kill switch (${ctx.config.killSwitchFile} exists)`);
52
63
  }
53
64
  if (plan.noop) {
54
- ctx.audit.log({ tool, targetType: plan.targetType, targetId: plan.targetId, operation: plan.operation, result: "noop", approvalId });
65
+ ctx.audit.log({ tool, targetType: plan.targetType, targetId: plan.targetId, operation: plan.operation, result: "noop", approvalId, identity });
55
66
  return textResult(`# ${tool} — nothing to do\n\n${head}\n\n${plan.noop}\n\nState:\n${jsonBlock(plan.before)}`);
56
67
  }
57
68
  requestIds.push(...(await spec.execute(plan)));
58
69
  let afterText;
70
+ let result = "success";
59
71
  try {
60
72
  afterText = jsonBlock(await spec.after(plan));
61
73
  }
62
74
  catch (err) {
63
- afterText = `(could not re-read the target: ${toM365Error(err).code} — the change itself succeeded)`;
75
+ result = "success_unverified";
76
+ const verificationError = toM365Error(err);
77
+ afterText = `(could not re-read the target: ${verificationError.code} — the change succeeded but its resulting state is unverified)`;
78
+ ctx.audit.log({ tool, targetType: plan.targetType, targetId: plan.targetId, operation: plan.operation, result, errorCode: verificationError.code, graphRequestIds: requestIds, approvalId, identity });
79
+ if (spec.verificationRequired) {
80
+ return errorResult(new M365Error("transient", `transient: ${tool} changed the target but post-write verification failed; inspect the target before retrying`, { requestId: requestIds.filter(Boolean).at(-1) }));
81
+ }
64
82
  }
65
- ctx.audit.log({ tool, targetType: plan.targetType, targetId: plan.targetId, operation: plan.operation, result: "success", graphRequestIds: requestIds, approvalId });
83
+ ctx.audit.log({ tool, targetType: plan.targetType, targetId: plan.targetId, operation: plan.operation, result, graphRequestIds: requestIds, approvalId, identity });
66
84
  return textResult(`# ${tool} — done\n\n${head}\n\nBefore:\n${jsonBlock(plan.before)}\n\nAfter:\n${afterText}\n\nGraph request-id: ${requestIds.filter(Boolean).join(", ") || "—"}`);
67
85
  }
68
86
  catch (err) {
@@ -79,6 +97,7 @@ export async function runWrite(spec) {
79
97
  errorCode: e.code,
80
98
  graphRequestIds: requestIds,
81
99
  approvalId,
100
+ identity,
82
101
  });
83
102
  return errorResult(e);
84
103
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aidalinfo/m365-mcp",
3
- "version": "0.1.0",
4
- "description": "Microsoft 365 MCP server over Microsoft Graph — Entra ID users & groups, licences, Teams. Read-only by default; full mode uses a separate Entra write identity with two-step confirmed, audited writes",
3
+ "version": "0.3.0",
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. 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",
7
7
  "bin": {
@@ -9,7 +9,8 @@
9
9
  },
10
10
  "files": [
11
11
  "dist",
12
- "README.md"
12
+ "README.md",
13
+ "LICENSE"
13
14
  ],
14
15
  "publishConfig": {
15
16
  "access": "public"
@@ -32,7 +33,10 @@
32
33
  "entra-id",
33
34
  "teams",
34
35
  "licenses",
35
- "typescript"
36
+ "typescript",
37
+ "sharepoint",
38
+ "access-review",
39
+ "service-health"
36
40
  ],
37
41
  "scripts": {
38
42
  "build": "tsc",
@@ -43,8 +47,8 @@
43
47
  "smoke": "node smoke.mjs"
44
48
  },
45
49
  "dependencies": {
46
- "@modelcontextprotocol/sdk": "^1.27.0",
47
- "zod": "^4.4.3"
50
+ "@modelcontextprotocol/sdk": "^1.32.0",
51
+ "zod": "^4.6.5"
48
52
  },
49
53
  "devDependencies": {
50
54
  "@jest/globals": "^30.3.0",