Suggested as a replacement for the hardcoded geolocation functionality to get real coordinates for cities via the Google Maps API
Allows exposing the weather tools to LangChain agents for building workflows that can access location and weather data
Enables exposing the weather tools to OpenAI function-calling agents to incorporate weather data into conversations and decision-making
๐ฆ๏ธ MCP Weather Server
A simple and modular MCP (Modular Command Protocol) server that exposes weather-related tools โ perfect for integration with AI agents, LLMs, or any tool-using client.
This project demonstrates how to create and serve tools such as:
get_coordinates(city)get_forecast(latitude, longitude)
Designed to be lightweight, clean, and easy to extend.
๐ง What Is MCP?
MCP (Modular Command Protocol) is a protocol for exposing tools (Python functions) in a machine-readable format so they can be:
Automatically discovered
Dynamically called by AI agents
Interoperable across systems
Itโs built for tool-using LLMs, agents, and next-gen integrations.
Related MCP server: MCP Weather Server
๐ Project Structure
๐ Getting Started
1. Clone the Repo
3. Run the Server
This starts the MCP server over stdio. You can connect any MCP client that supports the protocol.
๐ง Tools Overview
get_coordinates(city: str) -> Tuple[float, float]
Returns hardcoded latitude and longitude for a given city.
โ Replace this with a real geolocation API like OpenCage or Google Maps.
get_forecast(latitude: float, longitude: float) -> str
Returns a formatted weather forecast string for the given coordinates.
โ Replace with a live weather API like api.weather.gov.
format_forecast(forecasts: List[Dict]) -> str
Helper function that formats multiple forecast entries into a readable string.
๐งฉ Want to Build an MCP Client?
Stay tuned! The next part of this project will include a lightweight client that can:
Auto-discover tools
Call them based on context
Build real-time agent workflows
๐ง Use Cases
Build agent backends with clean, callable tools
Expose local or cloud-based APIs to LLMs
Prototype tools for LangChain or OpenAI function-calling agents
Teach MCP integration through a practical example
๐ License
This project is open-source under the MIT License.
๐ Contributing
Pull requests are welcome! Feel free to open issues or suggest features you'd like to see.
๐ Related
๐ Original article on LinkedIn โ (https://www.linkedin.com/build-relation/newsletter-follow?entityUrn=7349014151165313025)