Outlook MCP Python

Outlook MCP Python

A Python-based MCP server for Microsoft Outlook integration using Microsoft Graph API, enabling email reading/sending, calendar management, and contact operations through Claude Desktop.

Category
Visit Server

README

Outlook MCP Python

A Python-based Microsoft Outlook integration using Microsoft Graph API, built with FastAPI and MCP framework.

Overview

This project provides a server implementation for Microsoft Outlook integration using the Microsoft Graph API. It includes authentication handling, mail operations, and various utility functions for working with Outlook data.

Features

  • Microsoft Graph API integration
  • OAuth2 authentication flow
  • Mail operations (send, read, manage)
  • FastAPI-based server implementation
  • Environment-based configuration
  • Logging functionality

Project Structure

  • auth/ - Authentication related modules
  • mail/ - Mail operation modules
  • utils/ - Utility functions
  • main.py - Main application entry point
  • server.py - Server configuration
  • config.py - Configuration settings
  • logger.py - Logging configuration
  • outlook_auth_server.py - Outlook authentication server implementation

Prerequisites

  • Python 3.8 or higher
  • Microsoft Azure account with registered application
  • Microsoft Graph API access

Installation

  1. Clone the repository:
git clone [repository-url]
cd mcp-outlook-python
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

Azure App Registration & Configuration

To use this MCP server you need to first register and configure an app in Azure Portal. The following steps will take you through the process of registering a new app, configuring its permissions, and generating a client secret.

App Registration

  1. Open Azure Portal in your browser
  2. Sign in with a Microsoft Work or Personal account
  3. Search for or cilck on "App registrations"
  4. Click on "New registration"
  5. Enter a name for the app, for example "Outlook MCP Server"
  6. Select the "Accounts in any organizational directory and personal Microsoft accounts" option
  7. In the "Redirect URI" section, select "Web" from the dropdown and enter "http://localhost:3333/auth/callback" in the textbox
  8. Click on "Register"
  9. From the Overview section of the app settings page, copy the "Application (client) ID" and enter it as the MS_CLIENT_ID in the .env file as well as the OUTLOOK_CLIENT_ID in the claude-config-sample.json file

App Permissions

  1. From the app settings page in Azure Portal select the "API permissions" option under the Manage section
  2. Click on "Add a permission"
  3. Click on "Microsoft Graph"
  4. Select "Delegated permissions"
  5. Search for the following permissions and slect the checkbox next to each one
    • offline_access
    • User.Read
    • Mail.Read
    • Mail.Send
    • Calendars.Read
    • Calendars.ReadWrite
    • Contacts.Read
  6. Click on "Add permissions"

Client Secret

  1. From the app settings page in Azure Portal select the "Certificates & secrets" option under the Manage section
  2. Switch to the "Client secrets" tab
  3. Click on "New client secret"
  4. Enter a description, for example "Client Secret"
  5. Select the longest possible expiration time
  6. Click on "Add"
  7. Copy the secret value and enter it as the MS_CLIENT_SECRET in the .env file as well as the OUTLOOK_CLIENT_SECRET in the claude-config-sample.json file

Configuration

  1. Create a .env file in the root directory with the following variables:
MS_CLIENT_ID=your-ms-client-id
MS_CLIENT_SECRET=your-ms-client-secret
MS_AUTH_SERVER_URL=your-ms-auth-server-url
  1. Update the configuration in config.py as needed.

Usage with Claude Desktop

  1. Copy the sample configuration from claude-config-sample.json to your Claude Desktop configuration
  2. Restart Claude Desktop
  3. Authenticate with Microsoft using the authenticate tool
  4. Use the email tools to manage your Outlook account

Authentication Flow

  1. Start a local authentication server on port 3333 (using outlook-auth-server.js)
  2. Use the authenticate tool to get an authentication URL
  3. Complete the authentication in your browser
  4. Tokens are stored in ~/.outlook-mcp-tokens.json

Troubleshooting

  • Authentication Issues: Check the token file and authentication server logs
  • API Call Failures: Check for detailed error messages in the response

Dependencies

  • fastapi
  • uvicorn
  • python-dotenv
  • pydantic
  • pydantic-settings
  • requests
  • aiohttp
  • mcp

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured