mcpField
M
Microsoft 365 Admin

Microsoft 365 Admin

本地服务
github.com安全181 周前更新

关于 Microsoft 365 Admin

Microsoft 365 Admin 是面向管理员的 MCP 服务,通过 Microsoft Graph 执行安全、身份、合规和服务管理任务。它采用应用权限认证,默认只读;明确启用写入后,写操作会按风险分类。

主要功能

  1. 01674 个 Microsoft 365 管理工具
  2. 02应用权限认证
  3. 03默认只读模式
  4. 04写入工具的风险分类
  5. 05按领域筛选工具预设
  6. 06stdio 与 StreamableHTTP 传输

适用场景

  1. 01查看安全警报和事件
  2. 02审计身份、登录记录和访问权限
  3. 03管理 Intune 设备与合规性
  4. 04调查 Microsoft 365 服务及审计数据

MCP 相关

通过 stdio 或 StreamableHTTP 向 MCP 客户端提供 Microsoft Graph 管理工具。写入操作需显式启用 --allow-writes;预设和工具筛选器可缩小可用工具范围。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"okapi-ca-ms-365-admin": {
"command": "npx",
"args": [
"-y",
"@okapi-ca/ms-365-admin-mcp-server"
],
"env": {
"MS365_ADMIN_MCP_TENANT_ID": "<MS365_ADMIN_MCP_TENANT_ID>",
"MS365_ADMIN_MCP_CLIENT_ID": "<MS365_ADMIN_MCP_CLIENT_ID>",
"MS365_ADMIN_MCP_CLIENT_SECRET": "<MS365_ADMIN_MCP_CLIENT_SECRET>",
"MS365_ADMIN_MCP_KEYVAULT_URL": "<MS365_ADMIN_MCP_KEYVAULT_URL>",
"MS365_ADMIN_MCP_CLOUD_TYPE": "<MS365_ADMIN_MCP_CLOUD_TYPE>",
"MS365_ADMIN_MCP_MAX_TOP": "<MS365_ADMIN_MCP_MAX_TOP>",
"READ_ONLY": "<READ_ONLY>",
"ENABLED_TOOLS": "<ENABLED_TOOLS>"
}
}
}
}
启动命令npx -y @okapi-ca/ms-365-admin-mcp-server
需要配置的环境变量
MS365_ADMIN_MCP_TENANT_IDAzure AD tenant ID (specific GUID, not 'common').
MS365_ADMIN_MCP_CLIENT_IDApp registration client ID with the required application permissions.
MS365_ADMIN_MCP_CLIENT_SECRET密钥App registration client secret. Prefer Azure Key Vault via MS365_ADMIN_MCP_KEYVAULT_URL for production.
MS365_ADMIN_MCP_KEYVAULT_URL密钥Optional Azure Key Vault URL. When set, secrets are pulled from the vault and override the env-var values above.
MS365_ADMIN_MCP_CLOUD_TYPECloud environment: 'global' (default) or 'china' (21Vianet).
MS365_ADMIN_MCP_MAX_TOPCap on the $top query parameter to limit result size.
READ_ONLYSet to 'true' or '1' to force read-only mode (default behavior; mutations require --allow-writes).
ENABLED_TOOLSRegex to filter the catalog of available tools.

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@okapi-ca/ms-365-admin-mcp-server0.6.3

工具

329

收录的工具列表 · 更新于 2 周前

参数类型必填说明
topnumber否页面大小(Graph $top)。先从较小值(5-15)开始,以确保响应适合模型上下文。使用响应中的 @odata.nextLink 获取更多行。
skipstring否skip
countstring否count
expandstring否expand
filterstring否OData $filter 表达式,例如 status eq 'inProgress'
searchstring否search
selectstring否要返回的逗号分隔字段列表
orderbystring否orderby
excludeResponseboolean否排除完整响应正文,仅返回成功或失败

详细介绍

ms-365-admin-mcp-server

CI npm version License: MIT

一个通过 Graph API 应用权限(客户端凭据)管理 Microsoft 365 的模型上下文协议(MCP)服务。

它基于 Softeria/ms-365-mcp-server 开创的架构和端点驱动设计构建,并与之互补:Softeria 的服务使用委派权限,面向最终用户生产力场景;本服务则使用应用权限执行管理操作,包括安全监控、身份审计、事件响应和服务运行状况。请参阅下文的致谢。

功能

  • 674 个工具,涵盖安全、审计、身份、应用凭据、来宾用户、Exchange、Intune(设备、应用、MAM、报告、设置目录和终结点安全(BitLocker、Antivirus、Firewall、ASR)、加密报告、Windows 更新配置文件、BitLocker 和 LAPS 轮换、macOS 平台脚本、macOS 自定义属性脚本、分配筛选器、修正、Windows PowerShell 脚本、自定义合规性脚本)、治理(PIM、访问评审、权益管理、生命周期)、合规性、威胁情报、高级搜寻、Defender for Identity(传感器、候选项、迁移、身份帐户、审计策略)、Microsoft 365 Copilot 管理(使用情况报告、交互历史记录审计、AI 用户、会议见解、Agent 注册、策略设置)、自定义安全属性、LAPS、策略、报告、事件响应、eDiscovery v3(案例、数据保管人、非保管人数据源、评审集、查询、导出、操作)、Purview DSPM(保护范围)、基于事件的保留触发器、Teams 在线会议出席报告(仅应用模式,需使用 Application Access Policy)、已删除聊天恢复(管理员恢复流程)、Teams 聊天调查读取(用于分诊的 Chat.Read.All;用于可作为法庭证据的取证数据的 eDiscovery v3)、云电脑、通话记录、通用打印、信息保护、SharePoint 管理和记录管理
  • 应用权限(客户端凭据)——无需用户交互
  • 默认只读——写入操作需要显式指定 --allow-writes
  • 写入工具的风险分类(低/中/高/严重)
  • 预设,可按领域筛选工具(安全、审计、身份等)
  • 两种传输方式:stdio(默认)和 HTTP(StreamableHTTP)
  • 多云:Microsoft 全球云和中国云(21Vianet)
  • 支持使用 Key Vault 管理机密

文档

文档用途
docs/USE_CASES.md18 个典型管理场景,包含示例提示词和工具列表
docs/playbooks/端到端安全事件响应操作手册
agent-skills/面向大模型 Agent(如 Claude Code)的即插即用技能,包含安全模式
docs/APP_REGISTRATION.mdAzure AD 应用注册和权限授权的分步指南
docs/HTTP_DEPLOYMENT.mdHTTP 传输、JWT 验证、Docker、Azure Container Apps
docs/AZURE_DEPLOYMENT_SECURITY.mdAzure 生产环境部署的威胁模型、必要控制措施和检查清单
docs/TROUBLESHOOTING.md常见错误及其诊断方法
docs/ARCHITECTURE.md内部架构和代码生成流水线
docs/RISK_MODEL.md写入工具的风险分类标准
CONTRIBUTING.md如何贡献新工具、预设和修复
SECURITY.md漏洞报告和运维人员加固检查清单
CHANGELOG.md发布历史

先决条件

  • Node.js >= 18
  • Azure AD 应用注册,且具有应用程序权限(而非委托权限)
  • 特定的租户 ID(不能是 "common")

安装

npm(推荐)
npm install -g @okapi-ca/ms-365-admin-mcp-server
ms-365-admin-mcp-server --help
Docker
docker pull ghcr.io/okapi-ca/ms-365-admin-mcp-server:latest
docker run --rm -i \
  -e MS365_ADMIN_MCP_CLIENT_ID=... \
  -e MS365_ADMIN_MCP_CLIENT_SECRET=... \
  -e MS365_ADMIN_MCP_TENANT_ID=... \
  ghcr.io/okapi-ca/ms-365-admin-mcp-server:latest
从源代码安装
git clone https://github.com/okapi-ca/ms-365-admin-mcp-server.git
cd ms-365-admin-mcp-server
npm install
npm run generate
npm run build

配置

环境变量
变量必需说明
MS365_ADMIN_MCP_CLIENT_ID是应用注册客户端 ID
MS365_ADMIN_MCP_CLIENT_SECRET是应用注册客户端密钥
MS365_ADMIN_MCP_TENANT_ID是Azure AD 租户 ID(必须是特定租户)
MS365_ADMIN_MCP_CLOUD_TYPE否global(默认值)或 china
MS365_ADMIN_MCP_KEYVAULT_URL否Azure Key Vault URL(覆盖环境变量)
MS365_ADMIN_MCP_MAX_TOP否限制 $top 查询参数,以限制结果数量
READ_ONLY否true/1 强制设为只读(默认行为)
ENABLED_TOOLS否用于筛选可用工具的正则表达式
MCP 客户端配置(Claude Desktop 等)
{
  "mcpServers": {
    "ms365-admin": {
      "command": "node",
      "args": ["/path/to/ms-365-admin-mcp-server/dist/index.js"],
      "env": {
        "MS365_ADMIN_MCP_CLIENT_ID": "your-client-id",
        "MS365_ADMIN_MCP_CLIENT_SECRET": "your-client-secret",
        "MS365_ADMIN_MCP_TENANT_ID": "your-tenant-id"
      }
    }
  }
}
VS Code (1.102+)

VS Code 使用相同的 MCP 协议,但配置布局不同——使用 servers 而非 mcpServers,需要显式指定 type 字段,并使用 inputs 来 提示输入机密。可直接复制的示例位于 .vscode/mcp.json.example;将其复制到 .vscode/mcp.json,VS Code 首次启动时会提示输入租户 / 客户端 / 机密, 然后将它们存储在其机密存储中(实际的 mcp.json 已加入 gitignore,因此解析后的机密永远不会进入代码库)。

最简 stdio 配置:

{
  "inputs": [
    { "type": "promptString", "id": "ms365-tenant-id", "description": "Tenant ID" },
    { "type": "promptString", "id": "ms365-client-id", "description": "Client ID" },
    {
      "type": "promptString",
      "id": "ms365-client-secret",
      "description": "Client secret",
      "password": true,
    },
  ],
  "servers": {
    "ms365-admin": {
      "type": "stdio",
      "command": "ms-365-admin-mcp-server",
      "args": ["--preset", "security,audit,identity,health"],
      "env": {
        "MS365_ADMIN_MCP_TENANT_ID": "${input:ms365-tenant-id}",
        "MS365_ADMIN_MCP_CLIENT_ID": "${input:ms365-client-id}",
        "MS365_ADMIN_MCP_CLIENT_SECRET": "${input:ms365-client-secret}",
      },
    },
  },
}

对于远程 HTTP 部署,请使用带有 url 字段的 "type": "http"(VS Code 1.103+ 原生支持 OAuth 2.0 动态客户端注册),或者在原生浏览器流程不可用时 使用 mcp-remote 桥接;两种配置形式请参见示例文件。

工具会显示在 Agent 模式(GitHub Copilot Chat)中。VS Code 会要求 逐个批准工具;上面的 --preset 标志有助于控制工具目录的规模。 使用 Cmd/Ctrl+Shift+P → MCP: List Servers → Show Output 查看日志。

Claude.ai 界面的目录大小限制

Claude.ai、Claude Desktop 和云会话为每个连接器的工具设置了固定的 1 MiB 输入 架构预算(紧凑 JSON;不计入工具名称和描述)。工具按字母顺序纳入,放不下的工具 会被静默丢弃。Claude Code CLI 不受影响。 此限制尚未公开记录。

在关联到 Mac 的云会话中,claude-device 桥接会将每个本地 MCP 服务转发到同一个 连接器下(lcl-<server>-<tool>),因此所有本地服务共用该预算,而且此服务的工具排序 会排在其中大多数工具之后。

因此,请求体会以浅层形式公布(src/advertised-schema.ts): 实体自身的字段及其描述、作为自由格式对象的嵌套对象,以及不包含 Read-only. 字段。 Graph 会验证请求体;服务会按收到的内容原样转发。启用写入功能时,目录公布的输入 架构约为 595 KB;若超过 768 KiB,test/advertised-schema.test.ts 会导致构建失败。

如果云会话中仍有工具缺失,请缩减此服务公布的内容(只读模式、--preset、 --enabled-tools),禁用未使用的本地服务,或将此服务注册为独立连接器,使其拥有 自己的预算。

远程 HTTP 服务:device_code 身份验证(RFC 8628)

如果服务在远程主机(例如 Azure Container Apps)上以 HTTP / OAuth 模式运行,且客户端 通过 mcp-remote 连接,标准流程要求浏览器 能够访问 localhost:14543/oauth/callback。如果无法做到这一点——macOS Platform SSO 劫持 了 WebKit 流程、Claude Code 在无头 Docker 容器中运行,或用户身处远程 SSH 开发环境—— 请使用 ms-365-admin-mcp-auth 引导程序,预先填充 mcp-remote 的令牌缓存。

npx -p @okapi-ca/ms-365-admin-mcp-server@latest ms-365-admin-mcp-auth \
  --server https://your-mcp-host.azurecontainerapps.io/mcp

该辅助程序会输出一个 URL 和一个用户代码;你可以在任何可信设备(手机、另一台 笔记本电脑)上登录,令牌会写入 ~/.mcp-auth/mcp-remote-<version>/。Claude Desktop / Claude Code 随后会正常启动 mcp-remote,并找到缓存的令牌,无需打开浏览器。

Docker / 远程开发模式和退出代码参考,请参见 docs/TROUBLESHOOTING.md。

用法

CLI 选项
--read-only              Read-only mode (default)
--allow-writes           Enable write operations
--enabled-tools <regex>  Filter tools by regex pattern
--preset <names>         Use preset categories (comma-separated)
--partition <name>       Tool partition served on /mcp/<group> in HTTP mode (default: domains)
--list-presets           List available presets and exit
--list-tools             List available tools and exit
--list-permissions       List required Graph API permissions and exit
--verify-login           Test credentials against Graph API and exit
--cloud <type>           Cloud environment: global (default) or china
--transport <type>       Transport: stdio (default) or http
--port <number>          HTTP port (default: 8080)
--host <address>         HTTP bind address (default: 127.0.0.1)
--allowed-clients <ids>  Comma-separated Entra app IDs (required for HTTP)
-v                       Verbose logging
预设
# Security alerts and incidents only
node dist/index.js --preset security

# Identity management tools
node dist/index.js --preset identity

# Multiple presets
node dist/index.js --preset security,audit,identity
预设描述
security安全警报、事件、攻击模拟和威胁情报
audit目录审核、登录、预配日志、已删除项目
health服务运行状况和消息中心
reports使用情况报告(Teams、Email、SharePoint、OneDrive、Mailbox、M365 Apps)
identity用户、组、角色、设备、PIM、来宾用户、外部身份
exchangeExchange 管理(邮件跟踪、邮箱)
intune受管理设备、合规性、配置、Autopilot、应用、RBAC
governance访问评审、权利管理、生命周期工作流、使用条款
compliance许可证、安全评分、身份保护、风险检测、策略
response事件响应写入操作(禁用、撤销、确认、驳回)
ediscovery电子数据展示案例(Microsoft Purview)
cloudpcCloud PC / Windows 365(预配、映像、连接、设置、审核)
callrecordsTeams 通话记录
printUniversal Print(打印机、共享、连接器、服务、操作、任务)
infoprotection信息保护(BitLocker 恢复密钥、威胁评估)
sharepointadminSharePoint 租户管理设置
retention记录管理(保留标签、文件计划元数据)
all所有可用工具
验证凭据
node dist/index.js --verify-login

可用工具(674 个)

安全(11 个)
工具方法风险
list-security-alertsGET
get-security-alertGET
update-security-alertPATCH中
list-security-incidentsGET
get-security-incidentGET
update-security-incidentPATCH中
list-attack-simulationsGET
get-attack-simulationGET
create-attack-simulationPOST高
update-attack-simulationPATCH中
delete-attack-simulationDELETE中
审核日志和已删除项目(5 个)
工具方法
list-directory-auditsGET
list-sign-insGET
list-provisioning-logsGET
list-deleted-usersGET
list-deleted-groupsGET
服务运行状况(3 个)
工具方法
list-service-healthGET
list-service-issuesGET
list-service-messagesGET
使用情况报告(8 个)
工具方法
get-teams-activity-reportGET
get-email-activity-reportGET
get-active-users-reportGET
get-sharepoint-usage-reportGET
get-onedrive-usage-reportGET
get-active-user-counts-reportGET
get-mailbox-usage-reportGET
get-m365-apps-usage-reportGET
用户(9)
工具方法风险
list-usersGET
get-userGET
list-user-membershipsGET
list-user-auth-methodsGET
list-user-devicesGET
create-userPOST高
delete-userDELETE严重
assign-user-licensePOST中
reprocess-user-licensePOST低

没有通用的 update-user。此服务在 /users/{id} 上仅提供 disable-user-account 这一项 PATCH 操作(参见事件响应),其功能刻意限定为仅设置 accountEnabled,不做其他更改。

设备(2)
工具方法
list-devicesGET
get-deviceGET
组(11)
工具方法风险
list-groupsGET
get-groupGET
list-group-membersGET
list-group-ownersGET
create-groupPOST中
update-groupPATCH中
delete-groupDELETE严重
add-group-memberPOST中
remove-group-memberDELETE中
add-group-ownerPOST高
remove-group-ownerDELETE高

remove-group-member、add-group-owner 和 remove-group-owner 会运行预检防护规则:如果组是本地部署同步组、要从动态组中移除成员,或要移除组的唯一所有者,操作都会被拒绝。参见 docs/ARCHITECTURE.md。

目录角色与 PIM(9)
工具方法风险
list-directory-rolesGET
list-role-membersGET
list-role-assignmentsGET
list-role-definitionsGET
list-pim-eligible-assignmentsGET
list-pim-active-assignmentsGET
add-directory-role-memberPOST严重
delete-role-assignmentDELETE严重
remove-directory-role-memberDELETE严重

应优先使用 delete-role-assignment:list-role-assignments 配合 $filter=principalId eq '{user-id}' 已会返回所需的分配 ID。remove-directory-role-member 则适用于通过旧方式激活的角色。对于租户中最后一位活跃的全局管理员,两者都会无条件拒绝操作——这是防止锁定租户的防护规则,任何参数都无法覆盖。

管理单元(8)
工具方法风险
list-administrative-unitsGET
get-administrative-unitGET
list-administrative-unit-membersGET
create-administrative-unitPOST中
update-administrative-unitPATCH中
delete-administrative-unitDELETE高
add-administrative-unit-memberPOST中
remove-administrative-unit-memberDELETE高
条件访问(3)
工具方法
list-conditional-access-policiesGET
get-conditional-access-policyGET
list-named-locationsGET
应用与应用角色(11)
工具方法风险
list-applicationsGET
list-service-principalsGET
list-oauth2-grantsGET
list-user-app-role-assignmentsGET
list-sp-app-role-assignmentsGET
update-applicationPATCH高
delete-applicationDELETE严重
update-service-principalPATCH高
delete-oauth2-grantDELETE高
delete-sp-app-role-assignmentDELETE高
delete-user-app-role-assignmentDELETE高

delete-oauth2-grant 用于补救非法的授权许可:list-oauth2-grants 可识别此类许可,而此工具会撤销它。consentType: AllPrincipals 的许可会一次性撤销该应用对所有用户的委派访问权限——请先检查影响范围,并配合使用 revoke-user-sessions,因为撤销许可不会结束现有会话。

应用凭据与所有者(7)
工具方法
get-applicationGET
list-application-ownersGET
list-app-federated-credentialsGET
get-app-federated-credentialGET
get-service-principalGET
list-service-principal-ownersGET
list-sp-delegated-permissionsGET
应用管理策略(2)
工具方法
list-app-management-policiesGET
get-app-management-policyGET
组织与域(4)
工具方法风险
get-organizationGET
list-domainsGET
create-domainPOST高
verify-domainPOST中
许可证(2)
工具方法
list-subscribed-skusGET
get-subscribed-skuGET
安全评分(4)
工具方法
list-secure-scoresGET
get-secure-scoreGET
list-secure-score-controlsGET
get-secure-score-controlGET
身份保护与风险检测(7)
工具方法
list-risky-usersGET
get-risky-userGET
list-risky-user-historyGET
list-risky-service-principalsGET
get-risky-service-principalGET
list-risk-detectionsGET
get-risk-detectionGET
安全与访问策略(13)
工具方法风险
get-auth-methods-policyGET
list-auth-method-configsGET
get-auth-method-configGET
get-security-defaultsGET
get-admin-consent-policyGET
list-auth-strength-policiesGET
get-auth-strength-policyGET
create-auth-strength-policyPOST高
update-auth-strength-policyPATCH高
delete-auth-strength-policyDELETE高
get-cross-tenant-access-policyGET
list-cross-tenant-partnersGET
change-user-passwordPOST高
Guest user invitations (2)
ToolMethodRisk
list-invitationsGET
create-invitationPOSTmedium
External identity providers (2)
ToolMethod
list-identity-providersGET
get-identity-providerGET
Self-service sign-up (4)
ToolMethod
list-b2x-user-flowsGET
get-b2x-user-flowGET
list-api-connectorsGET
get-api-connectorGET
Custom authentication extensions (2)
ToolMethod
list-custom-auth-extensionsGET
get-custom-auth-extensionGET
Exchange message traces (2)
ToolMethod
list-message-tracesGET
get-message-traceGET
Exchange mailboxes (7)
ToolMethodRisk
list-exchange-mailboxesGET
get-exchange-mailboxGET
list-exchange-mailbox-foldersGET
get-exchange-mailbox-folderGET
export-exchange-mailbox-itemsPOSTmedium
update-exchange-mailboxPATCHmedium
delete-exchange-mailboxDELETEcritical
Threat intelligence - hosts (4)
ToolMethod
list-threat-intel-hostsGET
get-threat-intel-hostGET
get-threat-intel-host-whoisGET
list-threat-intel-host-pairsGET
Threat intelligence - articles & profiles (6)
ToolMethod
list-threat-intel-articlesGET
get-threat-intel-articleGET
list-threat-intel-article-indicatorsGET
list-threat-intel-profilesGET
get-threat-intel-profileGET
list-threat-intel-profile-indicatorsGET
Threat intelligence - vulnerabilities & WHOIS (4)
ToolMethod
list-threat-intel-vulnerabilitiesGET
get-threat-intel-vulnerabilityGET
list-threat-intel-whois-recordsGET
get-threat-intel-whois-recordGET
Threat intelligence - infrastructure (2)
ToolMethod
list-threat-intel-host-componentsGET
list-threat-intel-ssl-certsGET
Managed devices (8)
ToolMethodRisk
list-managed-devicesGET
get-managed-devices-by-namesGET
get-managed-deviceGET
get-windows-protection-stateGET
list-device-compliance-statesGET
list-device-configuration-statesGET
get-managed-device-overviewGET
delete-managed-deviceDELETEcritical
Compliance policies (5)
ToolMethod
list-compliance-policiesGET
get-compliance-policyGET
list-compliance-policy-device-statusesGET
get-compliance-policy-status-overviewGET
get-compliance-state-summaryGET
设备配置(4)
工具方法
list-device-configurationsGET
get-device-configurationGET
get-device-configuration-status-overviewGET
list-device-configuration-device-statusesGET
设置目录和 Endpoint security(6)

设置目录策略,包括所有现代 Endpoint security 策略(磁盘加密 / BitLocker、Antivirus、Firewall、Attack surface reduction、EDR、Account protection)。针对 Graph beta——configurationPolicies 没有对应的 v1.0 版本。这两个报告操作使用 POST,但只读取数据;和其他 Intune 报告一样,它们需要 --allow-writes。

工具方法风险
list-configuration-policiesGET
get-configuration-policyGET
list-configuration-policy-settingsGET
list-configuration-policy-templatesGET
get-configuration-policy-device-statusPOST低
get-configuration-policy-device-summaryPOST低
Endpoint security 意图(旧版模板)(4)

迁移到设置目录之前创建的基于模板的 Endpoint security 策略。**针对 Graph beta。**Endpoint security 审计必须同时涵盖这些策略和设置目录策略。

工具方法
list-intentsGET
get-intentGET
list-intent-device-statesGET
list-intent-templatesGET
设备加密(1)

Intune 加密报告:就绪状态、状态、TPM 版本,以及已应用到各设备的 BitLocker / FileVault 策略。针对 Graph beta。

工具方法
list-managed-device-encryption-statesGET
Windows Update 配置文件(3)

功能更新和质量更新配置文件,它们会覆盖设备的 Windows Update for Business 更新环中的延迟设置(更新环本身属于设备配置)。针对 Graph beta。

工具方法
list-windows-feature-update-profilesGET
list-windows-quality-update-profilesGET
list-windows-quality-update-policiesGET
macOS 平台脚本(6)

部署到受管理 macOS 设备的 Intune Shell 脚本。针对 Graph beta(/beta/deviceManagement/deviceShellScripts)——Microsoft 从未将此端点升级到 v1.0。需要 DeviceManagementScripts.ReadWrite.All。

工具方法风险
list-device-shell-scriptsGET
get-device-shell-scriptGET
create-device-shell-scriptPOST中
update-device-shell-scriptPATCH中
delete-device-shell-scriptDELETE高
assign-device-shell-scriptPOST中

说明:

  • scriptContent 必须是脚本内容的严格 base64 编码(非 URL 安全编码),且脚本使用 LF 换行符——CRLF 会导致脚本无法在 Mac 上执行。
  • 对于与用户会话交互的脚本(例如使用 osascript 操作 System Events),必须设置 runAsAccount=user。
  • assign-device-shell-script 会替换所有现有分配,而非追加。若要添加组且不移除其他组,请先 GET 当前分配,追加新目标,然后 POST 完整的合并列表。
  • 默认情况下,get-device-shell-script 不会返回 scriptContent;传入 $select=id,displayName,scriptContent,... 以获取 base64 正文。
Intune 修正 / 主动修正 (8)

用于 Windows 10/11 Azure AD 加入设备的检测与修正配对 PowerShell 脚本。目标为 Graph beta(/beta/deviceManagement/deviceHealthScripts)。需要 DeviceManagementScripts.ReadWrite.All。

工具方法风险
list-device-health-scriptsGET
get-device-health-scriptGET
list-device-health-script-run-statesGET
get-device-health-script-run-summaryGET
create-device-health-scriptPOST中
update-device-health-scriptPATCH中
delete-device-health-scriptDELETE高
assign-device-health-scriptPOST中

说明:

  • detectionScriptContent 和 remediationScriptContent 都是 经过 base64 编码的 PowerShell——脚本先以 UTF-8 编码,再进行 base64 编码。
  • 检测脚本返回退出代码 0(符合要求)或 1(需要修正)。只有检测脚本返回 1 时才会运行修正脚本。
  • assign-device-health-script 会替换所有现有分配——计划可以设为每日 / 每小时 / 运行一次。对于仅检测部署,请将 runRemediationScript: false。
  • 默认情况下,get-device-health-script 不会返回脚本正文;请传入 $select=id,displayName,detectionScriptContent,remediationScriptContent,...。
  • 对于 Windows“验证 + 修复”用例(CIS 加固、Agent 安装验证、服务状态),这是 deviceShellScripts 的现代替代方案。
分配筛选器 (5)

动态成员资格筛选器,用于将策略 / 应用分配范围限定到 Entra 组的子集。目标为 Graph beta(/beta/deviceManagement/assignmentFilters)。需要 DeviceManagementConfiguration.ReadWrite.All。

工具方法风险
list-assignment-filtersGET
get-assignment-filterGET
create-assignment-filterPOST中
update-assignment-filterPATCH中
delete-assignment-filterDELETE高

说明:

  • 规则语法类似 KQL,作用于设备属性——例如,(device.osVersion -startsWith "14") 表示仅限 macOS Sonoma,(device.deviceOwnership -eq "Corporate") 表示公司拥有的设备。
  • 运算符:-eq、-ne、-startsWith、-contains、-in、-matches,可用 -and / -or 连接。
  • 筛选器由 deviceConfigurations / mobileApps / deviceCompliancePolicies 分配引用(不直接针对用户——先将分配目标设为一个组,再添加筛选器以缩小范围)。
  • assignmentFilterManagementType:设备范围分配使用 devices,应用范围分配使用 apps(部分属性有所不同)。
  • 删除正在使用的筛选器时,依赖它的分配会静默回退为“组中的所有成员”——删除前请审核分配。
macOS 自定义属性 Shell 脚本(6)

Intune Shell 脚本,其标准输出会作为命名自定义属性存储在每台设备上——适用于展示清单数据(FileVault、Gatekeeper、加密标记、自定义标记)以及驱动动态组筛选器。目标为 Graph beta(/beta/deviceManagement/deviceCustomAttributeShellScripts)。需要 DeviceManagementScripts.ReadWrite.All。

工具方法风险
list-device-custom-attribute-shell-scriptsGET
get-device-custom-attribute-shell-scriptGET
create-device-custom-attribute-shell-scriptPOST中
update-device-custom-attribute-shell-scriptPATCH中
delete-device-custom-attribute-shell-scriptDELETE高
assign-device-custom-attribute-shell-scriptPOST中

注意:

  • 脚本的标准输出会成为每台设备上存储在 customAttributeName 下的值。
  • customAttributeType 控制 Intune 如何解析标准输出:integer、string 或 dateTime(ISO 8601)。
  • scriptContent 必须是采用 LF 换行符的脚本的严格 base64 编码——CRLF 会导致脚本在 Mac 上无法执行。
  • 部署后更改 customAttributeName 或 customAttributeType,会破坏引用旧键的下游动态组和分配筛选器——请先审查引用。
  • 删除脚本不会清除设备记录中此前收集的属性值。
Windows PowerShell 脚本(deviceManagementScripts)(6)

一次性 PowerShell 脚本,部署到受管理的 Windows 10/11 设备。每台设备每次分配运行一次,失败时会重试。如需检测并修复模式,请改用 deviceHealthScripts(Remediations)。目标为 Graph beta(/beta/deviceManagement/deviceManagementScripts)。需要 DeviceManagementScripts.ReadWrite.All。

工具方法风险
list-device-management-scriptsGET
get-device-management-scriptGET
create-device-management-scriptPOST中
update-device-management-scriptPATCH中
delete-device-management-scriptDELETE高
assign-device-management-scriptPOST中

注意:

  • scriptContent 是 UTF-8 PowerShell 脚本的 base64 编码。
  • 分配后,会在下一次 Intune Management Extension 同步时于每台设备上运行一次——成功执行后不会再次运行(重复执行模式请使用 deviceHealthScripts)。
  • 更新 scriptContent 不会在已成功运行的设备上重新运行;如需强制重新执行,请删除后重新创建。
  • enforceSignatureCheck=true 要求脚本经过代码签名(生产环境建议启用)。
  • runAs32Bit=true 会在 64 位 Windows 上强制使用 32 位 PowerShell(很少需要)。
Windows 自定义合规性脚本(deviceComplianceScripts)(6)

PowerShell 脚本,会在 STDOUT 上输出一个 JSON 对象,并根据关联的 windows10CustomComplianceConfiguration 策略中声明的规则进行评估——用于提供组织特定的合规性信号,补充内置的 BitLocker / Defender / 防火墙检查。目标为 Graph beta(/beta/deviceManagement/deviceComplianceScripts)。需要 DeviceManagementScripts.ReadWrite.All。

工具方法风险
list-device-compliance-scriptsGET
get-device-compliance-scriptGET
create-device-compliance-scriptPOST中
update-device-compliance-scriptPATCH中
delete-device-compliance-scriptDELETE高
assign-device-compliance-scriptPOST中

注意:

  • detectionScriptContent 必须在 STDOUT 上输出一个 JSON 对象(例如,ConvertTo-Json -Compress @{BitLockerEnabled=$true;TpmReady=$true})。
  • 脚本本身不会影响合规性——你还必须编写一个规则相匹配的 windows10CustomComplianceConfiguration 策略。
  • 如果更改 JSON 键却不更新关联策略中的规则,合规性评估会悄然失效。
  • 删除正在使用的脚本,会导致引用它的合规性策略在设备下次签入时评估失败。
  • 分配结构沿用 deviceHealthScriptAssignment(将 runRemediationScript 设为 false,因为合规性脚本没有对应的修正脚本)。
注册与 Autopilot(10)
工具方法风险
list-enrollment-configurationsGET
get-enrollment-configurationGET
list-autopilot-devicesGET
get-autopilot-deviceGET
create-enrollment-configurationPOST中
update-enrollment-configurationPATCH中
delete-enrollment-configurationDELETE高
update-autopilot-devicePATCH中
delete-autopilot-deviceDELETE高
import-autopilot-devicePOST中
已检测到的应用(3)
工具方法
list-detected-appsGET
get-detected-appGET
list-detected-app-devicesGET
Intune RBAC 与配置(7)
工具方法
list-intune-audit-eventsGET
get-software-update-summaryGET
get-apple-push-certificateGET
list-intune-role-definitionsGET
list-intune-role-assignmentsGET
list-intune-terms-and-conditionsGET
list-intune-terms-acceptancesGET
Intune 连接器与更新(3)
工具方法
get-intune-conditional-access-settingsGET
list-mtd-connectorsGET
list-ios-update-statusesGET
设备类别(1)
工具方法
list-device-categoriesGET
访问评审(5)
工具方法
list-access-review-definitionsGET
get-access-review-definitionGET
list-access-review-instancesGET
get-access-review-instanceGET
list-access-review-decisionsGET
权限管理(7)
工具方法
list-access-packagesGET
get-access-packageGET
list-access-package-assignmentsGET
list-access-package-requestsGET
list-access-package-catalogsGET
list-connected-organizationsGET
get-entitlement-management-settingsGET
生命周期工作流(3)
工具方法
list-lifecycle-workflowsGET
get-lifecycle-workflowGET
list-lifecycle-task-definitionsGET
群组 PIM(2)
工具方法
list-pim-group-assignment-schedulesGET
list-pim-group-eligibility-schedulesGET
使用条款(3)
工具方法
list-terms-of-use-agreementsGET
get-terms-of-use-agreementGET
list-terms-of-use-acceptancesGET
应用同意请求(3)
工具方法
list-app-consent-requestsGET
get-app-consent-requestGET
list-user-consent-requestsGET
事件响应(17)——需要 --allow-writes
工具方法风险
disable-user-accountPATCH严重
revoke-user-sessionsPOST高
add-security-alert-commentPOST低
update-devicePATCH高
confirm-compromised-usersPOST高
dismiss-risky-usersPOST高
delete-user-phone-auth-methodDELETE高
delete-user-fido2-auth-methodDELETE高
delete-user-authenticator-auth-methodDELETE高
delete-user-software-oath-auth-methodDELETE高
delete-user-windows-hello-auth-methodDELETE高
delete-user-email-auth-methodDELETE高
delete-user-temporary-access-pass-auth-methodDELETE高
confirm-compromised-service-principalsPOST高
dismiss-risky-service-principalsPOST高
confirm-safe-usersPOST高
run-hunting-queryPOST低

每种身份验证方法集合对应一个删除工具,因为 ID 的作用域限定在各自集合内,不能互换。请先运行 list-user-auth-methods,然后根据 @odata.type 进行匹配,以选择正确的工具和 ID。如果该方法是用户仅剩的 MFA 因素,且 MFA 为必需项,Graph 将拒绝删除。

Intune 设备远程操作 (18) -- 需要 --allow-writes
工具方法风险
wipe-managed-devicePOST严重
retire-managed-devicePOST高
sync-managed-devicePOST低
reboot-managed-devicePOST高
remote-lock-devicePOST中
reset-device-passcodePOST高
shutdown-managed-devicePOST高
disable-lost-modePOST低
locate-managed-devicePOST低
bypass-activation-lockPOST高
trigger-defender-scanPOST低
update-defender-signaturesPOST低
rotate-bitlocker-keysPOST中
rotate-local-admin-passwordPOST中
clean-windows-devicePOST严重
logout-shared-apple-userPOST中
delete-shared-apple-userPOST高
update-windows-device-accountPOST中
条件访问 CRUD (7) -- 需要 --allow-writes
工具方法风险
list-conditional-access-templatesGET
create-conditional-access-policyPOST高
update-conditional-access-policyPATCH高
delete-conditional-access-policyDELETE严重
create-named-locationPOST中
update-named-locationPATCH中
delete-named-locationDELETE高
Intune 策略 CRUD (8) -- 需要 --allow-writes
工具方法风险
create-compliance-policyPOST中
update-compliance-policyPATCH中
assign-compliance-policyPOST高
delete-compliance-policyDELETE高
create-device-configurationPOST中
update-device-configurationPATCH中
assign-device-configurationPOST高
delete-device-configurationDELETE高
设置目录和 Endpoint security CRUD (4) -- 需要 --allow-writes

目标为 Graph beta。 需要 DeviceManagementConfiguration.ReadWrite.All。assign-configuration-policy 会替换整个分配列表。

工具方法风险
create-configuration-policyPOST中
update-configuration-policyPATCH中
delete-configuration-policyDELETE高
assign-configuration-policyPOST高
Endpoint security 意图 CRUD (4) -- 需要 --allow-writes

目标为 Graph beta。 需要 DeviceManagementConfiguration.ReadWrite.All。assign-intent 会替换整个分配列表。

工具方法风险
update-intentPATCH中
update-intent-settingsPOST中
delete-intentDELETE高
assign-intentPOST高
OneDrive / 用户驱动器(DSAR 枚举)(4)

只读遍历用户的个人驱动器,用于数据主体访问请求。不会公开内容字节;这些工具返回元数据和下载 URL。

工具方法风险
get-user-driveGET
get-drive-rootGET
list-drive-childrenGET
get-drive-itemGET
Purview DSPM(保护范围)(2)
工具方法风险
get-data-security-governance-rootGET
compute-protection-scopesPOSTlow

compute-protection-scopes 是 POST 请求,但只进行计算,不会修改数据,因此风险等级为 low。仍需使用 --allow-writes。

Teams 在线会议出席记录(4)

查看特定用户会议的出席记录。仅应用访问需要在租户上配置应用程序访问策略,并通过 Set-CsApplicationAccessPolicy 按服务主体授予权限;若未配置,无论 Graph 权限如何,Graph 都会返回 403。

工具方法风险
get-user-online-meetingGET
list-user-meeting-attendance-reportsGET
get-user-meeting-attendance-reportGET
list-user-meeting-attendance-recordsGET
Teams 已删除聊天(3)
工具方法风险
list-deleted-chatsGET
get-deleted-chatGET
undo-delete-chatPOSTmedium

用于恢复用户删除的聊天的管理流程。保留期限由 Microsoft 决定,无法在此配置。

Teams 聊天调查读取(5)

读取用户聊天以进行分诊,需要 Chat.Read.All。对于可作为法庭证据的生产用途,请改用电子取证工具——这些读取不具备监管链。

工具方法风险
list-user-chatsGET
get-chatGET
list-chat-membersGET
list-chat-messagesGET
get-chat-messageGET
Teams 通话记录(11)
工具方法
list-call-recordsGET
get-call-recordGET
list-call-record-sessionsGET
get-call-record-sessionGET
list-call-session-segmentsGET
get-call-session-segmentGET
list-call-record-participantsGET
get-call-record-participantGET
get-call-record-organizerGET
get-pstn-callsGET
get-direct-routing-callsGET
Cloud PC / Windows 365(10)
工具方法风险
list-cloud-pcsGET
list-cloud-pc-provisioning-policiesGET
list-cloud-pc-device-imagesGET
list-cloud-pc-gallery-imagesGET
list-cloud-pc-on-premises-connectionsGET
list-cloud-pc-user-settingsGET
list-cloud-pc-audit-eventsGET
create-cloud-pc-provisioning-policyPOSTmedium
update-cloud-pc-provisioning-policyPATCHmedium
delete-cloud-pc-provisioning-policyDELETEhigh
Universal Print(6)
工具方法风险
list-printersGET
list-print-sharesGET
list-print-connectorsGET
list-print-servicesGET
list-print-operationsGET
list-print-task-definitionsGET
信息保护与敏感度标签(7)
工具方法
list-bitlocker-recovery-keysGET
list-threat-assessment-requestsGET
list-sensitivity-labelsGET
get-sensitivity-labelGET
list-sensitivity-sublabelsGET
get-sensitivity-label-rightsGET
get-protection-scopesGET
SharePoint 管理(25)
工具方法风险
get-sharepoint-settingsGET
list-sharepoint-sitesGET
get-sharepoint-siteGET
update-sharepoint-sitePATCH中
list-site-drivesGET
get-site-default-driveGET
list-site-listsGET
get-site-listGET
create-site-listPOST低
update-site-listPATCH低
delete-site-listDELETE高
list-site-list-itemsGET
create-site-list-itemPOST低
update-site-list-itemPATCH低
delete-site-list-itemDELETE中
list-site-list-columnsGET
list-site-columnsGET
list-site-content-typesGET
list-site-permissionsGET
get-site-permissionGET
create-site-permissionPOST中
update-site-permissionPATCH中
delete-site-permissionDELETE高
get-site-analyticsGET
list-site-subsitesGET
记录管理(9)
工具方法风险
list-file-plan-authoritiesGET
list-file-plan-categoriesGET
list-file-plan-citationsGET
list-file-plan-departmentsGET
list-file-plan-referencesGET
get-retention-eventGET
create-retention-eventPOST中
get-retention-event-typeGET
create-retention-event-typePOST中

不支持列出或读取 retentionLabels:Microsoft Graph 不支持使用应用程序权限执行此操作。请使用委托访问权限或 Security & Compliance PowerShell。list-retention-events 位于安全高级功能下。

Teams administration (33)
ToolMethodRisk
list-teamsGET
create-teamPOSTmedium
get-teamGET
update-teamPATCHmedium
delete-teamDELETEcritical
list-team-admin-channelsGET
create-team-admin-channelPOSTlow
get-team-admin-channelGET
delete-team-admin-channelDELETEhigh
list-team-admin-membersGET
add-team-admin-membersPOSTmedium
remove-team-admin-membersPOSTmedium
get-team-admin-memberGET
list-team-installed-appsGET
archive-teamPOSTmedium
unarchive-teamPOSTlow
clone-teamPOSTmedium
list-team-operationsGET
list-team-permission-grantsGET
get-teams-app-settingsGET
update-teams-app-settingsPATCHhigh
list-deleted-teamsGET
list-teams-catalog-appsGET
get-teams-catalog-appGET
list-teams-app-definitionsGET
get-teams-admin-settingsGET
list-teams-user-configurationsGET
get-teams-admin-policyGET
list-teams-policy-assignmentsGET
list-teams-phone-assignmentsGET
assign-teams-phone-numberPOSTmedium
unassign-teams-phone-numberPOSThigh
get-teams-phone-number-operationGET
Intune reports (18) -- requires --allow-writes (POST endpoints)
ToolMethodRisk
intune-device-noncompliance-reportPOSTlow
intune-compliance-policy-noncompliance-reportPOSTlow
intune-compliance-policy-noncompliance-summaryPOSTlow
intune-compliance-setting-noncompliance-reportPOSTlow
intune-config-policy-noncompliance-reportPOSTlow
intune-config-policy-noncompliance-summaryPOSTlow
intune-config-setting-noncompliance-reportPOSTlow
intune-devices-without-compliance-reportPOSTlow
intune-noncompliant-devices-settings-reportPOSTlow
intune-policy-noncompliance-reportPOSTlow
intune-policy-noncompliance-summaryPOSTlow
intune-policy-noncompliance-metadataPOSTlow
intune-setting-noncompliance-reportPOSTlow
intune-report-filtersPOSTlow
intune-historical-reportPOSTlow
intune-cached-reportPOSTlow
list-intune-report-export-jobsGET
intune-device-app-install-status-reportPOSTlow
Intune partners & infrastructure (10)
ToolMethodRisk
list-compliance-management-partnersGET
list-device-management-partnersGET
list-exchange-connectorsGET
list-remote-assistance-partnersGET
list-notification-message-templatesGET
list-intune-resource-operationsGET
list-imported-autopilot-devicesGET
list-windows-malware-infoGET
list-intune-mobile-appsGET
list-intune-app-categoriesGET
Intune app management (11)
ToolMethodRisk
list-intune-app-configurationsGET
list-managed-app-policiesGET
list-managed-app-registrationsGET
list-managed-app-statusesGET
list-android-app-protectionsGET
list-ios-app-protectionsGET
list-default-app-protectionsGET
list-targeted-app-configurationsGET
list-mdm-wip-policiesGET
list-mam-wip-policiesGET
list-vpp-tokensGET
Advanced policies (15)
ToolMethodRisk
list-activity-timeout-policiesGET
get-authorization-policyGET
get-auth-flows-policyGET
list-claims-mapping-policiesGET
list-conditional-access-policies-v2GET
get-default-app-management-policyGET
get-device-registration-policyGET
list-feature-rollout-policiesGET
list-home-realm-discovery-policiesGET
list-permission-grant-policiesGET
list-role-management-policiesGET
list-role-management-policy-assignmentsGET
list-token-issuance-policiesGET
list-token-lifetime-policiesGET
get-cross-tenant-default-policyGET
Identity Governance+ (11)
ToolMethodRisk
list-entitlement-assignment-policiesGET
list-entitlement-resourcesGET
list-entitlement-resource-environmentsGET
list-lifecycle-workflow-templatesGET
get-lifecycle-workflow-settingsGET
list-lifecycle-custom-task-extensionsGET
list-deleted-lifecycle-workflowsGET
list-pim-group-assignment-requestsGET
list-pim-group-assignment-instancesGET
list-pim-group-eligibility-requestsGET
list-pim-group-eligibility-instancesGET
PIM role management (6)
ToolMethodRisk
list-access-review-historyGET
list-pim-role-assignment-requestsGET
list-pim-role-assignment-schedulesGET
list-pim-role-eligibility-requestsGET
list-pim-role-eligibility-schedulesGET
list-role-resource-namespacesGET
Identity Protection+ (1)
ToolMethodRisk
list-service-principal-risk-detectionsGET
Security advanced (9)
ToolMethodRisk
list-retention-eventsGET
list-retention-event-typesGET
list-subject-rights-requestsGET
list-simulation-automationsGET
list-simulation-trainingsGET
list-simulation-payloadsGET
list-simulation-end-user-notificationsGET
list-simulation-landing-pagesGET
list-simulation-login-pagesGET
Defender for Identity(24)

通过 Graph 全面覆盖 Microsoft Defender for Identity(DfI)管理:传感器、传感器候选项(自动发现)、将传感器迁移到统一的 Defender XDR 架构、身份帐户(通过 invokeAction 对 AD 本地部署 / Okta 执行应急操作)、审核策略强制执行和运行状况警报。大多数端点为 Graph v1.0;sensorMigration 仅限 beta。

工具方法风险
list-identity-health-issuesGET
get-identity-health-issueGET
list-sensor-health-issuesGET
get-sensor-health-issueGET
list-identity-sensorsGET
get-identity-sensorGET
update-identity-sensorPATCH中
get-sensor-deployment-access-keyGET
get-sensor-deployment-package-uriGET
regenerate-sensor-deployment-access-keyPOST高
list-sensor-candidatesGET
get-sensor-candidateGET
get-sensor-candidate-activation-configGET
update-sensor-candidate-activation-configPATCH中
activate-sensor-candidatesPOST中
list-sensor-migrationsGET
get-sensor-migrationGET
migrate-sensorsPOST高
get-identity-security-settingsGET
get-auto-auditing-configGET
update-auto-auditing-configPATCH中
list-identity-accountsGET
get-identity-accountGET
invoke-identity-account-actionPOST严重

说明:

  • invoke-identity-account-action 是影响最大的写入操作——对源系统(AD 本地部署、Okta)中的帐户执行身份响应操作(disable、enable、forcePasswordReset、revokeAllSessions、requireUserToSignInAgain、markUserAsCompromised)。操作与提供程序的兼容性:disable/enable 适用于 AD + Okta,forcePasswordReset 仅适用于 AD,revokeAllSessions 仅适用于 Okta。
  • regenerate-sensor-deployment-access-key 会立即使之前的密钥失效——调用前请与负责部署新传感器的人员协调。
  • migrate-sensors 会在迁移到统一的 Defender XDR 期间重启目标 DC 上的传感器服务——会造成短暂的采集间断(约几分钟)。请为生产 DC 安排维护时段。仅限 beta。
  • activate-sensor-candidates 会通过部署访问密钥流程,在检测到的主机上触发传感器安装。请先通过 get-sensor-candidate 验证——错误的 serverId 会导致传感器安装到错误的主机上。
  • 在 update-auto-auditing-config 中设置 enabled=true 后,DfI 会在每台传感器主机上强制执行建议的 Windows 高级审核策略(下次心跳时还原本地管理员覆盖设置)——建议在生产环境中启用。

