msgraph by merill/msgraph
npx skills add https://github.com/merill/msgraph --skill msgraph搜索、查找并调用超过 27,700 个 Microsoft Graph API 中的任何一个——全部在本地完成,无需网络调用。使用三个搜索命令来查找正确的端点,检查权限和参数,然后可以选择直接执行调用或交给 Graph MCP 服务器处理。
Microsoft Graph API 拥有 超过 27,700 个端点,每周更新——这远远超出了 LLM 的训练截止日期。此技能将完整的 API 表面打包为本地索引,您可以即时搜索,无需网络调用。
| 索引 | 数量 | 包含内容 |
|---|---|---|
| OpenAPI 端点 | 27,700+ | 路径、方法、摘要、描述、权限范围 |
| 端点文档 | 6,200+ | 权限(委托/应用程序)、查询参数、必需标头、默认属性与仅 $select 属性 |
| 资源架构 | 4,200+ | 所有属性及其类型、支持的 $filter 操作符、默认/仅选择标志 |
| 社区示例 | 增长中 | 经过人工验证的查询,将自然语言任务映射到确切的 API 调用 |
msgraph CLI 已与此技能捆绑。通过此技能目录中的启动器脚本运行所有命令:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
bash <path-to-this-skill>/scripts/run.sh <command> [args...]powershell <path-to-this-skill>/scripts/run.ps1 <command> [args...]例如,要在 macOS 上搜索与邮件相关的 API:
bash /home/user/.opencode/skills/msgraph/scripts/run.sh openapi-search --query "send mail"
在以下所有示例中,msgraph 是完整启动器调用的简写。
这是此技能的主要目的。遵循此渐进式查找策略——每一级都增加更多细节:
/me、/users、/groups)。sample-search — 精选的、经过人工验证的示例。质量最高。用于常见任务和多步骤工作流。api-docs-search — 每个端点的权限、支持的查询参数、必需标头、默认属性与仅 $select 属性,以及带有筛选操作符的资源属性详细信息。openapi-search — 27,700 个 Graph API 的完整目录。当您无法通过其他方式找到端点时使用。此顺序仅供参考——请根据任务进行调整。例如,如果您已经知道端点但需要其权限,可以直接跳转到 api-docs-search。
搜索精选的社区示例,这些示例将自然语言任务映射到确切的 Microsoft Graph API 查询:
msgraph sample-search --query "conditional access policies"
msgraph sample-search --product entra
msgraph sample-search --query "managed devices" --product intune
| 标志 | 描述 |
|---|---|
--query | 自由文本搜索(搜索意图和查询字段) |
--product | 按产品筛选:entra、intune、exchange、teams、sharepoint、security、general |
--limit | 最大结果数(默认 10) |
至少需要 --query 或 --product 中的一个。结果包括多步骤工作流。
查找特定端点或资源类型的详细文档:
msgraph api-docs-search --endpoint /users --method GET
msgraph api-docs-search --resource user
msgraph api-docs-search --query "ConsistencyLevel"
| 标志 | 描述 |
|---|---|
--endpoint | 按端点路径搜索(例如 /users、/me/messages) |
--resource | 按资源类型名称搜索(例如 user、group、message) |
--method | 按 HTTP 方法筛选:GET、POST、PUT、PATCH |
--query | 在所有字段中进行自由文本搜索 |
--limit | 最大结果数(默认 10) |
至少需要 --endpoint、--resource 或 --query 中的一个。
端点结果 包括:所需权限(委托工作/学校、委托个人、应用程序)、支持的 OData 查询参数、必需标头、默认属性以及端点特定说明。
资源结果 包括:所有属性及其类型、支持的 $filter 操作符(eq、ne、startsWith 等),以及每个属性是默认返回还是需要 $select。
搜索包含 27,700 个 Microsoft Graph API 的完整 OpenAPI 目录:
msgraph openapi-search --query "send mail"
msgraph openapi-search --resource messages --method GET
| 标志 | 描述 |
|---|---|
--query | 自由文本搜索(搜索路径、摘要、描述) |
--resource | 按资源名称筛选(例如 users、groups、messages) |
--method | 按 HTTP 方法筛选 |
--limit | 最大结果数(默认 20) |
至少需要 --query、--resource 或 --method 中的一个。
如果代理可以访问 Microsoft Graph MCP 服务器(例如 lokka.dev 或任何其他 Microsoft Graph MCP 服务器),请使用上述搜索工具查找正确的端点、权限和请求语法,然后将信息与 MCP 服务器一起用于执行。
在此模式下,无需通过此技能进行身份验证。该技能纯粹充当知识层——MCP 服务器处理身份验证和 API 执行。
当没有可用的 Graph MCP 服务器时,此技能可以验证到 Microsoft 365 并直接执行 Microsoft Graph API 调用。
该工具支持 委托(用户) 和 仅应用(应用程序) 身份验证,可从环境变量自动检测。
快速开始:
msgraph auth status # 检查是否已登录
msgraph auth signin # 登录(打开浏览器)- 推荐
msgraph auth signin --device-code # 通过设备代码登录(无头环境)
msgraph auth signout # 清除会话
MSGRAPH_CLIENT_SECRET、MSGRAPH_CLIENT_CERTIFICATE_PATH、MSGRAPH_FEDERATED_TOKEN_FILE 或 MSGRAPH_AUTH_METHOD=managed-identity 时自动检测。需要 MSGRAPH_TENANT_ID。有关详细的身份验证配置,包括证书、托管身份、工作负载身份联合以及所有环境变量,请参阅 references/docs/authentication.md。
重要提示:在会话中首次执行 graph-call 之前,请运行 msgraph auth status 以验证身份验证。
msgraph graph-call <METHOD> <URL> [flags]
msgraph graph-call GET /me
msgraph graph-call GET /users --select "displayName,mail" --top 10
msgraph graph-call GET /me/messages --filter "isRead eq false" --top 5 --select "subject,from,receivedDateTime"
msgraph graph-call GET /users --filter "startsWith(displayName,'John')"
重要提示:在执行任何写入操作之前,您必须向用户请求确认。写入操作需要 --allow-writes 标志。
msgraph graph-call POST /me/sendMail --body '{"message":{"subject":"Hello","body":{"content":"Hi"},"toRecipients":[{"emailAddress":{"address":"user@example.com"}}]}}' --allow-writes
msgraph graph-call PATCH /me --body '{"jobTitle":"Engineer"}' --allow-writes
无论标志如何,DELETE 操作始终被阻止。
| 标志 | 描述 | 示例 |
|---|---|---|
--select | OData $select | --select "displayName,mail" |
--filter | OData $filter | --filter "isRead eq false" |
--top | OData $top(限制结果) | --top 10 |
--expand | OData $expand | --expand "members" |
--orderby | OData $orderby | --orderby "displayName desc" |
--api-version | v1.0 或 beta(默认:beta) | --api-version v1.0 |
--scopes | 请求额外的权限范围 | --scopes "Mail.Read" |
--headers | 自定义 HTTP 标头 | --headers "ConsistencyLevel:eventual" |
--body | 请求正文(JSON) | --body '{"key":"value"}' |
--output | json(默认)或 raw | --output raw |
--allow-writes | 允许 POST/PUT/PATCH(需要用户确认) |
--select 来减少响应大小 — 仅请求您需要的字段。--top 来限制结果 — 避免获取数千条记录。$count 和 $search 是必需的。使用 --headers "ConsistencyLevel:eventual"。--api-version v1.0。graph-call 之前检查身份验证状态。--allow-writes — 您必须首先与用户确认。statusCode 和 body 字段。| 状态码 | 含义 | 操作 |
|---|---|---|
| 401 | 令牌过期 | 再次运行 msgraph auth signin |
| 403 | 权限不足 | 工具会自动使用增量同意重试。如果仍然失败,用户需要管理员同意。 |
| 404 | 资源未找到 | 验证端点路径 |
| 429 | 速率限制 | 等待 Retry-After 持续时间,然后重试 |
| 变量 | 描述 | 默认值 |
|---|---|---|
MSGRAPH_CLIENT_ID | 自定义 Entra ID 应用客户端 ID | Microsoft Graph CLI Tools 应用 |
MSGRAPH_TENANT_ID | 目标租户 ID(仅应用身份验证必需) | common |
MSGRAPH_API_VERSION | 默认 API 版本 | beta |
MSGRAPH_INDEX_DB_PATH | OpenAPI 索引数据库路径 | 自动检测 |
MSGRAPH_SAMPLES_DB_PATH | 示例索引数据库路径 | 自动检测 |
MSGRAPH_API_DOCS_DB_PATH | API 文档索引数据库路径 | 自动检测 |
MSGRAPH_NO_TOKEN_CACHE | 禁用持久令牌缓存(仅内存) | false |
有关完整的身份验证环境变量列表,请参阅 references/docs/authentication.md。
搜索工具完全离线运行,无需网络访问。直接 API 执行需要访问 login.microsoftonline.com 和 graph.microsoft.com 的网络。交互式身份验证使用系统浏览器;在无头环境中回退到设备代码流程。
在需要特定指导时按需加载这些文件。请勿预先加载它们。
| 文件 | 何时阅读 | 大小 |
|---|---|---|
| references/REFERENCE.md | 常见资源路径、OData 模式、权限范围 | ~230 行 |
| references/docs/authentication.md | 详细身份验证配置:证书、托管身份、工作负载身份、所有环境变量 | ~200 行 |
| references/docs/query-parameters.md | OData $select、$filter、$expand、$top、$orderby、$search 语法和注意事项 | ~300 行 |
| references/docs/advanced-queries.md | ConsistencyLevel 标头、$count、$search、目录对象上的 ne/not/endsWith | ~190 行 |
| references/docs/paging.md | @odata.nextLink 分页、服务器端与客户端分页 | ~50 行 |
| references/docs/batching.md | $batch 端点、组合多个请求、dependsOn 排序 | ~280 行 |
| references/docs/throttling.md | 429 处理、Retry-After、退避策略 | ~90 行 |
| references/docs/errors.md | HTTP 状态码、错误响应格式、错误代码 | ~105 行 |
| references/docs/best-practices.md | 用于性能的 $select、分页、增量查询、批处理 | ~155 行 |
每周安装量
151
代码库
GitHub 星标数
37
首次出现
2026年3月2日
安全审计
安装于
codex149
gemini-cli149
kimi-cli149
cursor149
opencode149
github-copilot149
Search, look up, and call any of the 27,700+ Microsoft Graph APIs — all locally, no network calls needed. Use the three search commands to find the right endpoint, check permissions and parameters, then optionally execute calls directly or hand off to a Graph MCP server.
The Microsoft Graph API has 27,700+ endpoints updated weekly — well past LLM training cutoffs. This skill bundles the complete API surface as local indexes that you search instantly with no network calls.
| Index | Count | What it contains |
|---|---|---|
| OpenAPI endpoints | 27,700+ | Path, method, summary, description, permission scopes |
| Endpoint docs | 6,200+ | Permissions (delegated/app), query parameters, required headers, default vs $select-only properties |
| Resource schemas | 4,200+ | All properties with types, supported $filter operators, default/select-only flags |
| Community samples | Growing | Hand-verified queries mapping natural-language tasks to exact API calls |
The msgraph CLI is bundled with this skill. Run all commands through the launcher script in this skill's directory:
bash <path-to-this-skill>/scripts/run.sh <command> [args...]powershell <path-to-this-skill>/scripts/run.ps1 <command> [args...]For example, to search for mail-related APIs on macOS:
bash /home/user/.opencode/skills/msgraph/scripts/run.sh openapi-search --query "send mail"
In all examples below, msgraph is shorthand for the full launcher invocation.
This is the primary purpose of the skill. Follow this progressive lookup strategy — each level adds detail:
/me, /users, /groups).sample-search — curated, hand-verified samples. Highest quality. Use for common tasks and multi-step workflows.api-docs-search — per-endpoint permissions, supported query parameters, required headers, default vs $select-only properties, and resource property details with filter operators.openapi-search — full catalog of 27,700 Graph APIs. Use when you cannot find the endpoint any other way.This order is guidance — adapt based on the task. For example, jump straight to api-docs-search if you already know the endpoint but need its permissions.
Search curated community samples that map natural-language tasks to exact Microsoft Graph API queries:
msgraph sample-search --query "conditional access policies"
msgraph sample-search --product entra
msgraph sample-search --query "managed devices" --product intune
| Flag | Description |
|---|---|
--query | Free-text search (searches intent and query fields) |
--product | Filter by product: entra, intune, exchange, teams, sharepoint, security, general |
At least one of --query or --product is required. Results include multi-step workflows.
Look up detailed documentation for a specific endpoint or resource type:
msgraph api-docs-search --endpoint /users --method GET
msgraph api-docs-search --resource user
msgraph api-docs-search --query "ConsistencyLevel"
| Flag | Description |
|---|---|
--endpoint | Search by endpoint path (e.g. /users, /me/messages) |
--resource | Search by resource type name (e.g. user, group, message) |
--method | Filter by HTTP method: GET, , , |
At least one of --endpoint, --resource, or --query is required.
Endpoint results include: required permissions (delegated work/school, delegated personal, application), supported OData query parameters, required headers, default properties, and endpoint-specific notes.
Resource results include: all properties with types, supported $filter operators (eq, ne, startsWith, etc.), and whether each property is returned by default or requires $select.
Search the full OpenAPI catalog of 27,700 Microsoft Graph APIs:
msgraph openapi-search --query "send mail"
msgraph openapi-search --resource messages --method GET
| Flag | Description |
|---|---|
--query | Free-text search (searches path, summary, description) |
--resource | Filter by resource name (e.g. users, groups, messages) |
--method | Filter by HTTP method |
--limit | Max results (default 20) |
At least one of --query, --resource, or --method is required.
If the agent has access to a Microsoft Graph MCP server (such as lokka.dev or any other Microsoft Graph MCP server), use the search tools above to find the right endpoint, permissions, and request syntax, then use the information with the MCP server for execution.
In this mode, no authentication through this skill is needed. The skill acts purely as a knowledge layer — the MCP server handles authentication and API execution.
When no Graph MCP server is available, this skill can authenticate to Microsoft 365 and execute Microsoft Graph API calls directly.
The tool supports delegated (user) and app-only (application) authentication, auto-detected from environment variables.
Quick start:
msgraph auth status # check if signed in
msgraph auth signin # sign in (opens browser) - recommended
msgraph auth signin --device-code # sign in via device code (headless)
msgraph auth signout # clear the session
MSGRAPH_CLIENT_SECRET, MSGRAPH_CLIENT_CERTIFICATE_PATH, MSGRAPH_FEDERATED_TOKEN_FILE, or MSGRAPH_AUTH_METHOD=managed-identity is set. Requires MSGRAPH_TENANT_ID.For detailed authentication configuration including certificates, managed identity, workload identity federation, and all environment variables, see references/docs/authentication.md.
IMPORTANT : Run msgraph auth status before the first graph-call in a session to verify authentication.
msgraph graph-call <METHOD> <URL> [flags]
msgraph graph-call GET /me
msgraph graph-call GET /users --select "displayName,mail" --top 10
msgraph graph-call GET /me/messages --filter "isRead eq false" --top 5 --select "subject,from,receivedDateTime"
msgraph graph-call GET /users --filter "startsWith(displayName,'John')"
IMPORTANT : YOU MUST ask the user for confirmation before any write operation. Write operations require the --allow-writes flag.
msgraph graph-call POST /me/sendMail --body '{"message":{"subject":"Hello","body":{"content":"Hi"},"toRecipients":[{"emailAddress":{"address":"user@example.com"}}]}}' --allow-writes
msgraph graph-call PATCH /me --body '{"jobTitle":"Engineer"}' --allow-writes
DELETE is always blocked regardless of flags.
| Flag | Description | Example |
|---|---|---|
--select | OData $select | --select "displayName,mail" |
--filter | OData $filter | --filter "isRead eq false" |
--top | OData $top (limit results) | --top 10 |
--expand |
--select to reduce response size — only request fields you need.--top to limit results — avoid fetching thousands of records.$count and $search on directory objects (users, groups, etc.). Use --headers "ConsistencyLevel:eventual".--api-version v1.0 for production-stable endpoints.graph-call in a session.--allow-writes — YOU MUST confirm with the user first.statusCode and body fields from the response.| Status | Meaning | Action |
|---|---|---|
| 401 | Token expired | Run msgraph auth signin again |
| 403 | Insufficient permissions | Tool auto-retries with incremental consent. If still fails, user needs admin consent. |
| 404 | Resource not found | Verify the endpoint path |
| 429 | Rate limited | Wait for Retry-After duration, then retry |
| Variable | Description | Default |
|---|---|---|
MSGRAPH_CLIENT_ID | Custom Entra ID app client ID | Microsoft Graph CLI Tools app |
MSGRAPH_TENANT_ID | Target tenant ID (required for app-only) | common |
MSGRAPH_API_VERSION | Default API version | beta |
MSGRAPH_INDEX_DB_PATH | Path to OpenAPI index database |
For the full list of authentication environment variables, see references/docs/authentication.md.
Search tools run fully offline with no network access required. Direct API execution requires network access to login.microsoftonline.com and graph.microsoft.com. A system browser is used for interactive auth; falls back to device code flow in headless environments.
Load these on demand when you need specific guidance. Do NOT load them preemptively.
| File | When to Read | Size |
|---|---|---|
| references/REFERENCE.md | Common resource paths, OData patterns, permission scopes | ~230 lines |
| references/docs/authentication.md | Detailed auth configuration: certificates, managed identity, workload identity, all env vars | ~200 lines |
| references/docs/query-parameters.md | OData $select, $filter, $expand, $top, $orderby, $search syntax and gotchas | ~300 lines |
| references/docs/advanced-queries.md | ConsistencyLevel header, $count, $search, ne/not/endsWith on directory objects | ~190 lines |
| references/docs/paging.md | @odata.nextLink pagination, server-side vs client-side paging | ~50 lines |
Weekly Installs
151
Repository
GitHub Stars
37
First Seen
Mar 2, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex149
gemini-cli149
kimi-cli149
cursor149
opencode149
github-copilot149
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
155,300 周安装
--limit | Max results (default 10) |
POSTPUTPATCH--query | Free-text search across all fields |
--limit | Max results (default 10) |
| OData $expand |
--expand "members" |
--orderby | OData $orderby | --orderby "displayName desc" |
--api-version | v1.0 or beta (default: beta) | --api-version v1.0 |
--scopes | Request additional permission scopes | --scopes "Mail.Read" |
--headers | Custom HTTP headers | --headers "ConsistencyLevel:eventual" |
--body | Request body (JSON) | --body '{"key":"value"}' |
--output | json (default) or raw | --output raw |
--allow-writes | Allow POST/PUT/PATCH (requires user confirmation) |
| Auto-detected |
MSGRAPH_SAMPLES_DB_PATH | Path to samples index database | Auto-detected |
MSGRAPH_API_DOCS_DB_PATH | Path to API docs index database | Auto-detected |
MSGRAPH_NO_TOKEN_CACHE | Disable persistent token cache (in-memory only) | false |
| references/docs/batching.md | $batch endpoint, combining multiple requests, dependsOn sequencing | ~280 lines |
| references/docs/throttling.md | 429 handling, Retry-After, backoff strategy | ~90 lines |
| references/docs/errors.md | HTTP status codes, error response format, error codes | ~105 lines |
| references/docs/best-practices.md | $select for performance, pagination, delta queries, batching | ~155 lines |