Google Calendar MCP Server
Enables interaction with Google Calendar through the Google Calendar API. Supports listing calendars, creating/deleting events, and retrieving calendar events with OAuth2 authentication.
README
Google Calendar MCP Server
Google Calendar APIを使用したMCP(Model Context Protocol)サーバーです。FastMCPフレームワークを使用してGoogleカレンダーの操作機能を提供します。
機能
- カレンダー一覧取得: 利用可能なGoogleカレンダーの一覧を取得
- イベント取得: 指定したカレンダーからイベントを取得
- イベント作成: 新しいカレンダーイベントを作成
- イベント削除: カレンダーイベントを削除
要件
- Python 3.12以上
- Google Cloud Platformプロジェクト
- Google Calendar API有効化
- OAuth2認証情報
インストール
- リポジトリをクローン
git clone <repository-url>
cd google-calendar-mcp
- 依存関係をインストール
pip install -e .
またはuvを使用する場合:
uv sync
設定
1. Google Cloud Platform設定
- Google Cloud Consoleでプロジェクトを作成
- Google Calendar APIを有効化
- OAuth2認証情報を作成
- 必要な環境変数を設定
2. 環境変数設定
以下の環境変数を設定してください:
export GOOGLE_CLIENT_ID="your_client_id"
export GOOGLE_CLIENT_SECRET="your_client_secret"
export GOOGLE_PROJECT_ID="your_project_id"
export GOOGLE_REFRESH_TOKEN="your_refresh_token"
または.envファイルに設定:
GOOGLE_CLIENT_ID=your_client_id
GOOGLE_CLIENT_SECRET=your_client_secret
GOOGLE_PROJECT_ID=your_project_id
GOOGLE_REFRESH_TOKEN=your_refresh_token
3. OAuth2認証情報の取得
- Google Cloud ConsoleでOAuth2認証情報を作成
- 認証フローを実行してリフレッシュトークンを取得
- 取得した値を環境変数に設定
使用方法
MCPサーバーとして実行
python main.py
直接実行
python -m src.google_calendar_mcp
API仕様
list_calendars()
利用可能なGoogleカレンダーの一覧を取得します。
引数: なし
戻り値:
success(bool): 処理が成功したかどうかcalendars(List[Dict]): カレンダー情報のリストcount(int): カレンダー数error(str): エラーメッセージ(失敗時)
get_events()
指定したカレンダーからイベントを取得します。
引数:
calendar_id(str): カレンダーID(デフォルト: 'primary')time_min(str): 開始時刻(ISO形式、デフォルト: 現在時刻)time_max(str): 終了時刻(ISO形式、デフォルト: 7日後)max_results(int): 最大取得件数(デフォルト: 10)
戻り値:
success(bool): 処理が成功したかどうかevents(List[Dict]): イベント情報のリストcount(int): イベント数error(str): エラーメッセージ(失敗時)
create_event()
新しいカレンダーイベントを作成します。
引数:
summary(str): イベントタイトル(必須)start_time(str): 開始時刻(ISO形式、必須)end_time(str): 終了時刻(ISO形式、必須)description(str): イベントの説明(デフォルト: '')location(str): 場所(デフォルト: '')calendar_id(str): カレンダーID(デフォルト: 'primary')attendees(List[str]): 参加者メールアドレスのリスト(デフォルト: None)
戻り値:
success(bool): 処理が成功したかどうかevent_id(str): 作成されたイベントのIDevent_link(str): イベントのGoogleカレンダーリンクmessage(str): 成功メッセージerror(str): エラーメッセージ(失敗時)
delete_event()
カレンダーイベントを削除します。
引数:
event_id(str): 削除するイベントのID(必須)calendar_id(str): カレンダーID(デフォルト: 'primary')
戻り値:
success(bool): 処理が成功したかどうかmessage(str): 成功メッセージerror(str): エラーメッセージ(失敗時)
テスト
モックモードでのテスト実行
python run_tests.py --mode mock
実際のAPIを使用したテスト実行
python run_tests.py --mode real_api
カバレッジレポート付きテスト実行
python run_tests.py --mode mock --coverage
特定のテスト実行
python run_tests.py --mode mock --test test_calendar_tools.py::TestListCalendars
プロジェクト構造
google-calendar-mcp/
├── src/
│ ├── __init__.py
│ ├── google_calendar_mcp.py # MCPサーバーのメインエントリーポイント
│ ├── auth/
│ │ ├── __init__.py
│ │ └── google_auth.py # Google認証処理
│ └── tools/
│ ├── __init__.py
│ └── calendar_tools.py # カレンダー操作機能
├── tests/
│ ├── __init__.py
│ └── test_calendar_tools.py # テストコード
├── main.py # アプリケーションエントリーポイント
├── run_tests.py # テスト実行スクリプト
├── pyproject.toml # プロジェクト設定
├── pytest.ini # pytest設定
└── README.md # このファイル
依存関係
fastmcp: MCPサーバーフレームワークgoogle-api-python-client: Google APIクライアントgoogle-auth-httplib2: Google認証ライブラリgoogle-auth-oauthlib: OAuth2認証ライブラリpython-dotenv: 環境変数管理pytest: テストフレームワークpytest-mock: モックテストライブラリ
ライセンス
このプロジェクトのライセンスについては、LICENSEファイルを参照してください。
貢献
プルリクエストやイシューの報告を歓迎します。
トラブルシューティング
認証エラー
- 環境変数が正しく設定されているか確認
- OAuth2認証情報が有効か確認
- Google Calendar APIが有効化されているか確認
権限エラー
- 必要なスコープが設定されているか確認
- カレンダーへのアクセス権限があるか確認
テストエラー
- 環境変数
USE_REAL_APIの設定を確認 - 必要な依存関係がインストールされているか確認
Recommended Servers
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.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.