MCP_server_GraphAPI

MindForgeCollective/MCP_server_GraphAPI

3.2

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.

Tools
  1. get_user_profile

    Returns the authenticated user's Microsoft Graph profile

  2. list_emails

    Reads the latest emails from the inbox

  3. send_email

    Sends an email

  4. create_meeting

    Creates a calendar event

  5. list_events

    Lists upcoming events

  6. get_user_schedule

    Retrieves another user's calendar

  7. get_team_availability

    Returns free/busy availability for a list of attendees

  8. update_event

    Updates an existing event

  9. 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

  1. 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.

  2. Ensure you have Python 3.9+ and either poetry or pip 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

  1. Install dependencies:
uv pip install .
  1. 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

ToolDescriptionRequired Scope
get_user_profileReturns the authenticated user's Microsoft Graph profileuser
list_emailsReads the latest emails from the inbox (count parameter)mail.read
send_emailSends an email (to, subject, body)mail.send
create_meetingCreates a calendar event (subject, attendees, start, duration)calendars.readwrite
list_eventsLists upcoming events (from_now_minutes, next_hours, max_results)calendars.read
get_user_scheduleRetrieves another user's calendar (user_email, start_datetime, end_datetime)calendars.read.shared
get_team_availabilityReturns free/busy availability for a list of attendeescalendars.read
update_eventUpdates an existing event (event_id, updates)calendars.readwrite
delete_eventDeletes an event (event_id)calendars.readwrite

Troubleshooting

  1. Verify the environment variables:
    • MCP_MICROSOFT_MICROSOFT_CLIENT_ID
    • MCP_MICROSOFT_MICROSOFT_CLIENT_SECRET
    • MCP_MICROSOFT_MICROSOFT_CALLBACK_PATH
  2. Ensure the callback URL in Azure AD exactly matches the one configured.
  3. Confirm no other service is using port 8000.
  4. Check that the transport (sse or streamable-http) is valid.
  5. Inspect console logs for any errors from Microsoft Graph API responses.

To test the server, you can use Inspector or tools like curl / Postman.