自 v0.10.0 / 0.11.1 起所需的新 Graph 权限(必须在应用注册中授予同意):

  • SecurityIdentitiesSensors.Read.All + SecurityIdentitiesSensors.ReadWrite.All(传感器管理)
  • SecurityIdentitiesAutoConfig.Read.All + SecurityIdentitiesAutoConfig.ReadWrite.All(autoAuditingConfiguration)
  • SecurityIdentitiesAccount.Read.All(identityAccounts 列表 / 获取)
  • SecurityIdentitiesActions.ReadWrite.All(identityAccounts invokeAction——应急操作)
  • SecurityIdentitiesMigration.Read.All + SecurityIdentitiesMigration.ReadWrite.All(sensorMigration,beta)
威胁情报+(6)
工具方法风险
list-passive-dns-recordsGET
list-ssl-certificatesGET
list-threat-intel-subdomainsGET
list-threat-intel-host-portsGET
list-threat-intel-host-trackersGET
list-threat-intel-host-cookiesGET
报告+(5)
工具方法风险
list-user-registration-detailsGET
list-daily-print-usage-by-printerGET
list-daily-print-usage-by-userGET
list-monthly-print-usage-by-printerGET
list-monthly-print-usage-by-userGET
Copilot 管理(15)

设置和策略:

工具方法风险
get-copilot-admin-settingsGET
get-copilot-limited-modeGET
list-copilot-policy-settingsGET
get-copilot-policy-settingGET

使用情况报告:

工具方法风险
get-copilot-usage-user-detailGET
get-copilot-user-count-summaryGET
get-copilot-user-count-trendGET

交互历史审计、AI 用户和会议洞察:

工具方法风险
get-all-copilot-interactionsGET
get-user-copilot-interactionsGET
list-ai-usersGET
get-ai-userGET
list-ai-user-online-meetingsGET
list-ai-meeting-insightsGET
get-ai-meeting-insightGET

Agent 注册:

工具方法风险
get-copilot-agent-registrationGET

get-all-copilot-interactions 会返回租户中所有企业 Copilot 交互记录——提示词和响应。请将输出视为受监管的个人数据。

目录+(5)
工具方法风险
list-attribute-setsGET
list-custom-security-attributesGET
list-device-local-credentialsGET
list-federation-configurationsGET
list-on-premises-syncGET
应用程序凭据和所有者 CRUD(11)-- 需要 --allow-writes
工具方法风险
create-applicationPOSThigh
add-application-passwordPOSThigh
remove-application-passwordPOSThigh
add-application-keyPOSThigh
remove-application-keyPOSThigh
add-application-ownerPOSThigh
remove-application-ownerDELETEhigh
create-app-federated-credentialPOSThigh
update-app-federated-credentialPATCHhigh
delete-app-federated-credentialDELETEhigh
set-application-verified-publisherPOSTmedium
Service Principals CRUD & credentials (10) -- requires --allow-writes
ToolMethodRisk
create-service-principalPOSThigh
delete-service-principalDELETEcritical
add-sp-passwordPOSThigh
remove-sp-passwordPOSThigh
add-sp-keyPOSThigh
remove-sp-keyPOSThigh
add-sp-token-signing-certificatePOSThigh
add-sp-ownerPOSThigh
remove-sp-ownerDELETEhigh
create-sp-app-role-assignmentPOSThigh
PIM activation & requests (10) -- requires --allow-writes
ToolMethodRisk
create-pim-role-assignment-requestPOSTcritical
cancel-pim-role-assignment-requestPOSThigh
create-pim-role-eligibility-requestPOSTcritical
cancel-pim-role-eligibility-requestPOSThigh
create-pim-group-assignment-requestPOSThigh
cancel-pim-group-assignment-requestPOSTmedium
create-pim-group-eligibility-requestPOSThigh
cancel-pim-group-eligibility-requestPOSTmedium
create-role-management-policy-assignmentPOSThigh
update-role-management-policyPATCHhigh
Entitlement Management CRUD (12) -- requires --allow-writes
ToolMethodRisk
create-access-packagePOSTmedium
update-access-packagePATCHmedium
delete-access-packageDELETEhigh
create-access-package-catalogPOSTmedium
update-access-package-catalogPATCHmedium
delete-access-package-catalogDELETEhigh
create-access-package-assignment-policyPOSTmedium
update-access-package-assignment-policyPUTmedium
delete-access-package-assignment-policyDELETEhigh
create-access-package-assignment-requestPOSTmedium
reprocess-access-package-assignment-requestPOSTlow
cancel-access-package-assignment-requestPOSTmedium
Lifecycle Workflows CRUD & execution (8) -- requires --allow-writes
ToolMethodRisk
create-lifecycle-workflowPOSTmedium
update-lifecycle-workflowPATCHmedium
delete-lifecycle-workflowDELETEhigh
activate-lifecycle-workflowPOSThigh
restore-lifecycle-workflowPOSTmedium
create-lifecycle-custom-task-extensionPOSTmedium
update-lifecycle-custom-task-extensionPATCHmedium
delete-lifecycle-custom-task-extensionDELETEhigh
访问审查 CRUD 和操作(8)——需要 --allow-writes
工具方法风险
create-access-review-definitionPOST中
update-access-review-definitionPUT中
delete-access-review-definitionDELETE高
stop-access-review-instancePOST高
send-reminder-access-reviewPOST低
reset-access-review-decisionsPOST高
apply-access-review-decisionsPOST高
accept-access-review-recommendationsPOST中
电子数据取证(Purview)(33)——写入操作需要 --allow-writes

案件和搜索:

工具方法风险
list-ediscovery-casesGET
get-ediscovery-caseGET
create-ediscovery-casePOST中
update-ediscovery-casePATCH中
delete-ediscovery-caseDELETE严重
close-ediscovery-casePOST中
reopen-ediscovery-casePOST中
list-ediscovery-searchesGET
create-ediscovery-searchPOST中
estimate-ediscovery-search-statisticsPOST中

保管人:

工具方法风险
list-ediscovery-custodiansGET
get-ediscovery-custodianGET
create-ediscovery-custodianPOST中
apply-hold-ediscovery-custodianPOST高
remove-hold-ediscovery-custodianPOST高
release-ediscovery-custodianPOST中
update-ediscovery-custodian-indexPOST低

非保管人数据源:

工具方法风险
list-ediscovery-noncustodial-data-sourcesGET
get-ediscovery-noncustodial-data-sourceGET
create-ediscovery-noncustodial-data-sourcePOST中
apply-hold-ediscovery-noncustodial-data-sourcePOST中
remove-hold-ediscovery-noncustodial-data-sourcePOST高

审查集、查询和导出:

工具方法风险
list-review-setsGET
get-review-setGET
create-review-setPOST低
add-to-review-setPOST中
export-review-setPOST高
list-review-set-queriesGET
get-review-set-queryGET
create-review-set-queryPOST低
apply-tags-review-set-queryPOST中

操作:

工具方法风险
list-case-operationsGET
get-case-operationGET

export-review-set 是符合法庭采信要求的制作导出路径。其 exportOptions / exportStructure 字段是 Graph 标记的枚举,必须以逗号分隔的字符串发送,而非对象。

Azure AD 权限

