MindForgeCollective/MCP_server_GraphAPI
If you are the rightful owner of MCP_server_GraphAPI and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This document provides a comprehensive guide to setting up a Simple MCP Server with Microsoft OAuth Authentication, demonstrating integration with Microsoft Graph APIs for various functionalities.
get_user_profile
Returns the authenticated user's Microsoft Graph profile
list_emails
Reads the latest emails from the inbox
send_email
Sends an email
create_meeting
Creates a calendar event
list_events
Lists upcoming events
get_user_schedule
Retrieves another user's calendar
get_team_availability
Returns free/busy availability for a list of attendees
update_event
Updates an existing event
delete_event
Deletes an event
Simple MCP Server with Microsoft OAuth Authentication
An example of an MCP server using Microsoft OAuth (v2.0) for user authentication. It demonstrates the essential components for OAuth integration, with various tools based on Microsoft Graph APIs.
Overview
This demo guides you through setting up a server with:
-
OAuth2 authorization flow against Microsoft Azure AD (v2.0 endpoint)
-
Tools for:
- Retrieving the authenticated user's Microsoft Graph profile
- Reading and sending emails
- Creating, reading, updating, and deleting calendar events
- Checking team availability (free/busy)
Prerequisites
-
Register an app in Azure AD:
-
Log in to the Azure portal: https://portal.azure.com
-
Navigate to Azure Active Directory > App registrations > New registration
- Name: e.g., "Simple MCP Microsoft Auth"
- Supported account types: Accounts in any organizational directory ("Multitenant") + personal Microsoft accounts
- Redirect URI (Web):
http://localhost:8000/microsoft/callback
-
Click Register and note down:
- Application (client) ID
- Directory (tenant) ID
-
Go to Certificates & secrets, create a New client secret, and note its value.
-
-
Ensure you have Python 3.9+ and either
poetry
orpip
installed.
Required Environment Variables
Before running the server, set the following environment variables:
export MCP_MICROSOFT_MICROSOFT_CLIENT_ID="your-application-client-id"
export MCP_MICROSOFT_MICROSOFT_CLIENT_SECRET="your-client-secret"
export MCP_MICROSOFT_MICROSOFT_CALLBACK_PATH="http://localhost:8000/microsoft/callback"
Installation & Running
- Install dependencies:
uv pip install .
- Start the server:
uv run mcp_microsoft_auth --host localhost --port 8000 --transport streamable-http
If --transport
is not specified, sse will be used as default
Endpoints
- SSE endpoint: `/sse`
- Streamable HTTP endpoint: `/mcp`
Available Tools
Tool | Description | Required Scope |
---|---|---|
get_user_profile | Returns the authenticated user's Microsoft Graph profile | user |
list_emails | Reads the latest emails from the inbox (count parameter) | mail.read |
send_email | Sends an email (to , subject , body ) | mail.send |
create_meeting | Creates a calendar event (subject , attendees , start , duration ) | calendars.readwrite |
list_events | Lists upcoming events (from_now_minutes , next_hours , max_results ) | calendars.read |
get_user_schedule | Retrieves another user's calendar (user_email , start_datetime , end_datetime ) | calendars.read.shared |
get_team_availability | Returns free/busy availability for a list of attendees | calendars.read |
update_event | Updates an existing event (event_id , updates ) | calendars.readwrite |
delete_event | Deletes an event (event_id ) | calendars.readwrite |
Troubleshooting
- Verify the environment variables:
MCP_MICROSOFT_MICROSOFT_CLIENT_ID
MCP_MICROSOFT_MICROSOFT_CLIENT_SECRET
MCP_MICROSOFT_MICROSOFT_CALLBACK_PATH
- Ensure the callback URL in Azure AD exactly matches the one configured.
- Confirm no other service is using port 8000.
- Check that the transport (
sse
orstreamable-http
) is valid. - Inspect console logs for any errors from Microsoft Graph API responses.
To test the server, you can use Inspector or tools like curl
/ Postman.