msgraph-sdk
Helps your agent access Microsoft 365 data. It can connect to users, emails, calendars, and files.
What it does
This tool helps developers connect their programs to Microsoft 365 data like emails, calendars, and files. It simplifies authentication and calling Microsoft functions.
When to use it
- ✓When building an app that needs to read emails from an account.
- ✓When developing a program that schedules meetings in a calendar.
- ✓When creating a system that manages files in OneDrive or SharePoint.
Example of what to ask your AI
“How do I connect my Python app to user data in Microsoft 365?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
The program uses an 'SDK,' which is a set of pre-built tools, to communicate with Microsoft services. It handles security (who can access what) and the requests to retrieve or change data.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add github/awesome-copilot --skill msgraph-sdkOr download just the file:
curl -L https://raw.githubusercontent.com/github/awesome-copilot/main/skills/msgraph-sdk/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
Microsoft Graph SDK
Use this skill when integrating Microsoft Graph into an application to access Microsoft 365 data and services.
Always ground implementation in the current Microsoft Graph SDK documentation and SDK version for the target language rather than relying on memory alone.
Determine the target language first
- Use the .NET workflow when the project contains
.cs,.csproj, or.slnfiles, or when the user asks for C# guidance. Follow references/dotnet.md. - Use the TypeScript / JavaScript workflow when the project contains
package.json,.ts, or.jsfiles, or when the user asks for Node.js / browser guidance. Follow references/typescript.md. - Use the Python workflow when the project contains
.py,pyproject.toml, orrequirements.txt, or when the user asks for Python guidance. Follow references/python.md. - If multiple languages are present, match the language of the files being edited or ask the user.
Always consult live documentation
- Microsoft Graph overview: https://learn.microsoft.com/graph/overview
- Graph Explorer (try calls live): https://developer.microsoft.com/graph/graph-explorer
- Graph permissions reference: https://learn.microsoft.com/graph/permissions-reference
- Use Microsoft Docs MCP tooling when available to fetch current API shapes and SDK samples.
Authentication — choose the right pattern
Selecting the wrong auth flow is the most common Graph integration mistake. Apply this decision tree before writing any auth code:
| Scenario | Flow to use |
|---|---|
| Background service / daemon with no user | Client credentials (app-only) |
| Agent or API acting on behalf of a signed-in user | On-Behalf-Of (OBO) |
| App running in Azure (Function, Container App, VM) | Managed Identity (preferred over secrets) |
| CLI tool or local dev script | Device code or interactive browser |
| Single-page app (browser only) | Authorization code + PKCE |
- Never use client credentials when a user context is required — Graph enforces this at the permission level (application vs. delegated).
- Prefer
DefaultAzureCredentialin Azure-hosted apps; it tries managed identity first and falls back gracefully for local dev. - Never hardcode secrets. Use environment variables, Azure Key Vault, or the Secret Manager.
Core SDK usage patterns
Building the client
Always construct GraphServiceClient once and reuse it (it manages token caching internally).
Pass a credential from the Azure Identity library — never build raw HTTP clients manually.
Making calls
- Use the fluent builder API:
client.Users[userId].Messages.GetAsync(...). - Always
awaitasync calls. - Specify
$selectto limit returned fields — Graph returns large default payloads. - Use
$filterserver-side rather than filtering returned collections in memory. - Use
$expandto fetch related resources in a single call when relationships are small.
Pagination
Graph paginates collections. Never assume all items arrive in one response:
- Check for an
@odata.nextLinkon the response. - Use the SDK's
PageIteratorhelper (available in all three SDKs) to walk pages automatically. - Set
$topto control page size (max varies by resource, typically 999).
Advanced patterns
Batch requests
Combine up to 20 independent Graph calls into a single HTTP request using the $batch endpoint. Use batching when:
- Initializing data for a dashboard or agent that needs multiple resources upfront.
- Reducing latency in high-call-count operations.
Batch responses arrive out of order — match them by the id field you assigned each request.
Delta queries
Use delta queries to sync changes incrementally instead of polling full collections:
- First call:
GET /users/deltareturns all items + a@odata.deltaLink. - Subsequent calls: use the
deltaLinkto receive only what changed since the last sync. - Supported on: users, groups, messages, calendar events, Teams channels, and more.
- Store the
deltaLinkdurably (database, blob) between sync runs.
Change notifications (webhooks)
Subscribe to resource changes with POST /subscriptions:
- Graph delivers change events to your HTTPS notification URL.
- Subscriptions expire — renew them before
expirationDateTime(max varies by resource; typically 1–3 days for mail/calendar, up to 4230 minutes for users/groups).
…
FAQ
What is Microsoft Graph?
It's the gateway to access Microsoft 365 data and services, such as users, mail, calendars, and files.
What is an SDK?
It's a Software Development Kit, a set of tools that makes it easier to build programs that interact with a specific service, in this case, Microsoft Graph.
Why do I need to worry about authentication?
Authentication ensures that only authorized users or applications can access data, protecting sensitive information.
Details
Original description by the author
Integrate Microsoft Graph SDK into any project — .NET, TypeScript/JavaScript, or Python. Covers auth patterns (client credentials, OBO, managed identity), SDK setup, calling Graph APIs, batching, delta queries, change notifications, throttling, and permission scopes. Use when accessing Microsoft 365 data (users, mail, calendar, Teams, files, SharePoint) from any application type.
repo: github/awesome-copilot
Popularity
- GitHub stars
- 40k
- Ranking position
- #5241
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
acquire-codebase-knowledge
Helps your agent understand and document an existing code project. It's useful for onboarding new people or getting an overview of the architecture.
github/awesome-copilot
acreadiness-assess
Enables your agent to assess a project's readiness for AI and generate a report. It's useful for understanding how well a project is prepared to use AI tools.
github/awesome-copilot
acreadiness-generate-instructions
Helps your agent create instructions for AI tools based on an assessment. It's useful for improving how AI interacts with code and closing identified gaps.
github/awesome-copilot
acreadiness-policy
Enables your agent to help define or apply policies for AI project assessment. It's useful for standardizing how projects are evaluated and ensuring compliance.
github/awesome-copilot
Similar skills
api-connector-builder
Has your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
affaan-m/ECC
api-design
Helps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
affaan-m/ECC
backend-patterns
Helps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.
affaan-m/ECC