๐ฆ๏ธ Weather MCP (Model Context Protocol) Demo
LocalAbout ๐ฆ๏ธ Weather MCP (Model Context Protocol) Demo
Weather MCP Demo combines a Python weather server with a GPT-4 command-line client for natural-language weather queries. It is an example system showing how a client can discover and use a server tool.
Key features
- 01Weather server over SSE
- 02Discoverable fetch-weather tool
- 03GPT-4 natural-language client
- 04Interactive command-line interface
Use cases
- 01Asking for weather in natural language
- 02Exploring client-side tool discovery
- 03Studying a weather MCP client-server setup
MCP support
The server exposes a fetch-weather tool over SSE for MCP clients. The included OpenAI client discovers and uses that tool to handle weather queries.
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 README๐ฆ๏ธ Weather MCP (Model Context Protocol) Demo
This project demonstrates the implementation of a Model Context Protocol (MCP) system for weather information, consisting of a client using OpenAI's agents and a dedicated MCP server. The system allows users to query weather information through a natural language interface powered by GPT-4.
๐ Overview
The project is split into two main components:
- Weather MCP Server: A Python-based server that provides weather information.
- Weather OpenAI Client: A client that uses OpenAI's GPT-4 model to process natural language requests and interact with the MCP server.
๐ Components
๐ Weather MCP Server
๐ Located in: /server_weather/
The server component implements a Model Context Protocol server that:
- Exposes a weather information endpoint via SSE (Server-Sent Events).
- Provides a
fetch-weathertool that can be discovered by MCP clients. - Runs on
http://localhost:4000/sse.
๐ค Weather OpenAI Client
๐ Located in: /client_weather_openai/
The client component features:
- Integration with OpenAI's GPT-4 model.
- Automatic tool discovery from the MCP server.
- Natural language processing for weather queries.
- Interactive command-line interface for user interactions.
๐ Prerequisites
- Python 3.x
- OpenAI API Key (Get yours from OpenAI Platform)
- Environment Variables properly configured (
.envfile)
๐ง Setup
1. Clone this repository
git clone [email protected]:sturlese/client_server_mcp.git
cd client_server_mcp
2. Set up environment variables
- Create a
.envfile in the root of each component (/server_weather/and/client_weather_openai/). - Add your OpenAI API key:
# Example of .env file
OPENAI_API_KEY='your-api-key-here'
3. Install dependencies
Server component:
cd server_weather/
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Client component:
cd ../client_weather_openai/
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
๐ฎ Usage
Start the MCP Server
cd server_weather/
source venv/bin/activate
python server_weather.py
Start the OpenAI Client
cd client_weather_openai/
source venv/bin/activate
python weather_agent_openai.py
Example Usage
What's the weather in New York today?
๐๏ธ Architecture
The system uses the Model Context Protocol (MCP) to enable seamless communication between the AI agent and the weather service:
User ---> OpenAI Agent (Client) ---> MCP Server ---> Weather Data
๐ License
This project is open-source and available under the MIT License.
๐ค Contributing
Contributions, issues, and feature requests are welcome!
- Fork the project.
- Create a new branch (
git checkout -b feature/your-feature). - Make your changes.
- Commit your changes (
git commit -m 'Add your feature'). - Push to your branch (
git push origin feature/your-feature). - Open a pull request.
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.