MCP ジェミニ サーバー
Claude のような AI アシスタントが Google の Gemini API と対話できるようにする Model Context Protocol (MCP) のサーバー実装。
プロジェクト概要
このプロジェクトは、モデルコンテキストプロトコル(MCP)に準拠したサーバーを実装し、AIアシスタントがGoogleのGeminiモデルと通信できるようにします。このMCPサーバーにより、AIアシスタントはGemini APIを介してテキスト生成やテキスト分析をリクエストしたり、チャット会話を維持したりできるようになります。
特徴
- クライアント/サーバー通信: クライアントとサーバー間の安全なメッセージ交換のための MCP プロトコルを実装します。
- メッセージ処理: クライアント要求を処理し、適切な応答を送信します。
- エラー処理とログ記録: サーバーのアクティビティをログに記録し、スムーズなエラー回復を保証します。
- 環境変数のサポート: 機密情報を安全に保存するために
.env
ファイルを使用します。 - API テストとデバッグ: Postman とテスト スクリプトを使用した手動テストと自動テストをサポートします。
インストール
前提条件
- Python 3.7以上
- Google AI APIキー
設定
- このリポジトリをクローンします:
- 仮想環境を作成します。
- 仮想環境をアクティブ化します。
- Windows:
venv\Scripts\activate
- macOS/Linux:
source venv/bin/activate
- Windows:
- 依存関係をインストールします:
- Gemini API キーを使用してルート ディレクトリに
.env
ファイルを作成します。
使用法
- サーバーを起動します。
- サーバーはデフォルトで
http://localhost:5000/
で実行されます。 - POSTメソッドを使用してMCPリクエストを
/mcp
エンドポイントに送信する
リクエスト例
APIリファレンス
エンドポイント
GET /health
: サーバーが稼働しているかどうかを確認するGET /list-models
: 利用可能なGeminiモデルの一覧POST /mcp
: MCPリクエストのメインエンドポイント
MCPアクション
1. テキストを生成する
Gemini を使用してテキスト コンテンツを生成します。
パラメータ:
prompt
(必須): 生成のためのテキストプロンプトtemperature
(オプション):ランダム性(0.0~1.0)を制御max_tokens
(オプション): 生成するトークンの最大数
例:
2. テキスト分析
テキストコンテンツを分析します。
パラメータ:
text
(必須): 分析するテキストanalysis_type
(オプション): 分析の種類 ('sentiment'、'summary'、'keywords'、または 'general')
例:
3. チャット
ジェミニと会話しましょう。
パラメータ:
messages
(必須): 'role' と 'content' を持つメッセージオブジェクトの配列temperature
(オプション):ランダム性(0.0~1.0)を制御
例:
エラー処理
サーバーは適切な HTTP ステータス コードとエラー メッセージを返します。
200
: リクエスト成功400
: 不正なリクエスト (パラメータが欠落しているか無効です)500
: サーバーエラー (API の問題など)
テスト
付属のテスト スクリプトを使用して、さまざまな機能をテストします。
MCPプロトコル仕様
ここで実装されているモデルコンテキストプロトコルは、次の仕様に従います。
- リクエスト形式:
action
: 操作を指定する文字列parameters
: アクション固有のパラメータを含むオブジェクト
- 応答形式:
result
: 操作結果を含むオブジェクトerror
: エラーを説明する文字列(該当する場合)
ライセンス
MITライセンス
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Claude などの AI アシスタントがテキスト生成、テキスト分析、チャット会話のために Google の Gemini API と対話できるようにするモデル コンテキスト プロトコルを実装するサーバー。
Related MCP Servers
- -securityAlicense-qualityModel Context Protocol (MCP) server implementation that enables Claude Desktop to interact with Google's Gemini AI models.Last updated -53TypeScriptMIT License
- -securityFlicense-qualityA Model Context Protocol server that enables AI assistants to interact with Gmail services, supporting email operations, draft management, and calendar functionality through Google API integration.Last updated -TypeScript
- AsecurityAlicenseAqualityA Model Context Protocol server that enables AI assistants like Claude to interact with Google Cloud Platform environments through natural language, allowing users to query and manage GCP resources during conversations.Last updated -910262TypeScriptMIT License
- -securityFlicense-qualityA Model Context Protocol server that enables Claude Desktop to interact with Google's Gemini 2.5 Pro Experimental AI model, with features like Google Search integration and token usage reporting.Last updated -JavaScript