mcpField
S
Simple MCP Server & Client Sample (with Gemini Function Calling)

Simple MCP Server & Client Sample (with Gemini Function Calling)

Local
github.com/yokobaAI & Agents0Updated 74w ago

About Simple MCP Server & Client Sample (with Gemini Function Calling)

A minimal Python sample for building MCP servers and clients, aimed at developers learning the protocol and Gemini function calling. It demonstrates choosing between two server tools based on the time.

Key features

  1. 01Minimal MCP server and client examples
  2. 02Gemini function-calling client
  3. 03Automatic greet or farewell selection

Use cases

  1. 01Learning basic MCP server and client setup
  2. 02Testing Gemini-based tool selection

MCP support

Includes minimal MCP server and client implementations; one client connects Gemini function calling to server tools.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

Simple MCP Server & Client Sample (with Gemini Function Calling)

概要

  • MCP(Model Context Protocol)とは?
    機械学習モデルやAIエージェントに外部のツール(API)を呼ばせるプロトコル。

  • 本リポジトリの目的

    • 「MCPサーバ・クライアントの最小構成ってどう作るの?」
    • 「LLM(Gemini)でどのツールを呼ぶか自動で選ばせたい」
      というニーズ向けの備忘録です。

ファイル構成

  • mcp_simple_server1.py
    MCPサーバの最小サンプル。

  • mcp_simple_client1.py
    MCPクライアントの最小サンプル(接続確認用)。

  • mcp_simple_server2.py
    MCPサーバの最小サンプル。
    greet/farewell の2つのtoolを用意。

  • mcp_simple_client2.py
    Gemini function callingを使ったMCPクライアント。
    LLMが時刻によって自動でgreetまたはfarewellを選択し、サーバを呼び出します。


実行環境

  • Python 3.13(3.10以上なら動作するはず)
  • fastmcp >= 2.5.2
  • google-genai >= 1.18.0
  • uv (なくても動作するが高速化目的で推奨)

インストールと実行

  1. 必要なパッケージをインストール
uv init
uv add google-genai
uv add fastmcp
  1. Gemini APIキーを取得し、環境変数GEMINI_API_KEYに設定
    (Google AI Studioで無料発行可能)

  2. サーバ・クライアントの起動例

  • サーバ単体で起動(例)

    python mcp_simple_client1.py
    
  • クライアント+Gemini連携で実行(例)

    python mcp_simple_client2.py
    

使い方

  • サンプルコードはすべてコピペ・実行可能です。
  • Geminiのfunction callingで時刻によるtool選択をLLMに委ねています。

注意

  • エラーハンドリングや例外処理はシンプルさを優先して省略しています。
  • 実際の業務・サービス実装では適切なバリデーション、ログ、例外処理を追加してください。

License

MITライセンス等ご自由に。
備忘録・サンプル用途です。ご自身の責任でご利用ください。

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.