MCP-MSGraph

by kevinbellinger

221 downloads
Not rated
GitHub

About

A prototype MCP server which reads a user profile from Microsoft Graph.

Details

Author
kevinbellinger
Downloads
221
Categories
Other

- Reads a user profile from Microsoft Graph via a single MCP action (readUserProfile)
- Uses OAuth2 authentication with Azure AD
- Runs as a local FastAPI server
- Accepts requests over HTTP at the /mcp endpoint

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name MCP-MSGraph
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Clone the repository, create a Python virtual environment, install the required packages (fastapi, uvicorn, requests, requests-oauthlib, pydantic), then edit main.py to replace placeholder values with your Azure AD Application ID, Tenant ID, and Client Secret. Start the server with uvicorn main:app --reload and send an HTTP POST request to http://localhost:8000/mcp with a JSON body containing action, contextId, and data.userId.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mcp-msgraph": {
            "mcp-msgraph": {
                "command": "python3",
                "args": [
                    "-m",
                    "venv",
                    "venv"
                ]
            }
        }
    }
}

McpServers

{
    "mcp-msgraph": {
        "command": "python3",
        "args": [
            "-m",
            "venv",
            "venv"
        ]
    }
}

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

3. Install the required packages:

pip install fastapi uvicorn requests requests-oauthlib pydantic

4. Open 'main.py' and replace the placeholder values with your App ID, Tenant ID, and Client Secret.

5. 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":"someUser@yourtenant.onmicrosoft.com"}
      }'

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","account@odata.context":"https://graph.microsoft.com/beta/$metadata#users('adelev%40M365x17584779.onmicrosoft.com')/profile/account","account":[{"ageGroup":"","countryCode":"","userPrincipalName":"AdeleV@M365x17584779.OnMicrosoft.com","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"]}]}]}}%  
No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.