HM

hirokiyn/mcp-langgraph

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

16 stars 6 forks 品質 30 トレンド 21

MCP サーバーを使用するために適応したLangGraph エージェントのチュートリアル.

概要

これは、従来のLangChainツールではなくサーバーを使用して実装されたツールの最小限の機能的な例です。 これは、公式LangGraphチュートリアルに基づいており、MCPサーバーをツールとして統合する方法を実証するために適応しました。 🧠 このリポジトリを使用して、MCP ツールを使用して、LangGraph エージェントを迅速に構築できます。 * エージェントの状態とメッセージのルーティングを管理するためのLangGraphを統合します。 * MCP サーバーを使用してツールへのアクセスを提供します。 * 数学と気象のMCPサーバなどが含まれます。 * エージェントとやり取りするためのコマンドラインインターフェイスを提供します。 2. Poetry を使用して依存関係をインストールします。 1. Anthropic API キーを .env ファイルに設定します。 存在しない場合は、このファイルを作成する必要があります。 例えば: * 数学サーバ: python src/mcp servers/math server.py * 気象サーバ: python src/mcp servers/weather server.py 2. 代理店を実行して下さい: 対話モードでエージェントを起動します。 プロンプトを入力すると、エージェントはMCPサーバーが提供するツールを使用して応答します.

概要(AI 翻訳)

これは、従来のLangChainツールではなく、MCP(Model Context Protocol)サーバーを使用して実装されたツールでLangGraphを搭載したagentの最小限の機能例です。 これは、公式LangGraphチュートリアルに基づいており、MCPサーバーをツールとして統合する方法を実証するために適応しました。

🧠 このリポジトリをskeletonとして使用して、すぐにMCPツールでLangGraphエージェントをビルドしてください!

##特徴

  • エージェントの状態とメッセージのルーティングを管理するためのLangGraphを統合します。
  • MCP サーバーを使用してツールへのアクセスを提供します。
  • 数学と気象のMCPサーバなどが含まれます。
  • エージェントとやり取りするためのコマンドラインインターフェイスを提供します。

インストール

  1. リポジトリのクローン化:

  2. Poetry を使用して依存関係をインストールします。

使用法

  1. [.env] ファイルに Anthropic API キーを設定します。 存在しない場合は、このファイルを作成する必要があります。 例えば:

  2. MCP サーバーを起動します。

  • 数学サーバ: python src/mcp_servers/math_server.py
  • 気象サーバ: python src/mcp_servers/weather_server.py
  1. 代理店を実行して下さい:

対話モードでエージェントを起動します。 プロンプトを入力すると、エージェントはMCPサーバーが提供するツールを使用して応答します。

例

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

MCP + LangGraph Agent

This is a minimal, functional example of an agent powered by LangGraph with tools implemented using MCP (Model Context Protocol) servers instead of traditional LangChain tools. It’s based on the official LangGraph tutorial, adapted to demonstrate how to integrate MCP servers as tools.

🧠 Use this repo as a skeleton to quickly build your own LangGraph agent with MCP tools!

Features

flowchart TD
    __start__ --> chatbot
    chatbot -.-> tools
    chatbot -.-> __end__
    tools --> chatbot
  • Integrates LangGraph for managing agent state and message routing.
  • Uses MCP servers to provide access to tools.
  • Includes example MCP servers for math and weather.
  • Provides a command-line interface for interacting with the agent.

Installation

  1. Clone the repository:

    git clone 
    
  2. Install the dependencies using Poetry:

    poetry install
    

Usage

  1. Set the Anthropic API key in the .env file. You may need to create this file if it doesn’t exist. For example:

    ANTHROPIC_API_KEY=your_api_key
    
  2. Start the MCP servers:

    • Math server: python src/mcp_servers/math_server.py
    • Weather server: python src/mcp_servers/weather_server.py
  3. Run the agent:

    poetry run main
    

    This will start the agent in interactive mode. You can then enter prompts, and the agent will respond using the tools provided by the MCP servers.

Example

User: What's (3 + 5) x 12?
Assistant: The result of (3 + 5) × 12 = 96
User: What is the weather in New York?
Assistant: It's always sunny in New York.

MCP Server Configuration

The MCP servers are configured in src/main.py. You can modify the configuration to add or remove servers, or to change the transport mechanism.

LLM Configuration

The LLM used by the agent can be changed in src/common.py.

GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →