About MCP Crash Course
MCP Crash Course demonstrates LangChain integration with MCP through single- and multi-server examples. It connects an agent to math and weather tools using OpenAI integration and asynchronous operations.
Key features
- 01Integrate LangChain with MCP
- 02Connect to math and weather servers
- 03Demonstrate single- and multi-server clients
- 04Support asynchronous operations
Use cases
- 01Run an agent for mathematical queries
- 02Route weather queries to a server
- 03Study single- and multi-server MCP patterns
MCP support
Includes math and weather MCP servers and client examples using stdio and MultiServerMCPClient. The agent can select tools based on the query.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEMCP Crash Course
A demonstration project showcasing the integration of LangChain with Model Control Protocol (MCP) adapters. This project implements a system that can handle both mathematical calculations and weather queries through separate MCP servers.
Features
- Multiple MCP server integration (math and weather servers)
- LangChain integration with OpenAI
- Async operation support
- Environment variable configuration
Prerequisites
- Python 3.x
- OpenAI API key
Installation
- Clone the repository
- Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate - Install dependencies:
pip install -r requirements.txt - Create a
.envfile and add your OpenAI API key:OPENAI_API_KEY=your_api_key_here
Project Structure
main.py- Single server implementation using stdio clientlangchain_client.py- Multi-server implementation using MCP clientserver/- Directory containing MCP server implementationsmath_server.py- Server for mathematical operationsweather_server.py- Server for weather queries
Usage
-
Run the single server example:
python main.py -
Run the multi-server example:
python langchain_client.py
How It Works
The project demonstrates two approaches to using MCP:
-
Single Server (main.py):
- Uses stdio client for communication
- Connects to a math server for calculations
- Implements a React agent using LangChain
-
Multi-Server (langchain_client.py):
- Uses MultiServerMCPClient for managing multiple servers
- Connects to both math and weather servers
- Allows the agent to choose appropriate tools based on the query
Dependencies
- langchain-core
- langchain-openai
- langchain-mcp-adapters
- langgraph
- python-dotenv
- mcp
License
MIT
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.