MCP Google Calendar Server with Persistent Auth

MCP Google Calendar Server with Persistent Auth

Enables AI assistants to list and create Google Calendar events using natural language, with persistent OAuth authentication via Redis.

Category
访问服务器

README

MCP Google Calendar Server with Persistent Auth

This project implements a Model Context Protocol (MCP) server for Google Calendar, featuring persistent OAuth 2.0 authentication using Redis. It allows AI assistants (like Claude or Custom Clients) to interact with your Google Calendar.

Features

  • Google Calendar Integration: List upcoming events and create new events.
  • Persistent Authentication: Uses Redis to store OAuth tokens securely, so you don't need to re-authenticate on every restart.
  • FastMCP Framework: Built on top of the modern FastMCP framework.
  • Client Implementation: Includes a sample client (client.py) using OpenAI's GPT-4o to demonstrate interaction.

Supported Tools

  1. list_events: Lists upcoming events from the user's primary calendar. Supports filtering by result count and minimum time.
  2. create_event: Creates a new event with a summary, start time, end time, and description.

Prerequisites

Before running this project, ensure you have the following:

  1. Python 3.12+: This project requires a recent version of Python.
  2. Redis Server: A running Redis instance is required for token storage.
  3. Google Cloud Project:
    • Enable the Google Calendar API.
    • Create OAuth 2.0 Client IDs (Desktop app).
    • Scopes: Ensure the client has access to https://www.googleapis.com/auth/calendar.events.
    • Redirect URI: If configured for web, ensure http://localhost:8000/auth/callback is allowed (FastMCP default). For Desktop/Installed App, this is handled automatically.
    • Download the JSON credentials or copy the Client ID and Client Secret.
  4. OpenAI API Key: Required if you want to run the provided client.py test script.

Installation

This project manages dependencies using uv (recommended) or you can use pip.

Using uv (Recommended)

  1. Sync the project environment:
    uv sync
    

Using pip

  1. Create a virtual environment:
    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    
  2. Install dependencies:
    pip install -e .
    

Configuration

  1. Copy the example environment file:

    cp .env.example .env
    # On Windows: copy .env.example .env
    
  2. Edit .env and fill in your credentials:

Please refer .env.example

Docker Support

You can also run the server using Docker.

  1. Build the image:

    docker build -t mcp-google-calendar .
    
  2. Run the container (ensure you environment variables are passed):

    # Assuming you have a .env file
    docker run --env-file .env -p 8000:8000 mcp-google-calendar
    

    Note: If your Redis is running on the host, use host.docker.internal (Windows/Mac) or --network="host" (Linux).

Running the Server

  1. Start Redis: Ensure your Redis server is running locally (default port 6379).

  2. Run the MCP Server: Using uv:

    uv run server.py
    

    Using standard python:

    python server.py
    

    The server will start at http://localhost:8000.

You can also use profiles to maintain separate authentication sessions:

uv run client.py --profile work
uv run client.py --profile personal
uv run client.py --profile user1
uv run client.py --profile user2

Connecting a Client

Option 1: Using the provided Test Client

This project includes a CLI client powered by OpenAI to test the integration.

  1. Ensure the server is running.
  2. In a new terminal, run:
    uv run client.py
    # or: python client.py
    
  3. On first run, it will open your request OAuth authentication. Follow the steps in your browser to log in with your Google account.
  4. Once authenticated, you can chat with the assistant:

    "What is on my calendar for today?" "Schedule a meeting with the team tomorrow at 2 PM."

Option 2: Using Claude Desktop

You can configure Claude Desktop to use this MCP server.

  1. Locate your Claude Desktop config file (typically %APPDATA%\Claude\claude_desktop_config.json on Windows or ~/Library/Application Support/Claude/claude_desktop_config.json on macOS).
  2. Add the server configuration:
    {
      "mcpServers": {
        "google-calendar": {
          "command": "uv",
          "args": ["run", "--directory", "C:/path/to/repo/mcp-auth-google-calendar", "server.py"],
          "env": {
             "GOOGLE_CLIENT_ID": "your_client_id",
             "GOOGLE_CLIENT_SECRET": "your_client_secret"
          }
        }
      }
    }
    
    Note: Replace paths and credentials with your actual values.

Testing

Currently, no automated unit tests are included. The best way to test is using the client.py script as described above.

To run future tests (if added), you would use pytest:

uv run pytest

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选