MCP Crash Course
About
A practical demonstration of integrating LangChain with Model Control Protocol (MCP) featuring both single and multi-server implementations. Includes examples of mathematical computations and weather queries using async operations, React agents, and OpenAI integration. Perfect fo
Details
- Author
- Ayyappa054
- GitHub stars
- 2
- Downloads
- 375
- Categories
- AI
Jump to
- Integrates LangChain with MCP adapters
- Multiple MCP servers (math and weather)
- Async operation support
- Environment variable configuration
- Both single‑server and multi‑server usage examples
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
MCP Crash CourseCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Clone the repository, create a Python virtual environment, install dependencies from requirements.txt, and add your OpenAI API key to a .env file. Then run python main.py for the single‑server example or python langchain_client.py for the multi‑server example.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"mcp crash course": {
"langchain-mcp-examples": {
"command": "python",
"args": [
"-m",
"venv",
".venv"
]
}
}
}
}
McpServers
{
"langchain-mcp-examples": {
"command": "python",
"args": [
"-m",
"venv",
".venv"
]
}
}
MCP 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
1. Clone the repository
2. Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
3. Install dependencies:
pip install -r requirements.txt
4. Create a
.env file and add your OpenAI API key: OPENAI_API_KEY=your_api_key_here
Project Structure
- main.py - Single server implementation using stdio client
- langchain_client.py - Multi-server implementation using MCP client
- server/ - Directory containing MCP server implementations
- math_server.py - Server for mathematical operations
- weather_server.py - Server for weather queries
Usage
1. Run the single server example:
python main.py
2. Run the multi-server example:
python langchain_client.py
How It Works
The project demonstrates two approaches to using MCP:
1. Single Server (main.py):
- Uses stdio client for communication
- Connects to a math server for calculations
- Implements a React agent using LangChain
2. 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
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.