只读(默认)
AccessReview.Read.All
AdministrativeUnit.Read.All
AgentRegistration.Read.All
Agreement.Read.All
AiEnterpriseInteraction.Read.All
APIConnectors.Read.All
AppCatalog.Read.All
Application.Read.All
AppRoleAssignment.Read.All
AttackSimulation.Read.All
AuditLog.Read.All
BitlockerKey.Read.All
CallRecords.Read.All
Chat.ManageDeletion.All
Channel.ReadBasic.All
Chat.Read.All
ChatMember.Read.All
ChatMessage.Read.All
CloudPC.Read.All
ConsentRequest.Read.All
CopilotPolicySettings.Read
CopilotSettings-Internal.ReadWrite.All
CustomAuthenticationExtension.Read.All
CustomSecAttributeDefinition.Read.All
Device.Read.All
DeviceLocalCredential.Read.All
DeviceManagementApps.Read.All
DeviceManagementConfiguration.Read.All
DeviceManagementManagedDevices.Read.All
DeviceManagementRBAC.Read.All
DeviceManagementServiceConfig.Read.All
Directory.Read.All
Domain.Read.All
eDiscovery.Read.All
EntitlementManagement.Read.All
Exchange.ManageAsApp
Group.Read.All
GroupMember.Read.All
IdentityProvider.Read.All
IdentityRiskEvent.Read.All
IdentityRiskyServicePrincipal.Read.All
IdentityRiskyUser.Read.All
IdentityUserFlow.Read.All
InformationProtectionPolicy.Read.All
LifecycleWorkflows.Read.All
MailboxSettings.Read
OnlineMeetingArtifact.Read.All
OnlineMeetings.Read.All
OnPremDirectorySynchronization.Read.All
Organization.Read.All
Policy.Read.All
Printer.Read.All
ProtectionScopes.Compute.All
PrintConnector.Read.All
PrintJob.Read.All
PrivilegedAccess.Read.AzureADGroup
RecordsManagement.Read.All
Reports.Read.All
RoleAssignmentSchedule.Read.Directory
RoleEligibilitySchedule.Read.Directory
RoleManagement.Read.Directory
RoleManagementPolicy.Read.Directory
SecurityAlert.Read.All
SecurityEvents.Read.All
SecurityIdentitiesAccount.Read.All
SecurityIdentitiesAutoConfig.Read.All
SecurityIdentitiesHealth.Read.All
SecurityIdentitiesMigration.Read.All
SecurityIdentitiesSensors.Read.All
SecurityIncident.Read.All
ServiceHealth.Read.All
ServiceMessage.Read.All
SharePointTenantSettings.Read.All
Sites.Read.All
Sites.FullControl.All
SubjectRightsRequest.Read.All
Team.ReadBasic.All
TeamMember.Read.All
TeamsAppInstallation.ReadForTeam.All
TeamsTelephoneNumber.Read.All
TeamsUserConfiguration.Read.All
TeamworkAppSettings.Read.All
TeamworkDevice.Read.All
ThreatAssessment.Read.All
ThreatHunting.Read.All
ThreatIntelligence.Read.All
User.Invite.All
User.Read.All
UserAuthenticationMethod.Read.All
写入(事件响应、设备操作、CA 策略、Teams、SharePoint、身份管理)
AccessReview.ReadWrite.All
AdministrativeUnit.ReadWrite.All
Application.ReadWrite.All
Application.ReadWrite.OwnedBy
AppRoleAssignment.ReadWrite.All
AttackSimulation.ReadWrite.All
Channel.Create
Channel.Delete.All
CloudPC.ReadWrite.All
Device.ReadWrite.All
DeviceManagementConfiguration.ReadWrite.All
DeviceManagementManagedDevices.PrivilegedOperations.All
DeviceManagementManagedDevices.ReadWrite.All
DeviceManagementServiceConfig.ReadWrite.All
Directory.AccessAsUser.All
Domain.ReadWrite.All
eDiscovery.ReadWrite.All
EntitlementManagement.ReadWrite.All
Group.ReadWrite.All
GroupMember.ReadWrite.All
IdentityRiskyServicePrincipal.ReadWrite.All
IdentityRiskyUser.ReadWrite.All
LifecycleWorkflows.ReadWrite.All
Policy.ReadWrite.AuthenticationMethod
Policy.ReadWrite.ConditionalAccess
PrivilegedAccess.ReadWrite.AzureADGroup
RecordsManagement.ReadWrite.All
RoleAssignmentSchedule.ReadWrite.Directory
RoleEligibilitySchedule.ReadWrite.Directory
RoleManagement.ReadWrite.Directory
RoleManagementPolicy.ReadWrite.Directory
SecurityAlert.ReadWrite.All
SecurityIdentitiesActions.ReadWrite.All
SecurityIdentitiesAutoConfig.ReadWrite.All
SecurityIdentitiesMigration.ReadWrite.All
SecurityIdentitiesSensors.ReadWrite.All
SecurityIncident.ReadWrite.All
Sites.ReadWrite.All
Team.Create
Team.ReadWrite.All
TeamMember.ReadWrite.All
TeamsTelephoneNumber.ReadWrite.All
TeamworkAppSettings.ReadWrite.All
User.ReadWrite.All
UserAuthenticationMethod.ReadWrite.All

远程 HTTP 部署

本地 HTTP 模式
node dist/index.js \
  --transport http \
  --port 8080 \
  --allowed-clients "app-id-1,app-id-2"

HTTP 模式下必须使用 --allowed-clients 标志。它会针对 Microsoft 的 JWKS 端点验证传入的 bearer token(包括签名验证、受众、租户和客户端 ID 检查)。

Docker
docker build -t ms365-admin-mcp .
docker run -p 8080:8080 \
  -e MS365_ADMIN_MCP_CLIENT_ID=... \
  -e MS365_ADMIN_MCP_CLIENT_SECRET=... \
  -e MS365_ADMIN_MCP_TENANT_ID=... \
  ms365-admin-mcp --allowed-clients "your-app-id"
Azure Container Apps

项目提供了 Bicep 模板 infra/main.bicep,用于部署:

  • 用户分配的托管标识(UAMI)
  • Key Vault(RBAC、清除保护、90 天软删除)
  • Log Analytics 工作区 + Application Insights
  • Container App 环境
  • 使用 UAMI 的 Container App,并将 MS365_ADMIN_MCP_KEYVAULT_URL 配置为指向该保管库
MY_OID=$(az ad signed-in-user show --query id -o tsv)

az deployment group create \
  --resource-group rg-mcp-admin \
  --template-file infra/main.bicep \
  --parameters baseName=ms365mcpprod \
               containerImage=your-acr.azurecr.io/ms365-admin-mcp:latest \
               kvAdminObjectIds="['$MY_OID']"

部署后,请使用 ms365-admin-mcp-{client-id,tenant-id,client-secret} 为保管库填充初始密钥;参见 docs/HTTP_DEPLOYMENT.md。

开发

npm run dev              # Run with tsx (hot reload)
npm run generate         # Download OpenAPI spec + generate client
npm run build            # Build with tsup
npm run test             # Run vitest
npm run lint             # ESLint
npm run format           # Prettier
npm run verify           # Full pipeline (generate + lint + format + build + test)
npm run inspector        # MCP Inspector for interactive testing
添加新工具
  1. 在 src/endpoints.json 中添加端点条目,并设置其 section(README 清单中该条目所属的部分);如果是写入操作,还需设置 riskLevel。如果该部分是新的,请将其添加到 src/tool-partitions.ts 中的每个表格
  2. 运行 npm run generate 重新生成客户端
  3. 启动时,registerGraphTools() 会自动注册该工具
  4. 运行 npm run verify 进行验证

安全

  • 默认只读——修改操作需要 --allow-writes
  • 写入工具的风险级别(严重/高/中/低),并提供 LLM 可见的警告
  • HTTP 模式下通过 Microsoft JWKS(RS256)验证 JWT 签名
  • HTTP 模式下必须进行身份验证(必须提供 --allowed-clients)
  • MCP 端点上的速率限制(100 次请求/分钟)
  • 安全标头(nosniff、DENY、no-store、CSP)
  • Docker 使用非 root 用户
  • 从日志中删去敏感数据

致谢

没有 Softeria/ms-365-mcp-server,本项目便无从存在。他们的工作为此服务奠定了基础并带来启发,尤其包括:

  • 端点驱动架构(endpoints.json + 通过 graph-tools.ts 自动注册)
  • 基于 OpenAPI 的代码生成流程(npm run generate → 精简后的 Graph 规范 + Zodios 客户端)
  • CLI 易用性设计(预设、--list-tools、--list-permissions、--verify-login、MCP Inspector 集成)
  • 默认只读 + --allow-writes 安全模型

与 Softeria 的项目不同,本服务面向应用程序权限(通过 MSAL ConfidentialClientApplication 使用客户端凭据),而非委派权限,并增添了管理员专用功能——写入工具的风险分类、HTTP 模式下通过 Microsoft JWKS 验证 JWT、Azure Key Vault 集成以及事件响应工具。

衷心感谢 Softeria 团队及贡献者在开源许可下分享他们的工作,也感谢他们为 Microsoft 365 生态系统中的 MCP 服务设计树立了高标准。

许可证

MIT——参见 LICENSE。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。