mcpField
M
MCP Crash Course

MCP Crash Course

Local
github.com/Ayyappa054AI & Agents2Updated 78w ago

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

  1. 01Integrate LangChain with MCP
  2. 02Connect to math and weather servers
  3. 03Demonstrate single- and multi-server clients
  4. 04Support asynchronous operations

Use cases

  1. 01Run an agent for mathematical queries
  2. 02Route weather queries to a server
  3. 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.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

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

Comments

Markdown supported

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.