


AI アシスタントに、Gmail、Google カレンダー、Google ドライブ、Google 検索などの Google サービスとやり取りするための強力なツールを提供する MCP サーバー。
概要
py-mcp-google-toolbox は、次の Google 関連機能を提供します。
- Gmail の操作(読み取り、検索、送信、変更)
- Google カレンダーの管理(イベントの作成、一覧表示、更新、削除)
- Google ドライブの操作(検索、ファイルの読み取り)
- Google 検索統合(ウェブ検索)
目次
前提条件
- Python : Python 3.12以降をインストールします
- Google Cloud Console のセットアップ:
- Google Cloud Consoleに移動
- 新しいプロジェクトを作成するか、既存のプロジェクトを選択してください
- サービス API を有効にします。
- 「APIとサービス」>「ライブラリ」に移動します
- 「Gmail API」を検索して有効にします
- 「Google カレンダー API」を検索して有効にします
- 「Google Drive API」を検索して有効にします
- 検索フォームで「カスタム検索API」を有効にする
- GCP から OAuth 2.0 認証情報を設定します。
- 「APIとサービス」>「認証情報」に移動します
- 「認証情報を作成」>「OAuthクライアントID」をクリックします
- 「Webアプリケーション」を選択
- クライアントIDとクライアントシークレットを書き留めます
- secret json をダウンロードし、credentials.json に名前を変更します。
- APIキーを生成する
- カスタム検索エンジンにアクセスしてIDを取得します
インストール
Gitクローン
git clone https://github.com/jikime/py-mcp-google-toolbox.git
cd py-mcp-google-toolbox
構成
- UV パッケージ マネージャーをインストールします。
curl -LsSf https://astral.sh/uv/install.sh | sh
- 仮想環境を作成してアクティブ化します。
uv venv -p 3.12
source .venv/bin/activate # On MacOS/Linux
# or
.venv\Scripts\activate # On Windows
- 依存関係をインストールします:
uv pip install -r requirements.txt
- リフレッシュトークンを取得します(トークンの有効期限が切れている場合はこれを実行できます)
uv run get_refresh_token.py
これにより、次のようになります。
- Google OAuth認証のためにブラウザを開きます
- 次の権限を要求します。
https://www.googleapis.com/auth/gmail.modify
https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/gmail.send
https://www.googleapis.com/auth/gmail.readonly
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.readonly
- 資格情報を
token.json
に保存します - コンソールにリフレッシュトークンを表示する
- 環境変数:
cp env.example .env
vi .env
# change with your key
GOOGLE_API_KEY=your_google_api_key
GOOGLE_CSE_ID=your_custom_search_engine_id
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_REFRESH_TOKEN=your_google_refresh_token
- credentials.json をプロジェクトのルートフォルダにコピーします (py-mcp-google-toolbox)
Dockerの使用
- Docker イメージをビルドします。
docker build -t py-mcp-google-toolbox .
- コンテナを実行します。
docker run py-mcp-google-toolbox
ローカルの使用
- サーバーを実行します。
MCP設定を構成する
MCP 設定ファイルにサーバー構成を追加します。
クロードデスクトップアプリ
- Smithery経由で自動的にインストールするには:
npx -y @smithery/cli install @jikime/py-mcp-google-toolbox --client claude
- 手動でインストールするには
~/Library/Application Support/Claude/claude_desktop_config.json
を開きます。
これをmcpServers
オブジェクトに追加します。
{
"mcpServers": {
"Google Toolbox": {
"command": "/path/to/bin/uv",
"args": [
"--directory",
"/path/to/py-mcp-google-toolbox",
"run",
"server.py"
]
}
}
}
カーソルIDE
~/.cursor/mcp.json
を開く
これをmcpServers
オブジェクトに追加します。
{
"mcpServers": {
"Google Toolbox": {
"command": "/path/to/bin/uv",
"args": [
"--directory",
"/path/to/py-mcp-google-toolbox",
"run",
"server.py"
]
}
}
}
Docker用
{
"mcpServers": {
"Google Toolbox": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"py-mcp-google-toolbox"
]
}
}
}
ツールドキュメント
Gmailツール
list_emails
: Gmailの受信トレイからフィルタリングオプション付きで最近のメールを一覧表示しますsearch_emails
: 詳細なメール内容の取得を伴う高度な Gmail 検索を実行しますsend_email
: CC、BCC 受信者をサポートしてメールを作成して送信しますmodify_email
: ラベルを変更してメールの状態(既読/未読、アーカイブ、ゴミ箱)を変更します
カレンダーツール
list_events
: 指定された時間範囲内の今後のカレンダーイベントを取得します。create_event
: 出席者、場所、説明を含む新しいカレンダーイベントを作成しますupdate_event
: 柔軟なパラメータ更新で既存のカレンダーイベントを変更しますdelete_event
: イベントIDでカレンダーイベントを削除します
ドライブツール
read_gdrive_file
: Google ドライブのファイルからコンテンツを読み取り、取得しますsearch_gdrive
: カスタマイズ可能なクエリを使用して Google ドライブ内のファイルを検索します
検索ツール
search_google
: Google検索を実行し、フォーマットされた結果を返します
発達
ローカルテストの場合は、付属のクライアント スクリプトを使用できます。
# Example: List emails
uv run client.py list_emails max_results=5 query="is:unread"
# Example: Search emails
uv run client.py search_emails query="from:test@example.com"
# Example: Send email
uv run client.py send_email to="test@example.com" subject="test mail" body="Hello"
# Example: Modify email
uv run client.py modify_email id=MESSAGE_ID remove_labels=INBOX add_labels=ARCHIVED
# Example: List events
uv run client.py list_events time_min=2025-05-01T00:00:00+09:00 time_max=2025-05-02T23:59:59+09:00 max_results=5
# Example: Create event
uv run client.py create_event summary="new event" start=2025-05-02T10:00:00+09:00 end=2025-05-02T11:00:00+09:00 attendees="user1@example.com,user2@example.com"
# Example: Update event
uv run client.py update_event event_id=EVENT_ID summary="update event" start=2025-05-02T10:00:00+09:00 end=2025-05-02T11:00:00+09:00 attendees="user1@example.com,user2@example.com"
# Example Delete event
uv run client.py delete_event event_id=EVENT_ID
# Example: Search Google
uv run client.py search_google query="what is the MCP?"
# Example: Search Google Drive
uv run client.py search_gdrive query=mcp
# Example: Read file
uv run client.py read_gdrive_file file_id=1234567890
ライセンス
MITライセンス