Microsoft Graph (Entra) MCP server

Provides a secure bridge between Microsoft Graph API and AI systems for querying Microsoft 365 data without requiring direct access to credentials.
Back to servers
Provider
uniQuk
Release date
Apr 19, 2025
Language
Python
Stats
2 stars

The Microsoft Graph MCP Server allows AI assistants like Claude, GitHub Copilot, or Cursor Agent to access and query Microsoft Entra ID (formerly Azure Active Directory) data through a standardized Model Context Protocol interface, providing a secure way to interact with Microsoft Graph API.

Prerequisites

Before using this MCP server, you'll need:

  • Node.js 14+ and Python 3.8+
  • Microsoft Entra ID App Registration with appropriate permissions
  • API Keys for securing the MCP server (generated during setup, optional when used with AI assistants)

Installation

You can install the MCP server directly from GitHub:

# Global installation
npm install -g github:YOUR_USERNAME/mcp-entra

# Run the server
mcp-entra

On first run, you'll be guided through the setup process to configure your Microsoft Entra ID credentials.

Setting Up Microsoft Entra ID App Registration

Follow these steps to create the necessary app registration:

  1. Go to the Azure Portal
  2. Navigate to Azure Active Directory > App Registrations > New Registration
  3. Enter a name for your app (e.g., "Graph MCP Server")
  4. Select "Accounts in this organizational directory only" (single tenant)
  5. No redirect URI is needed - click "Register"
  6. Note down the Application (client) ID and Directory (tenant) ID
  7. Navigate to "Certificates & secrets" and create a new client secret
  8. Note down the secret value (you won't be able to see it again)
  9. Go to "API Permissions" and add the following permissions:
    • User.Read.All
    • Group.Read.All
    • (Add other permissions as needed for your use case)
  10. Click "Grant admin consent for [your tenant]"

AI Assistant Integration

Claude Desktop Configuration

{
  "mcpServers": {
    "Microsoft-Entra": {
      "command": "npx",
      "args": [
        "-y",
        "github:YOUR_USERNAME/mcp-entra"
      ],
      "env": {
        "TENANT_ID": "your-tenant-id",
        "CLIENT_ID": "your-client-id",
        "CLIENT_SECRET": "your-client-secret",
        "AI_ASSISTANT": "true"
      }
    }
  }
}

VS Code/GitHub Copilot Configuration

{
  "servers": {
    "Microsoft-Entra": {
      "type": "npm",
      "packageInfo": {
        "name": "github:uniQuk/mcp-entra"
      },
      "env": {
        "TENANT_ID": "your-tenant-id",
        "CLIENT_ID": "your-client-id",
        "CLIENT_SECRET": "your-client-secret",
        "AI_ASSISTANT": "true"
      }
    }
  }
}

Cursor Configuration

{
  "mcpServers": {
    "Microsoft-Entra": {
      "command": "npx",
      "args": [
        "-y",
        "github:uniQuk/mcp-entra"
      ],
      "env": {
        "TENANT_ID": "your-tenant-id",
        "CLIENT_ID": "your-client-id",
        "CLIENT_SECRET": "your-client-secret",
        "AI_ASSISTANT": "true"
      }
    }
  }
}

Available Tools

The MCP server provides these tools for interacting with Microsoft Entra ID:

  • listUsers - Retrieve a list of users from Microsoft Entra ID tenant
  • getUser - Retrieve a specific user by ID or UPN from Microsoft Entra ID tenant
  • searchUsers - Search for users by display name, email, etc.
  • listGroups - Retrieve a list of groups from Microsoft Entra ID tenant
  • getGroupMembers - Retrieve members of a specific group from Microsoft Entra ID tenant

Security Considerations

  • API key authentication is automatically bypassed when running with AI assistants
  • For non-AI usage, always use strong, unique API keys (the setup script generates one for you)
  • Store your client credentials securely
  • Consider deploying behind a reverse proxy for additional security
  • Set appropriate Microsoft Graph API permissions (least privilege)

Troubleshooting

Invalid API Key Error

  • Make sure the API key in your client configuration matches one of the keys in your environment variables
  • Or set AI_ASSISTANT=true in your environment variables when using with AI assistants

Authentication Error

  • Verify your Microsoft Graph client credentials are correct
  • Ensure the app has the required permissions and admin consent

MCP Connection Issues

  • Check that the server is running and accessible from your client
  • Verify the URL and transport configuration

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later