WeatherServer
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@WeatherServerWhat's the weather in London?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
LangChain MCP Weather Application
A complete example demonstrating how to build and consume a Model Context Protocol (MCP) server using:
Python
FastMCP
LangChain
OpenAI
Open-Meteo APIs
The project exposes weather information through an MCP server and allows a LangChain agent to discover and invoke weather tools dynamically.
Features
The weather tool returns:
Latitude
Longitude
Timezone
Humidity
Wind Speed
Weather Conditions
Sunrise Time
Sunset Time
7-Day Forecast
The application demonstrates:
Creating an MCP server with FastMCP
Registering MCP tools
Connecting to MCP servers with LangChain
Discovering tools dynamically
Building AI agents that invoke MCP tools
Integrating external REST APIs
Architecture
+-------------------+
| LangChain Agent |
+---------+---------+
|
v
+-------------------+
| MCP Client |
| MultiServerMCP |
+---------+---------+
|
| stdio
|
v
+-------------------+
| MCP Server |
| FastMCP |
+---------+---------+
|
v
+-------------------+
| Weather Service |
+---------+---------+
|
v
+-------------------+
| Open-Meteo APIs |
+-------------------+Project Structure
project/
│
├── server.py
├── client.py
├── agent.py
├── weather_service.py
├── requirements.txt
├── .env
└── README.mdComponents
1. weather_service.py
Contains the business logic responsible for:
Geocoding
Converts a city name into:
Latitude
Longitude
Timezone
Uses:
https://geocoding-api.open-meteo.comWeather Retrieval
Fetches:
Current humidity
Wind speed
Weather conditions
Sunrise
Sunset
7-day forecast
Uses:
https://api.open-meteo.comExample Output
{
"city": "Matadi",
"latitude": -5.799,
"longitude": 13.440,
"timezone": "Africa/Kinshasa",
"humidity": 82,
"wind_speed": 12.4,
"weather_conditions": 1,
"sunrise": "2026-06-01T06:03",
"sunset": "2026-06-01T17:58",
"forecast": [
{
"date": "2026-06-01",
"min_temp": 20.2,
"max_temp": 29.1
}
]
}2. server.py
Creates the MCP server.
MCP Server Initialization
mcp = FastMCP("WeatherServer")Tool Registration
@mcp.tool()
def weather(city: str):
return get_weather(city)Start Server
mcp.run()The server exposes the weather tool to any MCP-compatible client.
3. client.py
Demonstrates connecting to the MCP server and discovering tools.
Create MCP Client
client = MultiServerMCPClient(
{
"weather_server": {
"transport": "stdio",
"command": "python",
"args": ["server.py"]
}
}
)Discover Tools
tools = await client.get_tools()Example Output
TOOLS
[StructuredTool(name='weather', ...)]4. agent.py
Builds an AI agent capable of invoking MCP tools.
Load Environment Variables
load_dotenv()Create OpenAI Model
llm = ChatOpenAI(
model="gpt-5-nano"
)Retrieve MCP Tools
tools = await client.get_tools()Create Agent
agent = create_agent(
model=llm,
tools=tools,
system_prompt="You are a weather assistant."
)Invoke Agent
result = await agent.ainvoke(
{
"messages": [
{
"role": "user",
"content": "What is the weather in Matadi?"
}
]
}
)Installation
Clone Repository
git clone https://github.com/your-org/weather-mcp.git
cd weather-mcpCreate Virtual Environment
Using venv
python -m venv .venvActivate:
Linux / macOS
source .venv/bin/activateWindows
.venv\Scripts\activateInstall Dependencies
pip install -r requirements.txtrequirements.txt
mcp
langchain
langchain-openai
langchain-mcp-adapters
python-dotenv
requests
openaiEnvironment Variables
Create a .env file:
OPENAI_API_KEY=your_openai_api_keyRunning the Application
Option 1: Run MCP Server
python server.pyThe server starts and waits for MCP client requests.
Option 2: Test MCP Client
python client.pyExample:
TOOLS
[StructuredTool(name='weather', ...)]Option 3: Run LangChain Agent
python agent.pyExample:
{
"city": "Matadi",
"latitude": -5.799,
"longitude": 13.440,
"timezone": "Africa/Kinshasa",
"humidity": 82,
"wind_speed": 12.4,
"weather_conditions": 1,
"sunrise": "2026-06-01T06:03",
"sunset": "2026-06-01T17:58",
"forecast": [
{
"date": "2026-06-01",
"min_temp": 20.2,
"max_temp": 29.1
}
]
}MCP Workflow
User Question
|
v
LangChain Agent
|
v
MCP Tool Discovery
|
v
Weather Tool
|
v
Open-Meteo APIs
|
v
Weather Data
|
v
Agent ResponseExample Queries
What is the weather in Paris?What is the humidity in New York?Give me the 7-day forecast for Tokyo.When is sunrise in London?What is the wind speed in Matadi?Future Enhancements
Multiple MCP servers
Weather alerts
Historical weather data
Air quality information
LangGraph integration
Redis caching
Azure deployment
Streaming responses
RAG integration
Multi-agent orchestration
Technologies Used
Python
FastMCP
LangChain
OpenAI
Open-Meteo API
AsyncIO
MCP (Model Context Protocol)
Learning Objectives
This project teaches:
MCP Server Development
MCP Tool Registration
MCP Client Integration
LangChain Tool Discovery
AI Agent Tool Calling
REST API Integration
Async Python Programming
OpenAI + LangChain Integration
License
MIT License
Copyright (c) 2026
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files to deal in the Software without restriction.
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ngangu63/WeatherMcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server