Minimal MCP server and client sample

Minimal MCP server and client sample

mcp-server-example-ykitaza•byykitaza

A minimal sample project implementing a Model Context Protocol server with a numeric comparison tool, plus an MCP client and a Gemini-powered chat CLI.

License: Not specified•Runtime: Awaiting documentation review•Category: developer tools

WHAT IT DOES

  • •Provides an MCP server that offers a tool comparing the magnitude of two numbers, solving comparisons AI models often get wrong.
  • •Manages registration and execution of MCP tools on the server.
  • •Includes an MCP client module handling bidirectional communication with the server, configuration-based connection management, and error handling with retries.
  • •Offers a chat CLI that uses the Google Gemini API to process natural language and invoke MCP tools as needed.

BEST FOR

  • •Learning the fundamental concepts of MCP through a minimal implementation example.
  • •Verifying MCP usage through Google Gemini at low cost, leveraging free tiers.
  • •Developers who want to implement an MCP server independently of specific clients like Claude Desktop App.

ABOUT MCP-SERVER-EXAMPLE-YKITAZA

Minimal MCP server and client sample is cataloged as an MCP server attributed to ykitaza. A minimal sample project implementing a Model Context Protocol server with a numeric comparison tool, plus an MCP client and a Gemini-powered chat CLI. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for Minimal MCP server and client sample are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

What runtime does the sample require?

It requires the Bun runtime, version 1.0.0 or higher.

Which LLM does the chat CLI use?

The chat interface uses the Google Gemini API for natural language processing and requires a Gemini API key when using the chat CLI.

上游原版 README

在 GitHub 查看同一版本原文

README.md · a4ae3a6fc7f7 · 采集于 2026-11-13 11:44:10 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

MCP サーバー/クライアント サンプル

🔍 Model Context Protocol(MCP)の実装サンプルプロジェクト

💡 プロジェクトの背景

このプロジェクトは以下の目的で作成されました:

  • MCPの基礎学習: Model Context Protocolの基本概念を理解するための最小限の実装例を提供
  • シンプルな実装: 必要最小限の機能に絞ったMCPサーバーの実装により、プロトコルの本質的な部分に焦点を当てる
  • 独立した実装: Claude Desktop Appなどの特定のクライアントに依存せず、MCPサーバーを自前で実装する方法を示す
  • コストをかけず検証: Google Gemini 経由で MCP を利用することで、コストをかけず(無料枠等の活用可)検証を行うことが可能

このサンプルプロジェクトを通じて、MCPの基本的な仕組みとツール連携の実装方法を学ぶことができます。

🎯 機能概要

このプロジェクトは以下の主要機能を提供します:

MCPサーバー機能

  • 数値比較ツールの提供
    • 2つの数字の大小比較を行うツールを実装します。とても単純ですが、AIが間違えやすい比較問題(9.11と9.9の大小比較等)を解決します。
  • ツールの登録・実行管理

ツール使用前

通常のチャット画面

ツール使用後

数値比較ツールの実行結果

MCPクライアント機能

  • サーバーとの双方向通信
  • 設定ファイルによる接続管理
  • エラーハンドリングとリトライ処理

チャットインターフェース

  • Google Gemini APIによる自然言語処理
  • MCPツールとの連携機能

チャットCLIの利用イメージ

📋 必要要件

  • Bun ランタイム(v1.0.0以上)
  • MCP対応クライアント(例:Claude Desktop App、Cline、Cursor)
  • Gemini API キー(チャットCLI利用時)

🚀 クイックスタート

1. プロジェクトのセットアップ

# 依存関係のインストール
bun install

# 環境変数ファイルの作成
cp .env.example .env

# .envファイルにGemini APIキーを設定
# Google Cloud ConsoleからAPIキーを取得して設定
GEMINI_API_KEY="your-api-key-here"

2. サーバー設定

