LangGraph Agent with MCP

by galaxyxyz5

438 downloads
Not rated
GitHub

About

LangGraph Agent that integrates with MCP servers

Details

Author
galaxyxyz5
Downloads
438
Categories
Other, AI

- Automatic tool discovery via MCP
- Multi‑server support (Tavily, YouTube transcript, math, weather)
- Predefined tools for web search and YouTube summarization
- Modular architecture – easily add additional MCP servers
- Connects LangGraph agents to external data and APIs

Clone the repository, install dependencies from requirements.txt, and create a .env file with TAVILY_API_KEY and OPENAI_API_KEY. Run servers/server.py to start the MCP server, then run agent.py in a new terminal to connect the agent and execute queries.

LangGraph Agent with MCP

This project is designed to efficiently integrate Model Context Protocol (MCP) with a LangGraph Agent, allowing it to dynamically access external tools, data sources, and APIs.

Using this project, you can connect a LangGraph agent to MCP servers and use predefined tools to perform various tasks, such as web searches and summarizing YouTube videos. You can also add additional servers as needed.

This integration enables automatic tool discovery and multi-server support, making AI systems more modular and powerful. It allows AI systems to automatically find tools and connect to multiple servers, increasing their flexibility and efficiency.

image

What is MCP and Why It Matters?

The Model Context Protocol (MCP) is an open standard that provides a structured way for AI applications to interact with external data, tools, and APIs. MCP was developed by Anthropic to address the challenge of dynamically connecting LLMs to external data sources without requiring custom integrations for each tool.

MCP is important because it helps AI systems share and access data easily, removing barriers between different tools. This makes AI more connected and efficient. It also allows developers to build smarter AI systems that can work with many different tools and grow easily.

Project Structure

langgraph_mcp/
│-- agent.py  
│-- servers/
│   ├── tavily.py          
│   ├── yt_transcript.py   
│   ├── math_server.py 
│   ├──weather.py
│-- .env          
│-- requirements.txt

Installation

1. Clone the Repository:

git clone https://github.com/your-repo/langgraph-mcp.git
cd langgraph-mcp

2. Install Dependencies

pip install -r requirements.txt

3. Create a .env file and add:
TAVILY_API_KEY=<your-tavily-api-key>
OPENAI_API_KEY=<your-openai-api-key>

How It Works

To start, run ``servers/server.py` in your terminal. This will start the MCP server. Then, in a new terminal, run `agent.py``. The agent will connect to the server via the MCP client and execute your query, as shown in the demo.

https://github.com/user-attachments/assets/c65255a1-62af-4711-8f10-ebfdacd9b3c6

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.