ms-365-admin-mcp-server

一个通过 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 管理机密
文档
先决条件
- 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、来宾用户、外部身份 |
exchange | Exchange 管理(邮件跟踪、邮箱) |
intune | 受管理设备、合规性、配置、Autopilot、应用、RBAC |
governance | 访问评审、权利管理、生命周期工作流、使用条款 |
compliance | 许可证、安全评分、身份保护、风险检测、策略 |
response | 事件响应写入操作(禁用、撤销、确认、驳回) |
ediscovery | 电子数据展示案例(Microsoft Purview) |
cloudpc | Cloud PC / Windows 365(预配、映像、连接、设置、审核) |
callrecords | Teams 通话记录 |
print | Universal Print(打印机、共享、连接器、服务、操作、任务) |
infoprotection | 信息保护(BitLocker 恢复密钥、威胁评估) |
sharepointadmin | SharePoint 租户管理设置 |
retention | 记录管理(保留标签、文件计划元数据) |
all | 所有可用工具 |
验证凭据
node dist/index.js --verify-login
可用工具(674 个)
安全(11 个)
| 工具 | 方法 | 风险 |
|---|
list-security-alerts | GET | |
get-security-alert | GET | |
update-security-alert | PATCH | 中 |
list-security-incidents | GET | |
get-security-incident | GET | |
update-security-incident | PATCH | 中 |
list-attack-simulations | GET | |
get-attack-simulation | GET | |
create-attack-simulation | POST | 高 |
update-attack-simulation | PATCH | 中 |
delete-attack-simulation | DELETE | 中 |
审核日志和已删除项目(5 个)
| 工具 | 方法 |
|---|
list-directory-audits | GET |
list-sign-ins | GET |
list-provisioning-logs | GET |
list-deleted-users | GET |
list-deleted-groups | GET |
服务运行状况(3 个)
| 工具 | 方法 |
|---|
list-service-health | GET |
list-service-issues | GET |
list-service-messages | GET |
使用情况报告(8 个)
| 工具 | 方法 |
|---|
get-teams-activity-report | GET |
get-email-activity-report | GET |
get-active-users-report | GET |
get-sharepoint-usage-report | GET |
get-onedrive-usage-report | GET |
get-active-user-counts-report | GET |
get-mailbox-usage-report | GET |
get-m365-apps-usage-report | GET |
用户(9)
| 工具 | 方法 | 风险 |
|---|
list-users | GET | |
get-user | GET | |
list-user-memberships | GET | |
list-user-auth-methods | GET | |
list-user-devices | GET | |
create-user | POST | 高 |
delete-user | DELETE | 严重 |
assign-user-license | POST | 中 |
reprocess-user-license | POST | 低 |
没有通用的 update-user。此服务在 /users/{id} 上仅提供 disable-user-account 这一项 PATCH 操作(参见事件响应),其功能刻意限定为仅设置 accountEnabled,不做其他更改。
设备(2)
| 工具 | 方法 |
|---|
list-devices | GET |
get-device | GET |
组(11)
| 工具 | 方法 | 风险 |
|---|
list-groups | GET | |
get-group | GET | |
list-group-members | GET | |
list-group-owners | GET | |
create-group | POST | 中 |
update-group | PATCH | 中 |
delete-group | DELETE | 严重 |
add-group-member | POST | 中 |
remove-group-member | DELETE | 中 |
add-group-owner | POST | 高 |
remove-group-owner | DELETE | 高 |
remove-group-member、add-group-owner 和 remove-group-owner 会运行预检防护规则:如果组是本地部署同步组、要从动态组中移除成员,或要移除组的唯一所有者,操作都会被拒绝。参见 docs/ARCHITECTURE.md。
目录角色与 PIM(9)
| 工具 | 方法 | 风险 |
|---|
list-directory-roles | GET | |
list-role-members | GET | |
list-role-assignments | GET | |
list-role-definitions | GET | |
list-pim-eligible-assignments | GET | |
list-pim-active-assignments | GET | |
add-directory-role-member | POST | 严重 |
delete-role-assignment | DELETE | 严重 |
remove-directory-role-member | DELETE | 严重 |
应优先使用 delete-role-assignment:list-role-assignments 配合 $filter=principalId eq '{user-id}' 已会返回所需的分配 ID。remove-directory-role-member 则适用于通过旧方式激活的角色。对于租户中最后一位活跃的全局管理员,两者都会无条件拒绝操作——这是防止锁定租户的防护规则,任何参数都无法覆盖。
管理单元(8)
| 工具 | 方法 | 风险 |
|---|
list-administrative-units | GET | |
get-administrative-unit | GET | |
list-administrative-unit-members | GET | |
create-administrative-unit | POST | 中 |
update-administrative-unit | PATCH | 中 |
delete-administrative-unit | DELETE | 高 |
add-administrative-unit-member | POST | 中 |
remove-administrative-unit-member | DELETE | 高 |
条件访问(3)
| 工具 | 方法 |
|---|
list-conditional-access-policies | GET |
get-conditional-access-policy | GET |
list-named-locations | GET |
应用与应用角色(11)
| 工具 | 方法 | 风险 |
|---|
list-applications | GET | |
list-service-principals | GET | |
list-oauth2-grants | GET | |
list-user-app-role-assignments | GET | |
list-sp-app-role-assignments | GET | |
update-application | PATCH | 高 |
delete-application | DELETE | 严重 |
update-service-principal | PATCH | 高 |
delete-oauth2-grant | DELETE | 高 |
delete-sp-app-role-assignment | DELETE | 高 |
delete-user-app-role-assignment | DELETE | 高 |
delete-oauth2-grant 用于补救非法的授权许可:list-oauth2-grants 可识别此类许可,而此工具会撤销它。consentType: AllPrincipals 的许可会一次性撤销该应用对所有用户的委派访问权限——请先检查影响范围,并配合使用 revoke-user-sessions,因为撤销许可不会结束现有会话。
应用凭据与所有者(7)
| 工具 | 方法 |
|---|
get-application | GET |
list-application-owners | GET |
list-app-federated-credentials | GET |
get-app-federated-credential | GET |
get-service-principal | GET |
list-service-principal-owners | GET |
list-sp-delegated-permissions | GET |
应用管理策略(2)
| 工具 | 方法 |
|---|
list-app-management-policies | GET |
get-app-management-policy | GET |
组织与域(4)
| 工具 | 方法 | 风险 |
|---|
get-organization | GET | |
list-domains | GET | |
create-domain | POST | 高 |
verify-domain | POST | 中 |
许可证(2)
| 工具 | 方法 |
|---|
list-subscribed-skus | GET |
get-subscribed-sku | GET |
安全评分(4)
| 工具 | 方法 |
|---|
list-secure-scores | GET |
get-secure-score | GET |
list-secure-score-controls | GET |
get-secure-score-control | GET |
身份保护与风险检测(7)
| 工具 | 方法 |
|---|
list-risky-users | GET |
get-risky-user | GET |
list-risky-user-history | GET |
list-risky-service-principals | GET |
get-risky-service-principal | GET |
list-risk-detections | GET |
get-risk-detection | GET |
安全与访问策略(13)
| 工具 | 方法 | 风险 |
|---|
get-auth-methods-policy | GET | |
list-auth-method-configs | GET | |
get-auth-method-config | GET | |
get-security-defaults | GET | |
get-admin-consent-policy | GET | |
list-auth-strength-policies | GET | |
get-auth-strength-policy | GET | |
create-auth-strength-policy | POST | 高 |
update-auth-strength-policy | PATCH | 高 |
delete-auth-strength-policy | DELETE | 高 |
get-cross-tenant-access-policy | GET | |
list-cross-tenant-partners | GET | |
change-user-password | POST | 高 |
Guest user invitations (2)
| Tool | Method | Risk |
|---|
list-invitations | GET | |
create-invitation | POST | medium |
External identity providers (2)
| Tool | Method |
|---|
list-identity-providers | GET |
get-identity-provider | GET |
Self-service sign-up (4)
| Tool | Method |
|---|
list-b2x-user-flows | GET |
get-b2x-user-flow | GET |
list-api-connectors | GET |
get-api-connector | GET |
Custom authentication extensions (2)
| Tool | Method |
|---|
list-custom-auth-extensions | GET |
get-custom-auth-extension | GET |
Exchange message traces (2)
| Tool | Method |
|---|
list-message-traces | GET |
get-message-trace | GET |
Exchange mailboxes (7)
| Tool | Method | Risk |
|---|
list-exchange-mailboxes | GET | |
get-exchange-mailbox | GET | |
list-exchange-mailbox-folders | GET | |
get-exchange-mailbox-folder | GET | |
export-exchange-mailbox-items | POST | medium |
update-exchange-mailbox | PATCH | medium |
delete-exchange-mailbox | DELETE | critical |
Threat intelligence - hosts (4)
| Tool | Method |
|---|
list-threat-intel-hosts | GET |
get-threat-intel-host | GET |
get-threat-intel-host-whois | GET |
list-threat-intel-host-pairs | GET |
Threat intelligence - articles & profiles (6)
| Tool | Method |
|---|
list-threat-intel-articles | GET |
get-threat-intel-article | GET |
list-threat-intel-article-indicators | GET |
list-threat-intel-profiles | GET |
get-threat-intel-profile | GET |
list-threat-intel-profile-indicators | GET |
Threat intelligence - vulnerabilities & WHOIS (4)
| Tool | Method |
|---|
list-threat-intel-vulnerabilities | GET |
get-threat-intel-vulnerability | GET |
list-threat-intel-whois-records | GET |
get-threat-intel-whois-record | GET |
Threat intelligence - infrastructure (2)
| Tool | Method |
|---|
list-threat-intel-host-components | GET |
list-threat-intel-ssl-certs | GET |
Managed devices (8)
| Tool | Method | Risk |
|---|
list-managed-devices | GET | |
get-managed-devices-by-names | GET | |
get-managed-device | GET | |
get-windows-protection-state | GET | |
list-device-compliance-states | GET | |
list-device-configuration-states | GET | |
get-managed-device-overview | GET | |
delete-managed-device | DELETE | critical |
Compliance policies (5)
| Tool | Method |
|---|
list-compliance-policies | GET |
get-compliance-policy | GET |
list-compliance-policy-device-statuses | GET |
get-compliance-policy-status-overview | GET |
get-compliance-state-summary | GET |
设备配置(4)
| 工具 | 方法 |
|---|
list-device-configurations | GET |
get-device-configuration | GET |
get-device-configuration-status-overview | GET |
list-device-configuration-device-statuses | GET |
设置目录和 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-policies | GET | |
get-configuration-policy | GET | |
list-configuration-policy-settings | GET | |
list-configuration-policy-templates | GET | |
get-configuration-policy-device-status | POST | 低 |
get-configuration-policy-device-summary | POST | 低 |
Endpoint security 意图(旧版模板)(4)
迁移到设置目录之前创建的基于模板的 Endpoint security 策略。**针对 Graph beta。**Endpoint security 审计必须同时涵盖这些策略和设置目录策略。
| 工具 | 方法 |
|---|
list-intents | GET |
get-intent | GET |
list-intent-device-states | GET |
list-intent-templates | GET |
设备加密(1)
Intune 加密报告:就绪状态、状态、TPM 版本,以及已应用到各设备的 BitLocker / FileVault 策略。针对 Graph beta。
| 工具 | 方法 |
|---|
list-managed-device-encryption-states | GET |
Windows Update 配置文件(3)
功能更新和质量更新配置文件,它们会覆盖设备的 Windows Update for Business 更新环中的延迟设置(更新环本身属于设备配置)。针对 Graph beta。
| 工具 | 方法 |
|---|
list-windows-feature-update-profiles | GET |
list-windows-quality-update-profiles | GET |
list-windows-quality-update-policies | GET |
macOS 平台脚本(6)
部署到受管理 macOS 设备的 Intune Shell 脚本。针对 Graph beta(/beta/deviceManagement/deviceShellScripts)——Microsoft 从未将此端点升级到 v1.0。需要 DeviceManagementScripts.ReadWrite.All。
| 工具 | 方法 | 风险 |
|---|
list-device-shell-scripts | GET | |
get-device-shell-script | GET | |
create-device-shell-script | POST | 中 |
update-device-shell-script | PATCH | 中 |
delete-device-shell-script | DELETE | 高 |
assign-device-shell-script | POST | 中 |
说明:
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-scripts | GET | |
get-device-health-script | GET | |
list-device-health-script-run-states | GET | |
get-device-health-script-run-summary | GET | |
create-device-health-script | POST | 中 |
update-device-health-script | PATCH | 中 |
delete-device-health-script | DELETE | 高 |
assign-device-health-script | POST | 中 |
说明:
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-filters | GET | |
get-assignment-filter | GET | |
create-assignment-filter | POST | 中 |
update-assignment-filter | PATCH | 中 |
delete-assignment-filter | DELETE | 高 |
说明:
- 规则语法类似 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-scripts | GET | |
get-device-custom-attribute-shell-script | GET | |
create-device-custom-attribute-shell-script | POST | 中 |
update-device-custom-attribute-shell-script | PATCH | 中 |
delete-device-custom-attribute-shell-script | DELETE | 高 |
assign-device-custom-attribute-shell-script | POST | 中 |
注意:
- 脚本的标准输出会成为每台设备上存储在
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-scripts | GET | |
get-device-management-script | GET | |
create-device-management-script | POST | 中 |
update-device-management-script | PATCH | 中 |
delete-device-management-script | DELETE | 高 |
assign-device-management-script | POST | 中 |
注意:
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-scripts | GET | |
get-device-compliance-script | GET | |
create-device-compliance-script | POST | 中 |
update-device-compliance-script | PATCH | 中 |
delete-device-compliance-script | DELETE | 高 |
assign-device-compliance-script | POST | 中 |
注意:
detectionScriptContent 必须在 STDOUT 上输出一个 JSON 对象(例如,ConvertTo-Json -Compress @{BitLockerEnabled=$true;TpmReady=$true})。
- 脚本本身不会影响合规性——你还必须编写一个规则相匹配的
windows10CustomComplianceConfiguration 策略。
- 如果更改 JSON 键却不更新关联策略中的规则,合规性评估会悄然失效。
- 删除正在使用的脚本,会导致引用它的合规性策略在设备下次签入时评估失败。
- 分配结构沿用
deviceHealthScriptAssignment(将 runRemediationScript 设为 false,因为合规性脚本没有对应的修正脚本)。
注册与 Autopilot(10)
| 工具 | 方法 | 风险 |
|---|
list-enrollment-configurations | GET | |
get-enrollment-configuration | GET | |
list-autopilot-devices | GET | |
get-autopilot-device | GET | |
create-enrollment-configuration | POST | 中 |
update-enrollment-configuration | PATCH | 中 |
delete-enrollment-configuration | DELETE | 高 |
update-autopilot-device | PATCH | 中 |
delete-autopilot-device | DELETE | 高 |
import-autopilot-device | POST | 中 |
已检测到的应用(3)
| 工具 | 方法 |
|---|
list-detected-apps | GET |
get-detected-app | GET |
list-detected-app-devices | GET |
Intune RBAC 与配置(7)
| 工具 | 方法 |
|---|
list-intune-audit-events | GET |
get-software-update-summary | GET |
get-apple-push-certificate | GET |
list-intune-role-definitions | GET |
list-intune-role-assignments | GET |
list-intune-terms-and-conditions | GET |
list-intune-terms-acceptances | GET |
Intune 连接器与更新(3)
| 工具 | 方法 |
|---|
get-intune-conditional-access-settings | GET |
list-mtd-connectors | GET |
list-ios-update-statuses | GET |
设备类别(1)
| 工具 | 方法 |
|---|
list-device-categories | GET |
访问评审(5)
| 工具 | 方法 |
|---|
list-access-review-definitions | GET |
get-access-review-definition | GET |
list-access-review-instances | GET |
get-access-review-instance | GET |
list-access-review-decisions | GET |
权限管理(7)
| 工具 | 方法 |
|---|
list-access-packages | GET |
get-access-package | GET |
list-access-package-assignments | GET |
list-access-package-requests | GET |
list-access-package-catalogs | GET |
list-connected-organizations | GET |
get-entitlement-management-settings | GET |
生命周期工作流(3)
| 工具 | 方法 |
|---|
list-lifecycle-workflows | GET |
get-lifecycle-workflow | GET |
list-lifecycle-task-definitions | GET |
群组 PIM(2)
| 工具 | 方法 |
|---|
list-pim-group-assignment-schedules | GET |
list-pim-group-eligibility-schedules | GET |
使用条款(3)
| 工具 | 方法 |
|---|
list-terms-of-use-agreements | GET |
get-terms-of-use-agreement | GET |
list-terms-of-use-acceptances | GET |
应用同意请求(3)
| 工具 | 方法 |
|---|
list-app-consent-requests | GET |
get-app-consent-request | GET |
list-user-consent-requests | GET |
事件响应(17)——需要 --allow-writes
| 工具 | 方法 | 风险 |
|---|
disable-user-account | PATCH | 严重 |
revoke-user-sessions | POST | 高 |
add-security-alert-comment | POST | 低 |
update-device | PATCH | 高 |
confirm-compromised-users | POST | 高 |
dismiss-risky-users | POST | 高 |
delete-user-phone-auth-method | DELETE | 高 |
delete-user-fido2-auth-method | DELETE | 高 |
delete-user-authenticator-auth-method | DELETE | 高 |
delete-user-software-oath-auth-method | DELETE | 高 |
delete-user-windows-hello-auth-method | DELETE | 高 |
delete-user-email-auth-method | DELETE | 高 |
delete-user-temporary-access-pass-auth-method | DELETE | 高 |
confirm-compromised-service-principals | POST | 高 |
dismiss-risky-service-principals | POST | 高 |
confirm-safe-users | POST | 高 |
run-hunting-query | POST | 低 |
每种身份验证方法集合对应一个删除工具,因为 ID 的作用域限定在各自集合内,不能互换。请先运行 list-user-auth-methods,然后根据 @odata.type 进行匹配,以选择正确的工具和 ID。如果该方法是用户仅剩的 MFA 因素,且 MFA 为必需项,Graph 将拒绝删除。
Intune 设备远程操作 (18) -- 需要 --allow-writes
| 工具 | 方法 | 风险 |
|---|
wipe-managed-device | POST | 严重 |
retire-managed-device | POST | 高 |
sync-managed-device | POST | 低 |
reboot-managed-device | POST | 高 |
remote-lock-device | POST | 中 |
reset-device-passcode | POST | 高 |
shutdown-managed-device | POST | 高 |
disable-lost-mode | POST | 低 |
locate-managed-device | POST | 低 |
bypass-activation-lock | POST | 高 |
trigger-defender-scan | POST | 低 |
update-defender-signatures | POST | 低 |
rotate-bitlocker-keys | POST | 中 |
rotate-local-admin-password | POST | 中 |
clean-windows-device | POST | 严重 |
logout-shared-apple-user | POST | 中 |
delete-shared-apple-user | POST | 高 |
update-windows-device-account | POST | 中 |
条件访问 CRUD (7) -- 需要 --allow-writes
| 工具 | 方法 | 风险 |
|---|
list-conditional-access-templates | GET | |
create-conditional-access-policy | POST | 高 |
update-conditional-access-policy | PATCH | 高 |
delete-conditional-access-policy | DELETE | 严重 |
create-named-location | POST | 中 |
update-named-location | PATCH | 中 |
delete-named-location | DELETE | 高 |
Intune 策略 CRUD (8) -- 需要 --allow-writes
| 工具 | 方法 | 风险 |
|---|
create-compliance-policy | POST | 中 |
update-compliance-policy | PATCH | 中 |
assign-compliance-policy | POST | 高 |
delete-compliance-policy | DELETE | 高 |
create-device-configuration | POST | 中 |
update-device-configuration | PATCH | 中 |
assign-device-configuration | POST | 高 |
delete-device-configuration | DELETE | 高 |
设置目录和 Endpoint security CRUD (4) -- 需要 --allow-writes
目标为 Graph beta。 需要 DeviceManagementConfiguration.ReadWrite.All。assign-configuration-policy 会替换整个分配列表。
| 工具 | 方法 | 风险 |
|---|
create-configuration-policy | POST | 中 |
update-configuration-policy | PATCH | 中 |
delete-configuration-policy | DELETE | 高 |
assign-configuration-policy | POST | 高 |
Endpoint security 意图 CRUD (4) -- 需要 --allow-writes
目标为 Graph beta。 需要 DeviceManagementConfiguration.ReadWrite.All。assign-intent 会替换整个分配列表。
| 工具 | 方法 | 风险 |
|---|
update-intent | PATCH | 中 |
update-intent-settings | POST | 中 |
delete-intent | DELETE | 高 |
assign-intent | POST | 高 |
OneDrive / 用户驱动器(DSAR 枚举)(4)
只读遍历用户的个人驱动器,用于数据主体访问请求。不会公开内容字节;这些工具返回元数据和下载 URL。
| 工具 | 方法 | 风险 |
|---|
get-user-drive | GET | |
get-drive-root | GET | |
list-drive-children | GET | |
get-drive-item | GET | |
Purview DSPM(保护范围)(2)
| 工具 | 方法 | 风险 |
|---|
get-data-security-governance-root | GET | |
compute-protection-scopes | POST | low |
compute-protection-scopes 是 POST 请求,但只进行计算,不会修改数据,因此风险等级为 low。仍需使用 --allow-writes。
Teams 在线会议出席记录(4)
查看特定用户会议的出席记录。仅应用访问需要在租户上配置应用程序访问策略,并通过 Set-CsApplicationAccessPolicy 按服务主体授予权限;若未配置,无论 Graph 权限如何,Graph 都会返回 403。
| 工具 | 方法 | 风险 |
|---|
get-user-online-meeting | GET | |
list-user-meeting-attendance-reports | GET | |
get-user-meeting-attendance-report | GET | |
list-user-meeting-attendance-records | GET | |
Teams 已删除聊天(3)
| 工具 | 方法 | 风险 |
|---|
list-deleted-chats | GET | |
get-deleted-chat | GET | |
undo-delete-chat | POST | medium |
用于恢复用户删除的聊天的管理流程。保留期限由 Microsoft 决定,无法在此配置。
Teams 聊天调查读取(5)
读取用户聊天以进行分诊,需要 Chat.Read.All。对于可作为法庭证据的生产用途,请改用电子取证工具——这些读取不具备监管链。
| 工具 | 方法 | 风险 |
|---|
list-user-chats | GET | |
get-chat | GET | |
list-chat-members | GET | |
list-chat-messages | GET | |
get-chat-message | GET | |
Teams 通话记录(11)
| 工具 | 方法 |
|---|
list-call-records | GET |
get-call-record | GET |
list-call-record-sessions | GET |
get-call-record-session | GET |
list-call-session-segments | GET |
get-call-session-segment | GET |
list-call-record-participants | GET |
get-call-record-participant | GET |
get-call-record-organizer | GET |
get-pstn-calls | GET |
get-direct-routing-calls | GET |
Cloud PC / Windows 365(10)
| 工具 | 方法 | 风险 |
|---|
list-cloud-pcs | GET | |
list-cloud-pc-provisioning-policies | GET | |
list-cloud-pc-device-images | GET | |
list-cloud-pc-gallery-images | GET | |
list-cloud-pc-on-premises-connections | GET | |
list-cloud-pc-user-settings | GET | |
list-cloud-pc-audit-events | GET | |
create-cloud-pc-provisioning-policy | POST | medium |
update-cloud-pc-provisioning-policy | PATCH | medium |
delete-cloud-pc-provisioning-policy | DELETE | high |
Universal Print(6)
| 工具 | 方法 | 风险 |
|---|
list-printers | GET | |
list-print-shares | GET | |
list-print-connectors | GET | |
list-print-services | GET | |
list-print-operations | GET | |
list-print-task-definitions | GET | |
信息保护与敏感度标签(7)
| 工具 | 方法 |
|---|
list-bitlocker-recovery-keys | GET |
list-threat-assessment-requests | GET |
list-sensitivity-labels | GET |
get-sensitivity-label | GET |
list-sensitivity-sublabels | GET |
get-sensitivity-label-rights | GET |
get-protection-scopes | GET |
SharePoint 管理(25)
| 工具 | 方法 | 风险 |
|---|
get-sharepoint-settings | GET | |
list-sharepoint-sites | GET | |
get-sharepoint-site | GET | |
update-sharepoint-site | PATCH | 中 |
list-site-drives | GET | |
get-site-default-drive | GET | |
list-site-lists | GET | |
get-site-list | GET | |
create-site-list | POST | 低 |
update-site-list | PATCH | 低 |
delete-site-list | DELETE | 高 |
list-site-list-items | GET | |
create-site-list-item | POST | 低 |
update-site-list-item | PATCH | 低 |
delete-site-list-item | DELETE | 中 |
list-site-list-columns | GET | |
list-site-columns | GET | |
list-site-content-types | GET | |
list-site-permissions | GET | |
get-site-permission | GET | |
create-site-permission | POST | 中 |
update-site-permission | PATCH | 中 |
delete-site-permission | DELETE | 高 |
get-site-analytics | GET | |
list-site-subsites | GET | |
记录管理(9)
| 工具 | 方法 | 风险 |
|---|
list-file-plan-authorities | GET | |
list-file-plan-categories | GET | |
list-file-plan-citations | GET | |
list-file-plan-departments | GET | |
list-file-plan-references | GET | |
get-retention-event | GET | |
create-retention-event | POST | 中 |
get-retention-event-type | GET | |
create-retention-event-type | POST | 中 |
不支持列出或读取 retentionLabels:Microsoft Graph 不支持使用应用程序权限执行此操作。请使用委托访问权限或 Security & Compliance PowerShell。list-retention-events 位于安全高级功能下。
Teams administration (33)
| Tool | Method | Risk |
|---|
list-teams | GET | |
create-team | POST | medium |
get-team | GET | |
update-team | PATCH | medium |
delete-team | DELETE | critical |
list-team-admin-channels | GET | |
create-team-admin-channel | POST | low |
get-team-admin-channel | GET | |
delete-team-admin-channel | DELETE | high |
list-team-admin-members | GET | |
add-team-admin-members | POST | medium |
remove-team-admin-members | POST | medium |
get-team-admin-member | GET | |
list-team-installed-apps | GET | |
archive-team | POST | medium |
unarchive-team | POST | low |
clone-team | POST | medium |
list-team-operations | GET | |
list-team-permission-grants | GET | |
get-teams-app-settings | GET | |
update-teams-app-settings | PATCH | high |
list-deleted-teams | GET | |
list-teams-catalog-apps | GET | |
get-teams-catalog-app | GET | |
list-teams-app-definitions | GET | |
get-teams-admin-settings | GET | |
list-teams-user-configurations | GET | |
get-teams-admin-policy | GET | |
list-teams-policy-assignments | GET | |
list-teams-phone-assignments | GET | |
assign-teams-phone-number | POST | medium |
unassign-teams-phone-number | POST | high |
get-teams-phone-number-operation | GET | |
Intune reports (18) -- requires --allow-writes (POST endpoints)
| Tool | Method | Risk |
|---|
intune-device-noncompliance-report | POST | low |
intune-compliance-policy-noncompliance-report | POST | low |
intune-compliance-policy-noncompliance-summary | POST | low |
intune-compliance-setting-noncompliance-report | POST | low |
intune-config-policy-noncompliance-report | POST | low |
intune-config-policy-noncompliance-summary | POST | low |
intune-config-setting-noncompliance-report | POST | low |
intune-devices-without-compliance-report | POST | low |
intune-noncompliant-devices-settings-report | POST | low |
intune-policy-noncompliance-report | POST | low |
intune-policy-noncompliance-summary | POST | low |
intune-policy-noncompliance-metadata | POST | low |
intune-setting-noncompliance-report | POST | low |
intune-report-filters | POST | low |
intune-historical-report | POST | low |
intune-cached-report | POST | low |
list-intune-report-export-jobs | GET | |
intune-device-app-install-status-report | POST | low |
Intune partners & infrastructure (10)
| Tool | Method | Risk |
|---|
list-compliance-management-partners | GET | |
list-device-management-partners | GET | |
list-exchange-connectors | GET | |
list-remote-assistance-partners | GET | |
list-notification-message-templates | GET | |
list-intune-resource-operations | GET | |
list-imported-autopilot-devices | GET | |
list-windows-malware-info | GET | |
list-intune-mobile-apps | GET | |
list-intune-app-categories | GET | |
Intune app management (11)
| Tool | Method | Risk |
|---|
list-intune-app-configurations | GET | |
list-managed-app-policies | GET | |
list-managed-app-registrations | GET | |
list-managed-app-statuses | GET | |
list-android-app-protections | GET | |
list-ios-app-protections | GET | |
list-default-app-protections | GET | |
list-targeted-app-configurations | GET | |
list-mdm-wip-policies | GET | |
list-mam-wip-policies | GET | |
list-vpp-tokens | GET | |
Advanced policies (15)
| Tool | Method | Risk |
|---|
list-activity-timeout-policies | GET | |
get-authorization-policy | GET | |
get-auth-flows-policy | GET | |
list-claims-mapping-policies | GET | |
list-conditional-access-policies-v2 | GET | |
get-default-app-management-policy | GET | |
get-device-registration-policy | GET | |
list-feature-rollout-policies | GET | |
list-home-realm-discovery-policies | GET | |
list-permission-grant-policies | GET | |
list-role-management-policies | GET | |
list-role-management-policy-assignments | GET | |
list-token-issuance-policies | GET | |
list-token-lifetime-policies | GET | |
get-cross-tenant-default-policy | GET | |
Identity Governance+ (11)
| Tool | Method | Risk |
|---|
list-entitlement-assignment-policies | GET | |
list-entitlement-resources | GET | |
list-entitlement-resource-environments | GET | |
list-lifecycle-workflow-templates | GET | |
get-lifecycle-workflow-settings | GET | |
list-lifecycle-custom-task-extensions | GET | |
list-deleted-lifecycle-workflows | GET | |
list-pim-group-assignment-requests | GET | |
list-pim-group-assignment-instances | GET | |
list-pim-group-eligibility-requests | GET | |
list-pim-group-eligibility-instances | GET | |
PIM role management (6)
| Tool | Method | Risk |
|---|
list-access-review-history | GET | |
list-pim-role-assignment-requests | GET | |
list-pim-role-assignment-schedules | GET | |
list-pim-role-eligibility-requests | GET | |
list-pim-role-eligibility-schedules | GET | |
list-role-resource-namespaces | GET | |
Identity Protection+ (1)
| Tool | Method | Risk |
|---|
list-service-principal-risk-detections | GET | |
Security advanced (9)
| Tool | Method | Risk |
|---|
list-retention-events | GET | |
list-retention-event-types | GET | |
list-subject-rights-requests | GET | |
list-simulation-automations | GET | |
list-simulation-trainings | GET | |
list-simulation-payloads | GET | |
list-simulation-end-user-notifications | GET | |
list-simulation-landing-pages | GET | |
list-simulation-login-pages | GET | |
Defender for Identity(24)
通过 Graph 全面覆盖 Microsoft Defender for Identity(DfI)管理:传感器、传感器候选项(自动发现)、将传感器迁移到统一的 Defender XDR 架构、身份帐户(通过 invokeAction 对 AD 本地部署 / Okta 执行应急操作)、审核策略强制执行和运行状况警报。大多数端点为 Graph v1.0;sensorMigration 仅限 beta。
| 工具 | 方法 | 风险 |
|---|
list-identity-health-issues | GET | |
get-identity-health-issue | GET | |
list-sensor-health-issues | GET | |
get-sensor-health-issue | GET | |
list-identity-sensors | GET | |
get-identity-sensor | GET | |
update-identity-sensor | PATCH | 中 |
get-sensor-deployment-access-key | GET | |
get-sensor-deployment-package-uri | GET | |
regenerate-sensor-deployment-access-key | POST | 高 |
list-sensor-candidates | GET | |
get-sensor-candidate | GET | |
get-sensor-candidate-activation-config | GET | |
update-sensor-candidate-activation-config | PATCH | 中 |
activate-sensor-candidates | POST | 中 |
list-sensor-migrations | GET | |
get-sensor-migration | GET | |
migrate-sensors | POST | 高 |
get-identity-security-settings | GET | |
get-auto-auditing-config | GET | |
update-auto-auditing-config | PATCH | 中 |
list-identity-accounts | GET | |
get-identity-account | GET | |
invoke-identity-account-action | POST | 严重 |
说明:
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-records | GET | |
list-ssl-certificates | GET | |
list-threat-intel-subdomains | GET | |
list-threat-intel-host-ports | GET | |
list-threat-intel-host-trackers | GET | |
list-threat-intel-host-cookies | GET | |
报告+(5)
| 工具 | 方法 | 风险 |
|---|
list-user-registration-details | GET | |
list-daily-print-usage-by-printer | GET | |
list-daily-print-usage-by-user | GET | |
list-monthly-print-usage-by-printer | GET | |
list-monthly-print-usage-by-user | GET | |
Copilot 管理(15)
设置和策略:
| 工具 | 方法 | 风险 |
|---|
get-copilot-admin-settings | GET | |
get-copilot-limited-mode | GET | |
list-copilot-policy-settings | GET | |
get-copilot-policy-setting | GET | |
使用情况报告:
| 工具 | 方法 | 风险 |
|---|
get-copilot-usage-user-detail | GET | |
get-copilot-user-count-summary | GET | |
get-copilot-user-count-trend | GET | |
交互历史审计、AI 用户和会议洞察:
| 工具 | 方法 | 风险 |
|---|
get-all-copilot-interactions | GET | |
get-user-copilot-interactions | GET | |
list-ai-users | GET | |
get-ai-user | GET | |
list-ai-user-online-meetings | GET | |
list-ai-meeting-insights | GET | |
get-ai-meeting-insight | GET | |
Agent 注册:
| 工具 | 方法 | 风险 |
|---|
get-copilot-agent-registration | GET | |
get-all-copilot-interactions 会返回租户中所有企业 Copilot 交互记录——提示词和响应。请将输出视为受监管的个人数据。
目录+(5)
| 工具 | 方法 | 风险 |
|---|
list-attribute-sets | GET | |
list-custom-security-attributes | GET | |
list-device-local-credentials | GET | |
list-federation-configurations | GET | |
list-on-premises-sync | GET | |
应用程序凭据和所有者 CRUD(11)-- 需要 --allow-writes
| 工具 | 方法 | 风险 |
|---|
create-application | POST | high |
add-application-password | POST | high |
remove-application-password | POST | high |
add-application-key | POST | high |
remove-application-key | POST | high |
add-application-owner | POST | high |
remove-application-owner | DELETE | high |
create-app-federated-credential | POST | high |
update-app-federated-credential | PATCH | high |
delete-app-federated-credential | DELETE | high |
set-application-verified-publisher | POST | medium |
Service Principals CRUD & credentials (10) -- requires --allow-writes
| Tool | Method | Risk |
|---|
create-service-principal | POST | high |
delete-service-principal | DELETE | critical |
add-sp-password | POST | high |
remove-sp-password | POST | high |
add-sp-key | POST | high |
remove-sp-key | POST | high |
add-sp-token-signing-certificate | POST | high |
add-sp-owner | POST | high |
remove-sp-owner | DELETE | high |
create-sp-app-role-assignment | POST | high |
PIM activation & requests (10) -- requires --allow-writes
| Tool | Method | Risk |
|---|
create-pim-role-assignment-request | POST | critical |
cancel-pim-role-assignment-request | POST | high |
create-pim-role-eligibility-request | POST | critical |
cancel-pim-role-eligibility-request | POST | high |
create-pim-group-assignment-request | POST | high |
cancel-pim-group-assignment-request | POST | medium |
create-pim-group-eligibility-request | POST | high |
cancel-pim-group-eligibility-request | POST | medium |
create-role-management-policy-assignment | POST | high |
update-role-management-policy | PATCH | high |
Entitlement Management CRUD (12) -- requires --allow-writes
| Tool | Method | Risk |
|---|
create-access-package | POST | medium |
update-access-package | PATCH | medium |
delete-access-package | DELETE | high |
create-access-package-catalog | POST | medium |
update-access-package-catalog | PATCH | medium |
delete-access-package-catalog | DELETE | high |
create-access-package-assignment-policy | POST | medium |
update-access-package-assignment-policy | PUT | medium |
delete-access-package-assignment-policy | DELETE | high |
create-access-package-assignment-request | POST | medium |
reprocess-access-package-assignment-request | POST | low |
cancel-access-package-assignment-request | POST | medium |
Lifecycle Workflows CRUD & execution (8) -- requires --allow-writes
| Tool | Method | Risk |
|---|
create-lifecycle-workflow | POST | medium |
update-lifecycle-workflow | PATCH | medium |
delete-lifecycle-workflow | DELETE | high |
activate-lifecycle-workflow | POST | high |
restore-lifecycle-workflow | POST | medium |
create-lifecycle-custom-task-extension | POST | medium |
update-lifecycle-custom-task-extension | PATCH | medium |
delete-lifecycle-custom-task-extension | DELETE | high |
访问审查 CRUD 和操作(8)——需要 --allow-writes
| 工具 | 方法 | 风险 |
|---|
create-access-review-definition | POST | 中 |
update-access-review-definition | PUT | 中 |
delete-access-review-definition | DELETE | 高 |
stop-access-review-instance | POST | 高 |
send-reminder-access-review | POST | 低 |
reset-access-review-decisions | POST | 高 |
apply-access-review-decisions | POST | 高 |
accept-access-review-recommendations | POST | 中 |
电子数据取证(Purview)(33)——写入操作需要 --allow-writes
案件和搜索:
| 工具 | 方法 | 风险 |
|---|
list-ediscovery-cases | GET | |
get-ediscovery-case | GET | |
create-ediscovery-case | POST | 中 |
update-ediscovery-case | PATCH | 中 |
delete-ediscovery-case | DELETE | 严重 |
close-ediscovery-case | POST | 中 |
reopen-ediscovery-case | POST | 中 |
list-ediscovery-searches | GET | |
create-ediscovery-search | POST | 中 |
estimate-ediscovery-search-statistics | POST | 中 |
保管人:
| 工具 | 方法 | 风险 |
|---|
list-ediscovery-custodians | GET | |
get-ediscovery-custodian | GET | |
create-ediscovery-custodian | POST | 中 |
apply-hold-ediscovery-custodian | POST | 高 |
remove-hold-ediscovery-custodian | POST | 高 |
release-ediscovery-custodian | POST | 中 |
update-ediscovery-custodian-index | POST | 低 |
非保管人数据源:
| 工具 | 方法 | 风险 |
|---|
list-ediscovery-noncustodial-data-sources | GET | |
get-ediscovery-noncustodial-data-source | GET | |
create-ediscovery-noncustodial-data-source | POST | 中 |
apply-hold-ediscovery-noncustodial-data-source | POST | 中 |
remove-hold-ediscovery-noncustodial-data-source | POST | 高 |
审查集、查询和导出:
| 工具 | 方法 | 风险 |
|---|
list-review-sets | GET | |
get-review-set | GET | |
create-review-set | POST | 低 |
add-to-review-set | POST | 中 |
export-review-set | POST | 高 |
list-review-set-queries | GET | |
get-review-set-query | GET | |
create-review-set-query | POST | 低 |
apply-tags-review-set-query | POST | 中 |
操作:
| 工具 | 方法 | 风险 |
|---|
list-case-operations | GET | |
get-case-operation | GET | |
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
添加新工具
- 在
src/endpoints.json 中添加端点条目,并设置其 section(README 清单中该条目所属的部分);如果是写入操作,还需设置 riskLevel。如果该部分是新的,请将其添加到 src/tool-partitions.ts 中的每个表格
- 运行
npm run generate 重新生成客户端
- 启动时,
registerGraphTools() 会自动注册该工具
- 运行
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。