// server-config.jsonを作成
{
    "my-simple-tool": {
        "command": "bun",
        "args": [
            "run",
            "/absolute/path/to/mcp-server/index.ts"
        ]
    }
}

※ パスは環境に合わせて適切な絶対パスに変更してください。

3. 実行

# チャットCLIの起動
bun run chat

🏗️ システム構成

ディレクトリ構造

src/
├── index.ts                 # チャットCLIのエントリーポイント
├── llm-clients/            # LLMクライアント実装
│   └── gemini.ts           # Google Gemini APIクライアント
├── mcp-client/            # MCPクライアントモジュール
│   ├── client.ts          # MCPツールクライアント実装
│   └── config.ts          # クライアント設定ローダー
└── mcp-server/           # MCPサーバーモジュール
    ├── index.ts          # サーバーのエントリーポイント
    └── tools/            # MCPツール実装
        └── compare-numbers.ts  # 数値比較ツール

コンポーネントの説明

MCPサーバー

  • src/mcp-server/: Model Context Protocol準拠のサーバー実装
  • ツールの登録と実行を管理
  • 数値比較などのツールを提供

MCPクライアント

  • src/mcp-client/: MCPサーバーとの通信を行うクライアントライブラリ
  • サーバー設定の読み込みと接続管理
  • ツールの呼び出しとレスポンス処理

LLMクライアント

  • src/llm-clients/: 言語モデルとの対話を管理
  • Google Gemini APIを使用した自然言語処理
  • MCPツールとの連携機能を実装

データフロー

  1. ユーザーがチャットCLIに入力

    • 質問やコマンドをテキストで入力
    • 入力は日本語で自然な形式が可能
  2. Geminiクライアントが入力を処理

    • 入力テキストを分析
    • ツール使用の必要性を判断
    • 適切なツールとパラメータを選択
  3. 必要に応じてMCPツールを呼び出し

    • MCPクライアントを通じてサーバーと通信
    • ツールに必要なパラメータを渡す
    • 実行結果を受け取る
  4. ツールの実行結果をGeminiに渡して応答を生成

    • ツールの出力を自然言語に変換
    • コンテキストに応じた適切な説明を生成
    • エラー発生時は分かりやすいメッセージを作成
  5. 結果をユーザーに表示

    • 処理結果を日本語で分かりやすく表示
    • エラーが発生した場合は対処方法も提示

⚙️ 設定ガイド

サーバー設定

サーバーの設定は以下の2つのファイルで管理します:

1. 環境変数(.env)

# Google Cloud ConsoleからAPIキーを取得して設定
GEMINI_API_KEY="your-api-key-here"

2. サーバー設定(server-config.json)

// server-config.jsonを作成
{
    "my-simple-tool": {
        "command": "bun",
        "args": [
            "run",
            "/absolute/path/to/mcp-server/index.ts"
        ]
    }
}
設定項目必須デフォルト値説明
command✓-サーバー実行コマンド(bun/node等)
args✓-実行引数(サーバーファイルパス等)
disabled-falseサーバーの無効化フラグ
autoApprove-[]自動承認するツールのリスト
timeout-30000ツール実行のタイムアウト時間(ミリ秒)

⚠️ 重要な注意点

  • サーバーファイルのパスは必ず絶対パスを使用
  • 設定変更後はクライアントの再起動が必要
  • autoApproveの使用は必要最小限に
  • 環境変数は.envファイルで管理し、.gitignoreに追加

基本的な使い方

# チャットの開始
bun run chat

# チャットの終了方法
exit    # 終了
quit    # 終了
終了     # 終了

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for Minimal MCP server and client sample from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mcp-server-example-ykitaza)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related developer tools MCP Servers

Alternative and complementary servers in the same category

View all in developer tools →
Postbye
postbye-mcp•postbye-team

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools
Singapore Proxy MCP
singapore-proxy-mcp•Xavierfok

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

0
Developer Tools

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools