New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@sullyman/graph-mcp

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@sullyman/graph-mcp

MCP Server for Microsoft Graph API — multi-tenant MSP management

latest
npmnpm
Version
0.3.2
Version published
Maintainers
1
Created
Source

graph-mcp

MCP Server for Microsoft Graph API — multi-tenant MSP management without GDAP.

Lets Claude Code manage users, groups, licenses, devices, security, mail, calendar, Teams, SharePoint, and more across all your customer tenants through natural language. 101 tools across 19 categories covering the full Microsoft Graph API surface, plus 28 MSP workflow skills organized by certification tier (Fundamentals → Associate → Expert).

Prerequisites

  • Node.js 18+
  • That's it! No Azure App Registration needed for basic usage.

How? The server defaults to Microsoft Graph PowerShell SDK's well-known public client ID (14d82eec-204b-4c2f-b7e8-296a70dab67e). This is a Microsoft-published multi-tenant app with broad delegated permissions — no custom registration required. You can override with your own CLIENT_ID if needed.

Quick Start

# Clone and install
git clone https://github.com/your-org/graph-mcp.git
cd graph-mcp
npm install

# Build
npm run build

Add to Claude Code

Add to ~/.claude/mcp.json:

{
  "mcpServers": {
    "viyu-graph": {
      "command": "node",
      "args": ["/path/to/graph-mcp/dist/index.js"]
    }
  }
}

No CLIENT_ID env var needed. The server uses Microsoft's public client ID by default. To use your own app registration, add "env": { "CLIENT_ID": "your-app-id" } to the config above.

First Use — Onboarding a Tenant

Once the server is running in Claude Code, there's no need to manually edit tenant config files. Just say:

"Set up a new tenant called contoso"

Claude will call the onboard-tenant tool which:

  • Displays a Device Code URL + code in the terminal
  • You open the URL in your browser and sign in with Global Admin credentials
  • The tenant ID and domain are auto-detected and saved to config/tenants.json
  • You're authenticated and ready to go

Repeat for each customer tenant.

Azure App Registration (Optional)

By default, graph-mcp uses the Microsoft Graph PowerShell SDK public client ID — no app registration needed. The sections below are only relevant if you want to use your own custom app registration with CLIENT_ID env var.

Custom App Registration Setup (click to expand)
  • Go to Entra ID > App registrations
  • New registration
  • Name: Graph MCP
  • Supported account types: "Accounts in any organizational directory" (multi-tenant)
  • Redirect URI: Mobile and desktop applications → https://login.microsoftonline.com/common/oauth2/nativeclient
  • No client secret needed — Device Code uses PublicClientApplication

API Permissions (Delegated)

Add these delegated permissions under Microsoft Graph:

PermissionPurpose
User.ReadWrite.AllManage users
Group.ReadWrite.AllManage groups
Directory.ReadWrite.AllDirectory roles, org info
Organization.Read.AllTenant organization info
Domain.Read.AllVerified domains
Mail.ReadWriteRead and send email
Mail.SendSend email on behalf of users
Calendars.ReadWriteManage calendar events
DeviceManagementManagedDevices.ReadWrite.AllIntune device management
DeviceManagementConfiguration.Read.AllIntune configuration policies
SecurityEvents.ReadWrite.AllSecurity alerts and incidents
IdentityRiskyUser.Read.AllRisky user detection
IdentityRiskEvent.Read.AllRisk event detection
Policy.Read.AllConditional Access and auth policies
AuditLog.Read.AllSign-in and audit logs
Reports.Read.AllUsage reports
Team.ReadBasic.AllTeams management
Channel.ReadBasic.AllTeams channels
ChannelMessage.SendSend Teams messages
Sites.ReadWrite.AllSharePoint sites and OneDrive
Files.ReadWrite.AllOneDrive files
Application.Read.AllApp registrations
DelegatedPermissionGrant.ReadWrite.AllOAuth2 consent grants
RoleManagement.Read.DirectoryDirectory role memberships
UserAuthenticationMethod.Read.AllUser MFA method details

Grant admin consent in your MSP tenant.

For each customer tenant, have their Global Admin visit:

https://login.microsoftonline.com/{customer-tenant-id}/adminconsent?client_id={your-app-client-id}

Or use the onboard-tenant tool which handles this interactively.

Available Tools (101)

Tenant Management (6 tools)

ToolDescription
list-tenantsList all configured tenants
switch-tenantSwitch active tenant context
current-tenantShow current tenant
add-tenantRegister a new tenant manually
onboard-tenantInteractive setup: Device Code login + auto-detect + save config
remove-tenantRemove a tenant from config

Authentication (3 tools)

ToolDescription
loginDevice Code auth (URL + code shown in terminal)
logoutClear cached tokens
auth-statusCheck token status and expiry

Users (5 tools)

ToolDescription
list-usersList users with OData filtering ($filter, $select, $top)
get-userGet user by ID or UPN
create-userCreate new user
update-userUpdate user properties
reset-passwordReset user password

Groups (6 tools)

ToolDescription
list-groupsList groups with filtering
get-groupGet group details
create-groupCreate security or M365 group
list-group-membersList group members
add-group-memberAdd user to group
remove-group-memberRemove user from group

Directory (4 tools)

ToolDescription
get-organizationTenant/org info
list-domainsVerified domains
list-directory-rolesDirectory roles
list-role-membersMembers of a role

Applications (6 tools)

ToolDescription
list-applicationsApp registrations
get-applicationApp registration details
list-service-principalsEnterprise applications
get-service-principalEnterprise app details
list-app-role-assignmentsUser's app access
list-oauth2-permission-grantsConsent grants audit

Mail (5 tools)

ToolDescription
list-messagesList emails for a user
get-messageGet specific email
send-mailSend email on behalf of user
list-mail-foldersList mail folders
reply-to-messageReply / reply-all

Calendar (6 tools)

ToolDescription
list-eventsList calendar events
get-eventGet event details
create-eventCreate event (with Teams meeting option)
update-eventUpdate event
delete-eventDelete event
get-scheduleFree/busy availability check

Teams (6 tools)

ToolDescription
list-teamsList all teams
get-teamGet team details
list-channelsList channels in a team
create-channelCreate channel (standard/private/shared)
send-channel-messagePost message to channel
list-team-membersList team members

SharePoint & OneDrive (7 tools)

ToolDescription
list-sitesList/search SharePoint sites
get-siteGet site details
list-site-listsLists in a site
list-drivesDocument libraries for site or user
list-drive-itemsFiles and folders in a drive
search-drive-contentSearch files across SP/OneDrive
create-sharing-linkCreate sharing link for a file

Devices & Intune (8 tools)

ToolDescription
list-managed-devicesIntune managed devices
get-managed-deviceDevice details
sync-deviceTrigger device sync
reboot-deviceRemote reboot
wipe-deviceRemote wipe (destructive)
list-compliance-policiesCompliance policies
list-device-configurationsConfiguration profiles
list-detected-appsApps detected on devices

Security (8 tools)

ToolDescription
list-security-alertsSecurity alerts (Defender)
get-security-alertAlert details
update-security-alertUpdate alert status/classification
get-secure-scoresMicrosoft Secure Score
list-secure-score-profilesRecommended security actions
list-incidentsSecurity incidents
list-risky-usersRisky users (ID Protection)
list-risk-detectionsRisk detections

Policies (7 tools)

ToolDescription
list-conditional-access-policiesCA policies
get-conditional-access-policyCA policy details
list-named-locationsNamed locations (IP/country)
list-authentication-methods-policyMFA methods policy
list-user-auth-methodsUser's registered auth methods
list-authorization-policyGuest access settings
list-permission-grant-policiesApp consent policies

Licenses (4 tools)

ToolDescription
list-subscribed-skusAll licenses in tenant
assign-licenseAssign license to user
remove-licenseRemove license from user
license-usage-reportUtilization summary

Reports & Audit (5 tools)

ToolDescription
list-sign-in-logsSign-in logs (AAD P1/P2)
list-audit-logsDirectory audit logs
list-provisioning-logsApp provisioning logs
get-credential-user-registrationMFA/SSPR registration report
get-m365-usage-reportsM365 usage reports (email, Teams, OneDrive, etc.)

Contacts (4 tools)

ToolDescription
list-contactsList contacts for a user
get-contactGet contact details
create-contactCreate a new contact
delete-contactDelete a contact

Planner & To Do (7 tools)

ToolDescription
list-user-planner-plansUser's Planner plans
get-planner-planPlan details
list-planner-tasksTasks in a plan
list-user-planner-tasksAll tasks assigned to a user
list-planner-bucketsBuckets in a plan
list-todo-listsUser's To Do lists
list-todo-tasksTasks in a To Do list

Subscriptions (3 tools)

ToolDescription
list-subscriptionsActive webhook subscriptions
get-subscriptionSubscription details
delete-subscriptionRemove a subscription

Escape Hatch (1 tool)

ToolDescription
graph-requestRaw Graph API call (any method, path, query, body, version)

Install Skills (npm users)

If you installed via npm, use the built-in skill installer:

# Install skills to ~/.claude/skills/ (global)
npx graph-mcp --install-skills

# Install skills to a specific project
npx graph-mcp --install-skills /path/to/project

Restart Claude Code after installing skills.

Slash Commands (Skills)

These are Claude Code slash commands that orchestrate multiple tools into MSP workflows. Copy the .claude/commands/ directory into your project or global config to use them.

Tier 1: Fundamentals (Helpdesk / Tier-1 Support)

Skills designed for new hires and helpdesk techs — plain language, guided steps, no Graph API knowledge needed.

CommandDescription
/troubleshoot-userGuided user issue diagnosis — "can't log in", "no email", "Teams not working" with decision tree
/who-isQuick user lookup — one-glance card with profile, status, MFA, licenses, groups, and roles
/explain-tenantPlain-language tenant summary for client-facing reps and new MSP staff
/password-reset-guideGuided password reset — checks lockout, risk, MFA before resetting with helpdesk script

Tier 2: Associate (M365 Admins / Security Analysts)

Workflow automation for multi-step tasks that take 30-60 minutes in admin portals.

CommandDescription
/setup-tenantGuided walkthrough for adding a new tenant
/tenant-health-checkSecurity posture, MFA adoption, risky users, license utilization
/tenant-overviewQuick summary — org info, user count, domains, licenses
/security-reviewDeep security audit — MFA gaps, CA analysis, admin roles, app consent
/mfa-enforcement-checkMFA enrollment status, per-user registration, CA policy gaps
/app-consent-reviewThird-party app consent audit, overprivileged app detection
/license-auditLicense waste detection and optimization recommendations
/stale-accountsFind inactive, disabled, and orphaned accounts
/group-auditEmpty groups, no-owner groups, large groups, dynamic vs static
/device-compliance-reportManaged device compliance, OS breakdown, stale devices
/user-onboardCreate user, assign licenses, add to groups, send welcome email
/user-offboardDisable account, revoke sessions, remove licenses and groups
/investigate-userDeep dive into a user — profile, sign-ins, risk, auth methods
/conditional-access-wizardCA policy gap analysis against Microsoft-recommended baselines
/mail-flow-checkEmail delivery diagnostics — mailbox status, forwarding, license, folder sizes
/bulk-license-assignBatch license assign/remove across department or group with dry-run preview
/sign-in-analyzerSign-in log deep dive — geographic anomalies, impossible travel, brute force
/tenant-health-reportStandalone HTML health report with CSS gauges and NIST CSF alignment
/sync-licensing-to-itglueCross-MCP sync — push licensing data and contacts to ITGlue

Tier 3: Expert (Architects / MSP Leadership)

Cross-tenant intelligence, framework alignment (NIST, CIS, ITIL), and strategic reporting for QBRs.

CommandDescription
/cross-tenant-reportPortfolio-wide health report across all managed tenants
/zero-trust-assessmentNIST/CIS/Microsoft Zero Trust maturity scoring across 6 pillars
/tenant-comparisonSide-by-side tenant diff on security, MFA, CA, licenses, and admin hygiene
/change-auditTenant change tracking — audit logs, provisioning, sign-in anomalies, security alerts
/tenant-architecture-reviewExecutive-ready QBR report — governance, security, cost optimization, roadmap

