Skip to main content
Glama

Model Context Protocol (MCP) Server

by hideya

LangChain / Python を使用した MCP クライアント

このシンプルなモデル コンテキスト プロトコル (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サーバーを実行するためにuvuvxがインストールされている
  • [オプション] Node.js パッケージベースの MCP サーバーを実行するためのnpm 7+ ( npx )
  • 必要に応じてAnthropicOpenAIGroqからの API キー

設定

  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で設定できます。

-
security - not tested
A
license - permissive license
-
quality - not tested

このサーバーは、Anthropic、OpenAI、Groq などのプロバイダーからの AI モデルの呼び出しを容易にし、ユーザーが大規模な言語モデルのインタラクションをシームレスに管理および構成できるようにします。

  1. 前提条件
    1. 設定
      1. 使用法

        Related MCP Servers

        • -
          security
          -
          license
          -
          quality
          A simple server that acts as a Master Control Program (MCP) for unified interaction with OpenAI and Anthropic (Claude) AI models through a single API endpoint.
          Last updated -
        • -
          security
          F
          license
          -
          quality
          A server that allows AI agents to consult multiple large language models (like Grok, Gemini, Claude, GPT-4o) through Model Context Protocol for assistance and information.
          Last updated -
          3
          JavaScript
        • A
          security
          A
          license
          A
          quality
          A server that enables AI assistants to interact with the Omnisend marketing platform, supporting contact management, product management, and event tracking operations through natural language.
          Last updated -
          10
          TypeScript
          Apache 2.0
          • Linux
          • Apple
        • -
          security
          F
          license
          -
          quality
          A unified API server that enables interaction with multiple AI model providers like Anthropic and OpenAI through a consistent interface, supporting chat completions, tool calling, and context handling.
          Last updated -
          JavaScript

        View all related MCP servers

        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/hideya/mcp-client-langchain-py'

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