Skip to main content
Glama
jairosoft-com

Microsoft Calendar MCP Server

Microsoft Calendar MCP Server

A Model Context Protocol (MCP) server for managing Microsoft Outlook calendar events using Microsoft Graph API. This server provides tools for fetching calendar events within specified date ranges and integrates seamlessly with Claude Desktop, MCP Inspector, and other MCP-compatible clients.

🚀 Current Status: Production-ready with dual transport support (stdio and SSE) for maximum compatibility.

Features

  • 📅 Fetch calendar events for specific users and date ranges

  • 🔐 Secure Microsoft Graph API authentication using Azure AD

  • 🌐 Support for timezone-aware operations

  • 🔧 FastMCP-based server with dual transport support:

    • stdio transport: For Claude Desktop and CLI clients

    • SSE transport: For MCP Inspector and web-based clients

  • 📊 Detailed event information including attendees and metadata

  • 🏥 Health check endpoint for monitoring

Related MCP server: Enhanced Outlook MCP Server

Prerequisites

  • Python 3.13 or higher

  • Azure AD application with appropriate Microsoft Graph API permissions:

    • Calendars.Read or Calendars.ReadWrite

    • User.Read (for accessing user information)

  • Service principal credentials (Client ID, Client Secret, Tenant ID)

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd mcp-server-outlook-calendar
  2. Install dependencies using UV:

    uv sync

Method 2: Using pip

  1. Clone the repository:

    git clone <repository-url>
    cd mcp-server-outlook-calendar
  2. Create and activate a virtual environment:

    python -m venv .venv
    source .venv/bin/activate  # On Unix/macOS
    # OR
    .venv\Scripts\activate  # On Windows
  3. Install dependencies:

    pip install -e ".[dev]"

Configuration

  1. Create a .env file in the project root with your Azure AD credentials:

    AZURE_TENANT_ID=your_tenant_id_here
    AZURE_CLIENT_ID=your_client_id_here
    AZURE_CLIENT_SECRET=your_client_secret_here
  2. Test your connection:

    # Using UV
    uv run python test_connection.py
    
    # Using pip
    python test_connection.py

Usage

Running the Server

Method 1: SSE Transport (for MCP Inspector)

# Using UV (recommended)
uv run python main.py

# Using pip
python main.py

Server will run on: http://0.0.0.0:8000 SSE Endpoint: http://0.0.0.0:8000/sse Health Check: http://0.0.0.0:8000/health

Method 2: Stdio Transport (for Claude Desktop)

# Using UV
uv run python -m ms_calendar.server

# Using pip
python -m ms_calendar.server

Running with Claude Desktop (MCP)

To integrate this server with Claude Desktop using MCP (Model Context Protocol):

  1. Add the server configuration to your Claude Desktop config file:

    On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json On Windows: %APPDATA%\Claude\claude_desktop_config.json

    {
      "mcpServers": {
        "ms-calendar": {
          "command": "python",
          "args": [
            "-m", "ms_calendar.server"
          ],
          "cwd": "/path/to/your/mcp-server-outlook-calendar"
        }
      }
    }

    Note: Update the cwd path to match your local project location.

  2. Restart Claude Desktop to load the new server configuration.

The server will be available as a tool within Claude Desktop for calendar operations.

As a Python Library

from ms_calendar.calendar_service import fetch_all_calendar_events, get_graph_client
from datetime import datetime, timedelta
import asyncio

async def main():
    # Get a Graph client
    graph_client = get_graph_client()
    
    # Fetch events for the next 7 days
    start_date = datetime.utcnow()
    end_date = start_date + timedelta(days=7)
    
    events = await fetch_all_calendar_events(
        graph_client=graph_client,
        user_id="user@example.com",
        start_date=start_date,
        end_date=end_date
    )
    
    for event in events:
        print(f"Event: {event.subject} - {event.start.date_time} to {event.end.date_time}")

if __name__ == "__main__":
    asyncio.run(main())

Running with MCP Inspector

For development and testing, you can use the MCP Inspector with SSE transport:

  1. Start the server in SSE mode:

    # Using UV (recommended)
    uv run python main.py
    
    # Using pip
    python main.py
  2. Run the MCP Inspector:

    npx @modelcontextprotocol/inspector
  3. Configure the inspector:

    • Transport Type: SSE

    • URL: http://127.0.0.1:8000/sse

    • The inspector will automatically open in your browser

Note: The SSE transport is currently marked as deprecated in favor of StreamableHttp, but it remains fully functional for MCP Inspector usage.

API Reference

get_calendar_events_time_specific

Fetch calendar events for a user within a specified date range using Microsoft Graph API.

Arguments:

  • user_id (str): Microsoft Graph user ID or email address (e.g., "user@example.com")

  • start (str): Start date in ISO format (default: "2025-06-16")

  • end (str): End date in ISO format (default: "2025-06-16")

  • timezone (str): IANA timezone identifier (default: "Asia/Manila")

Returns:

  • dict: JSON object containing:

    • count (int): Number of events found

    • events (list): Array of event objects with:

      • id (str): Event unique identifier

      • subject (str): Event title/subject

      • attendees (list): Array of attendee objects with email, name, and type

  • str: Error message if the operation fails

Example Response:

{
  "count": 2,
  "events": [
    {
      "id": "AAMkAGI2...",
      "subject": "Team Meeting",
      "attendees": [
        {
          "email": "john@example.com",
          "name": "John Doe",
          "type": "required"
        }
      ]
    }
  ]
}

/health

Health check endpoint for monitoring server status.

HTTP GET /health

Returns JSON:

  • {"status": "ok"}

Azure AD Setup

To use this server, you'll need to set up an Azure AD application:

  1. Register an Application:

    • Go to Azure Portal → Azure Active Directory → App registrations

    • Click "New registration"

    • Provide a name and select account types

    • Register the application

  2. Configure API Permissions:

    • Go to "API permissions" in your app

    • Add Microsoft Graph permissions:

      • Calendars.Read (to read calendar events)

      • User.Read (to read user information)

    • Grant admin consent for your organization

  3. Create Client Secret:

    • Go to "Certificates & secrets"

    • Create a new client secret

    • Copy the secret value (you won't see it again)

  4. Note Application Details:

    • Copy the Application (client) ID

    • Copy the Directory (tenant) ID

    • Use these in your .env file

Testing & Coverage

  • Tests use pytest, pytest-asyncio, and pytest-cov

  • Microsoft Graph API calls can be mocked for testing

  • Run all tests with:

    pytest
  • Generate an HTML coverage report with:

    pytest --cov=src --cov-report=html
    open htmlcov/index.html

Transport Support

SSE Transport (Server-Sent Events)

  • Entry Point: main.py

  • Port: 8000 (default)

  • Use Cases: MCP Inspector, web-based clients, development/testing

  • Features: Real-time communication, HTTP debugging support

  • Health Check: GET /health returns {"status": "ok"}

Stdio Transport

  • Entry Point: ms_calendar.server module

  • Use Cases: Claude Desktop, CLI clients, production deployments

  • Features: Lower overhead, direct process communication

Development

This project uses modern Python development tools:

  • Package Manager: UV (recommended) or pip

  • Framework: FastMCP for MCP server implementation

  • API Client: Microsoft Graph SDK for calendar access

  • Authentication: Azure Identity for secure Azure AD integration

  • Code Quality:

    • Black for code formatting (88-char line length)

    • Flake8 for linting with custom rules

    • MyPy for strict type checking

  • Testing: pytest with asyncio support and coverage reporting

  • Type Safety: Full mypy support with py.typed marker

Project Analysis

For a comprehensive technical analysis of this project, including architecture details, security considerations, and performance characteristics, see ANALYSIS.md.

References

Available Tools

1 tool
get_calendar_events_time_specificA

FastMCP tool: Fetch calendar events for a user using Microsoft Graph API.

Args: user_id: Microsoft Graph user ID. start: ISO datetime string for start. end: ISO datetime string for end. timezone: IANA timezone (default: UTC).

Returns: Dictionary of events or error message.

ParametersJSON Schema
NameRequiredDescriptionDefault
endNo2025-06-16
startNo2025-06-16
user_idYes
timezoneNoAsia/Manila

TDQS

A3.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states that it returns a dictionary or an error message; it does not mention authentication requirements, read-only guarantees, rate limits, pagination, or how the time range boundaries are handled. This is a substantial gap for a tool that accesses a user's calendar data.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded, starting with the core purpose before moving into arguments and return value. Each line contributes useful information, and there is no redundant filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple four-parameter tool, the description covers the basics of invocation and return behavior. Yet there are no annotations or output schema, and the description omits important context such as what 'dictionary of events' actually contains, error scenarios, and the discrepancy between the stated timezone default and the schema default. This is adequate but leaves meaningful gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, and the description does add meaning by labeling user_id as a Microsoft Graph user ID, start/end as ISO datetime strings, and timezone as an IANA timezone. However, the description states 'timezone (default: UTC)' while the input schema declares a default of 'Asia/Manila', creating a direct conflict that undermines reliability.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific action and resource: 'Fetch calendar events for a user using Microsoft Graph API.' This clearly identifies what the tool does without relying on the tool name. The resource and operation are unambiguous, even with no sibling tools to differentiate from.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context that this tool is used to retrieve a user's calendar events, with start/end/timezone inputs implying a time-bounded query. It does not discuss exclusions or alternatives, but there are no sibling tools or competing MCPs described, so the guidance is reasonably complete for a straightforward fetch operation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev0.1.0
    • First observedget_calendar_events_time_specific

TDQS

A3.5/5.0

Scored across 1 tool

Disambiguation5/5

There is only one tool, so there is no possibility of confusing it with another tool. Its purpose of fetching calendar events within a time range is clearly stated.

Naming Consistency4/5

The tool name follows a clear get_noun structure and is descriptive. However, the 'time_specific' suffix is a bit awkward and there is no broader naming pattern to evaluate with only one tool.

Tool Count2/5

A single tool for a Microsoft Calendar server is far too few for the apparent scope of the domain. Even a focused calendar server would typically need additional event and calendar management operations.

Completeness1/5

The server only supports fetching events for a time range. It lacks create, update, delete, calendar listing, and event detail operations, making the surface severely incomplete for calendar workflows.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers