Skip to main content
Glama

マルチサーバー Model Context Protocol (MCP) デモ

複数の Model Context Protocol (MCP) サーバーを構築し、Groq とリアルタイム OpenWeatherMap データを活用した LangGraph ReAct エージェントと統合する完全なデモンストレーションです。

このプロジェクトは、LLM エージェントが異なる MCP サーバーおよびトランスポートプロトコル (stdiostreamable-http) をまたいでツールを動的に発見し、単一の統合ワークフローで利用できる方法を示しています。


🏗️ アーキテクチャ

flowchart LR
    subgraph Agent["LangGraph ReAct Agent (client.py)"]
        ChatGroq["LLM: Groq (Qwen / ChatGroq)"]
        MultiMCP["MultiServerMCPClient"]
    end

    subgraph MathServer["Math MCP Server (mathserver.py)"]
        MathTools["Tools: add, sub, mul, div"]
    end

    subgraph WeatherServer["Weather MCP Server (weatherserver.py)"]
        WeatherTools["Tool: get_weather (OpenWeatherMap API)"]
    end

    MultiMCP -- "stdio transport (subprocess)" --> MathServer
    MultiMCP -- "streamable-http (http://127.0.0.1:8000/mcp)" --> WeatherServer

コンポーネント

  1. Math MCP サーバー (mathserver.py)

    • FastMCP で構築。

    • stdio トランスポート上で動作。

    • 算術ツール addsubmuldiv を公開。

    • MCP クライアントによってバックグラウンドサブプロセスとして自動起動。

  2. Weather MCP サーバー (weatherserver.py)

    • FastMCP で構築、streamable-http トランスポート(http://127.0.0.1:8000/mcp)上で動作。

    • httpx を使用して OpenWeatherMap API からライブ気象データを取得。

    • get_weather ツール(気温、天気説明、体感温度、湿度を返す)を公開。

  3. オーケストレータークライアント (client.py)

    • langchain-mcp-adaptersMultiServerMCPClient を使用して両方の MCP サーバーに同時接続。

    • ツールを収集し、Groq の高速 LLM 推論(ChatGroq)を利用した LangGraph ReAct エージェントを動作させる。


Related MCP server: AIE8-MCP Server

📁 プロジェクト構造

Mcp_demo/
├── client.py           # ReAct Agent & Multi-Server MCP client orchestrator
├── mathserver.py       # FastMCP server running on stdio transport
├── weatherserver.py    # FastMCP server with OpenWeatherMap API on HTTP transport
├── requirements.txt    # Python package dependencies
├── pyproject.toml      # Project configuration & metadata
├── .env.example        # Environment variables template
├── .gitignore          # Git ignore rules (protects .env and caches)
└── README.md           # Project documentation

🚀 はじめ方

1. 前提条件

2. インストール

リポジトリをクローンし、依存関係をインストール:

git clone https://github.com/sreeshanthkprakash-stack/MCP-Server.git
cd MCP-Server

# Create and activate virtual environment
python -m venv .venv
# On Windows:
.venv\Scripts\activate
# On Linux/macOS:
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

3. 環境設定

ルートディレクトリに .env ファイルを作成(または .env.example からコピー):

GROQ_API_KEY=your_groq_api_key_here
OPENWEATHER_API_KEY=your_openweather_api_key_here

🧪 アプリケーションの実行

ステップ 1: Weather MCP サーバーを起動

気象サーバーは HTTP 経由で通信するため、まずターミナルで起動:

python weatherserver.py

気象サーバーは http://127.0.0.1:8000/mcp で待機を開始します。

ステップ 2: エージェントクライアントを実行

2 番目のターミナルウィンドウを開き(仮想環境がアクティブであることを確認)、次のコマンドを実行:

python client.py

期待される出力例

math_response The result of the expression ((15*20)+200)/4 is 125.
weather_response Weather in Hyderabad: haze, temperature 29.5°C (feels like 32.1°C), humidity 65%

📦 依存関係

  • mcp:公式 Model Context Protocol SDK (FastMCP)

  • langchain-mcp-adapters:LangChain を MCP サーバーに接続

  • langgraph:グラフベースのエージェントオーケストレーションランタイム

  • langchain-groq:Groq による高速 LLM 推論

  • httpx:非同期 HTTP クライアント(気象 API リクエスト用)

  • python-dotenv:安全な環境変数の読み込み


📄 ライセンス

このプロジェクトはオープンソースで、MIT ライセンス の下で利用可能です。

F
license - not found
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.

  • MCP server exposing the Backtest360 engine API as tools for AI agents.

  • Agent-native collaboration network: orchestrate a team of long-running agents from any MCP client.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sreeshanthkprakash-stack/MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server