Skip to main content
Glama
Model Context Protocol (MCP) Server

Model Context Protocol (MCP) Server

by hideya

LangChain / Python を使用した MCP クライアントライセンス: MIT

このシンプルなモデル コンテキスト プロトコル (MCP)クライアントは、LangChain ReAct Agent による MCP サーバー ツールの使用方法を示します。

これは、 langchain_mcp_toolsのユーティリティ関数convert_mcp_to_langchain_tools()を活用します。
この関数は、指定された複数の MCP サーバーの並列初期化を処理し、使用可能なツールを LangChain 互換ツールのリスト ( List[BaseTool] ) に変換します。

現在、Anthropic、OpenAI、Groq の LLM がサポートされています。

このMCPクライアントのTypescriptバージョンはここから入手できます。

前提条件

  • Python 3.11以上

  • [オプション] PythonパッケージベースのMCPサーバーを実行するためにuv ( uvx )がインストールされている

  • [オプション] Node.js パッケージベースの MCP サーバーを実行するためのnpm 7+ ( npx )

  • 必要に応じてAnthropic 、 OpenAI 、 Groqからの API キー

Related MCP server: OpenAI and Claude MCP

設定

  1. 依存関係をインストールします:

    make install
  2. API キーの設定:

    cp .env.template .env
    • 必要に応じて.envを更新します。

    • .gitignoreは、資格情報の誤ったコミットを防ぐために.env無視するように設定されています。

  3. 必要に応じて、LLM および MCP サーバーの設定llm_mcp_config.json5を構成します。

    • MCP サーバーの構成ファイル形式は、 Claude for Desktopと同じ構造に従いますが、1 つの違いがあります。キー名mcpServersは、JSON 構成ファイルで一般的に使用される snake_case 規則に従うためにmcp_serversに変更されています。

    • ファイル形式はJSON5で、コメントと末尾のコンマが許可されます。

    • 形式はさらに拡張され、 ${...}表記が対応する環境変数の値に置き換えられます。

    • すべての資格情報と個人情報を.envファイルに保存し、必要に応じて${...}表記で参照します。

使用法

アプリを実行します:

make start

初回実行時には多少時間がかかります。

詳細モードで実行:

make start-v

コマンドラインオプションを参照してください:

make start-h

プロンプトで Enter キーを押すだけで、MCP サーバー ツールの呼び出しを実行するサンプル クエリを使用できます。

クエリの例はllm_mcp_config.json5で設定できます。

Available Tools

2 tools
get-alertsC

Get weather alerts for a US state

Inputs: state (required).

get-forecastB

Get weather forecast for a location in the US

Inputs: latitude (required), longitude (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 2 tools

    Disambiguation5/5

    The tools get-alerts and get-forecast have clearly distinct purposes: one provides weather alerts, the other gives forecasts. No overlap.

    Naming Consistency5/5

    Both tool names follow the consistent pattern 'get-<resource>', using lowercase and hyphens, which is predictable.

    Tool Count2/5

    With only 2 tools, the server feels too sparse for a weather domain. Typically, more operations like current conditions or radar would be expected.

    Completeness2/5

    The tool set only covers alerts and forecasts, missing common weather operations like current conditions, location search, or severe weather warnings, resulting in significant gaps.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers