Navigation
MCP-MSGraph: Seamless Profile Sync & Smarter Workflows - MCP Implementation

MCP-MSGraph: Seamless Profile Sync & Smarter Workflows

Meet MCP-MSGraph: Seamlessly pull user profiles from Microsoft Graph into your apps – empowering smarter, integrated workflows without the hassle. Next-gen prototyping, today.

Developer Tools
4.7(77 reviews)
115 saves
53 comments

This tool saved users approximately 11426 hours last month!

About MCP-MSGraph

What is MCP-MSGraph: Seamless Profile Sync & Smarter Workflows?

MCP-MSGraph is a prototype server built using the Model Context Protocol (MCP) to fetch user profiles from Microsoft Graph. It bridges MCP capabilities with Microsoft's cloud services, enabling seamless integration of user data into workflows. This project showcases how MCP can dynamically sync profile information and enhance application logic with real-time identity data.

How to Use MCP-MSGraph: Seamless Profile Sync & Smarter Workflows?

Get started by setting up an Azure AD app to grant permissions, then configure the server with your credentials. Run the FastAPI-based service locally to send requests that fetch user profiles via MCP endpoints. The process involves cloning the repo, installing dependencies, and adjusting config values—making it easy to test profile sync in your dev environment.

MCP-MSGraph Features

Key Features of MCP-MSGraph: Seamless Profile Sync & Smarter Workflows?

  • Native Microsoft Integration: Leverages Azure AD for secure authentication and Microsoft Graph API access.
  • Real-Time Profile Sync: Retrieves up-to-date user details directly from enterprise directories.
  • Flexible Workflow Triggers: Use MCP actions like readUserProfile to automate processes based on user attributes.
  • Lightweight Setup: Runs on standard Python tools (FastAPI, Uvicorn) with minimal configuration.

Use Cases of MCP-MSGraph: Seamless Profile Sync & Smarter Workflows?

MCP-MSGraph FAQ

FAQ from MCP-MSGraph: Seamless Profile Sync & Smarter Workflows?

Q: Do I need admin consent? Yes, API permissions require admin approval to access user data at scale.
Q: Can I use this with custom apps? Absolutely—MCP’s modular design lets you plug this server into existing systems via REST calls.
Q: What if the Graph API rate limits hit? Implement caching strategies or adjust permission scopes to balance load.

Content

MCP-MSGraph

A prototype MCP (Model Context Protocol) server that reads a user profile from Microsoft Graph.
This project demonstrates how to connect MCP to data stored in Microsoft Graph as a proof of concept.


Create an Azure AD Application

  1. Log into Azure Portal.
  2. Navigate to Azure Active Directory > App registrations > New registration.
  3. Create a new application.
  4. Note the generated Application (client) ID and Client Secret.
  5. Under API permissions , add User.Read.All (as delegated or application permission as appropriate) and grant admin consent.

Instructions to run the server:

  1. Clone the repository or setup your own folder and files structure.

  2. Create a virtual environment:

python3 -m venv venv
source venv/bin/activate
  1. Install the required packages:
pip install fastapi uvicorn requests requests-oauthlib pydantic
  1. Open 'main.py' and replace the placeholder values with your App ID, Tenant ID, and Client Secret.

  2. Start the server

uvicorn main:app --reload

Your server will be available at http://127.0.0.1:8000.


Example Request

Use curl (or any REST client) to send a request to retrieve a user’s profile:

curl -X POST http://localhost:8000/mcp \
  -H "Content-Type: application/json" \
  -d '{
        "action":"readUserProfile",
        "contextId":"abc123",
        "data": {"userId":"[[email protected]](/cdn-cgi/l/email-protection)"}
      }'

Result should look something like:

{"status":"success","action":"readUserProfile","contextId":"abc123","data":{"@odata.context":"https://graph.microsoft.com/beta/$metadata#users('adelev%40M365x17584779.onmicrosoft.com')/profile/$entity","id":"profileId","[[email protected]](/cdn-cgi/l/email-protection)":"https://graph.microsoft.com/beta/$metadata#users('adelev%40M365x17584779.onmicrosoft.com')/profile/account","account":[{"ageGroup":"","countryCode":"","userPrincipalName":"[[email protected]](/cdn-cgi/l/email-protection)","allowedAudiences":"organization","createdDateTime":"2025-01-30T11:06:01.7661211Z","lastModifiedDateTime":"2025-01-30T11:06:01.9431431Z","id":"c74cb3af-2f62-43fa-9709-5d2cfc4b4042","isSearchable":false,"inference":null,"preferredLanguageTag":{"locale":null,"displayName":null},"createdBy":{"user":null,"device":null,"application":{"displayName":"AAD","id":null}},"lastModifiedBy":{"user":null,"device":null,"application":{"displayName":"MsGraph","id":null}},"source":{"type":["AAD","MsGraph"]},"sources":[{"sourceId":"4ce763dd-9214-4eff-af7c-da491cc3782d","isDefaultSource":true},{"sourceId":"0024a795-114d-4031-95c7-5fb543e00e80","properties":["isSipEnabled"]}]},{"ageGroup":"","countryCode":"","userPrincipalName":"","allowedAudiences":"federatedOrganizations","createdDateTime":"2025-01-30T11:06:01.7661213Z","lastModifiedDateTime":"2025-01-30T11:06:01.9431431Z","id":"750f8cc2-2f72-4b38-88c6-531dfc5ed47f","isSearchable":false,"inference":null,"preferredLanguageTag":{"locale":null,"displayName":null},"createdBy":{"user":null,"device":null,"application":{"displayName":"AAD","id":null}},"lastModifiedBy":{"user":null,"device":null,"application":{"displayName":"MsGraph","id":null}},"source":{"type":["AAD","MsGraph"]},"sources":[{"sourceId":"4ce763dd-9214-4eff-af7c-da491cc3782d","isDefaultSource":true},{"sourceId":"0024a795-114d-4031-95c7-5fb543e00e80","properties":["isSipEnabled"]}]}]}}%

Related MCP Servers & Clients