Security

Tool Annotations

All 101 tools have structured annotations that Claude Code uses to determine confirmation behavior:

AnnotationToolsBehavior
readOnlyHint: trueGET operations (list-users, get-organization, etc.)No confirmation needed
destructiveHint: truewipe-device, delete-event, delete-subscription, remove-group-memberConfirmation required
idempotentHint: trueupdate-user, assign-license, update-security-alertSafe to retry

Audit Logging

Two layers of audit logging provide defense in depth:

  • Shell-based PostToolUse hook — captures every MCP tool invocation from any agent, writes to ~/.graph-mcp/audit.log
  • Structured TypeScript audit logger — captures Graph API HTTP mutations (POST/PATCH/DELETE) with severity levels and structured JSON on stderr

Audit log entries include:

  • Timestamp, severity (INFO/HIGH/CRITICAL), operation type
  • Tenant ID and resource path
  • Automatic sanitization of sensitive fields (tokens, passwords, secrets → [REDACTED])

Write Guard Hook

A PreToolUse hook gates destructive operations. The following tools require explicit user confirmation before execution:

  • wipe-device — remote wipe (data loss)
  • reset-password — credential change
  • delete-event, delete-subscription, delete-contact — permanent deletion
  • remove-group-member, remove-license — access revocation

Sensitive Data Sanitization

The audit logger automatically redacts values for keys containing: password, token, secret, authorization, client_id, api_key, refresh_token, access_token.

Environment Variables

VariableRequiredDefaultDescription
CLIENT_IDNoMS Graph PowerShell SDKAzure App Registration client ID (uses Microsoft's public client by default)
TENANTS_CONFIG_PATHNo./config/tenants.jsonPath to tenants config
GRAPH_API_VERSIONNov1.0Graph API version
LOG_LEVELNoinfoerror, warn, info, debug

Development

npm run dev         # Run with tsx (hot reload)
npm run build       # Build for production
npm run typecheck   # Type check without emitting
npm run lint        # ESLint
npm run inspector   # Test with MCP Inspector

Architecture

src/
├── index.ts              # Entry: stdio transport bootstrap
├── server.ts             # McpServer creation + tool registration
├── constants.ts          # Scopes, URLs, defaults
├── auth/                 # MSAL Device Code flow + token caching
│   ├── auth-manager.ts   # Per-tenant PCA instances, loginWithDiscovery
│   └── token-cache.ts    # ICachePlugin for file-based MSAL cache
├── tenants/              # Multi-tenant registry + switching
│   ├── tenant-manager.ts # Registry, resolve, add/remove, persist
│   └── tenant-config.ts  # JSON file I/O
├── graph/                # Authenticated Graph client + pagination
│   ├── graph-client.ts   # fetch wrapper, 429 retry, error parsing
│   └── pagination.ts     # OData @odata.nextLink follower
├── tools/                # MCP tool modules (one per category)
│   ├── tenant-tools.ts   # list/switch/add/onboard/remove tenant
│   ├── auth-tools.ts     # login/logout/status
│   ├── user-tools.ts     # CRUD users, reset password
│   ├── group-tools.ts    # CRUD groups, members
│   ├── directory-tools.ts
│   ├── application-tools.ts
│   ├── mail-tools.ts
│   ├── calendar-tools.ts
│   ├── teams-tools.ts
│   ├── sharepoint-tools.ts
│   ├── device-tools.ts
│   ├── security-tools.ts
│   ├── policy-tools.ts
│   ├── license-tools.ts
│   ├── reports-tools.ts
│   └── graph-explorer-tool.ts
├── types/                # TypeScript interfaces
└── utils/                # Logger (stderr), config, error classes

Key patterns:

  • Stderr-only logging — stdout is the MCP JSON-RPC channel
  • Per-tenant MSAL instances — lazily created, cached in memory
  • File-based token cache~/.graph-mcp/cache/{tenantId}.json
  • Auto-discovery onboardingonboard-tenant detects tenant ID from Device Code auth
  • Modular tools — each category in its own file, easy to extend

FAQs

Package last updated on 11 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts