graph-api

Rules for using the Microsoft Graph SDK, a programming library for Microsoft services such as Outlook mail and calendars. They cover authentication, fluent requests, pagination, and selecting response fields.

In plain words
What is it for?
Reading Microsoft Graph data through the project’s shared client, handling multi-page results, and requesting only approved email or calendar fields.
Why use it?
They prevent duplicated login logic and inconsistent or incomplete Graph API requests.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/titanzero/outlook-mcp/graph-api
Clone the repo
git clone --depth 1 https://github.com/titanzero/outlook-mcp

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 370 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin fork From a forked repository.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00370
Opus 5 $0.00000 $0.00185
Sonnet 5 $0.00000 $0.00074
Haiku 4.5 $0.00000 $0.00037

Measured yesterday against content hash 50cdf4d6f9c6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

graph-api scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/graph-api.mdc · 54 lines

What it actually says

Graph API Rules

Client Access

const { getGraphClient, graphGetPaginated } = require('../utils/graph-client');

const client = await getGraphClient();

getGraphClient() already handles auth via ensureAuthenticated(). Do not add standalone auth calls in handlers.

Fluent SDK Usage

Use the SDK fluent chain instead of raw HTTP requests:

const result = await client.api('/me/messages')
  .select(config.EMAIL_SELECT_FIELDS)
  .top(25)
  .orderby('receivedDateTime desc')
  .get();

Pagination

For endpoints that may exceed one page, use:

const response = await graphGetPaginated(client, 'me/messages', {
  $top: 50,
  $select: config.EMAIL_SELECT_FIELDS,
  $orderby: 'receivedDateTime desc',
}, maxCount);

graphGetPaginated() follows @odata.nextLink automatically up to maxCount items.

Field Selection

Always use selection constants from config.js:

  • EMAIL_SELECT_FIELDS
  • EMAIL_DETAIL_FIELDS
  • EMAIL_FULL_BODY_FIELDS
  • CALENDAR_SELECT_FIELDS

If a tool needs additional fields, update config.js first.

Auth Provider

utils/graph-client.js defines OutlookAuthProvider implementing the SDK's auth interface. It delegates to ensureAuthenticated() from auth/index.js. The client singleton is recreated if the token changes (e.g. after refresh).

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 54 lines · 0 tokens per session scan A 50cdf4d6f9c6

Subscribe to this mod's changes

graph-api is a cursor rule published in the GitHub repository titanzero/outlook-mcp (1 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 370 tokens. A static security scan graded it A with 0 findings. It comes from a forked repository.