Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP Server Project

This project demonstrates how to build and connect to Model Context Protocol (MCP) servers using fastmcp and langchain.

Overview

The project consists of three main components:

  1. Calculator MCP Server (Calculator_MCP_Server.py): A FastMCP server exposing basic arithmetic operations (add, subtract, multiply, divide).
  2. Weather MCP Server (Weather_MCP_Server.py): A FastMCP server that fetches current weather information for a given city using the OpenWeather API.
  3. LLM Client (client.py): A LangChain-powered conversational agent that connects to both MCP servers and can intelligently invoke their tools based on user prompts.

Prerequisites

Setup

  1. Clone the repository:

    git clone <repository-url>
    cd MCP_Server_Project
  2. Create a virtual environment and install dependencies:

    python -m venv .venv
    source .venv/bin/activate  # On Windows use: .venv\Scripts\activate
    pip install -r requirements.txt
  3. Configure Environment Variables: Create a .env file in the root directory and add your API keys:

    OPENWEATHER_API_KEY=your_openweather_api_key
    OPENROUTER_API_KEY=your_openrouter_api_key
    MODEL=your_preferred_model_name

Running the Project

To use the client, you first need to start the MCP servers on their respective ports.

  1. Start the Calculator Server:

    python Calculator_MCP_Server.py

    (Runs on http://127.0.0.1:8001)

  2. Start the Weather Server:

    python Weather_MCP_Server.py

    (Runs on http://127.0.0.1:8002)

  3. Start the Client (in a new terminal):

    python client.py

You can now chat with the agent and ask it to perform calculations or fetch weather data!

About

MCP Server Project with Weather and Calculator servers

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages