Skip to main content
Glama
jeannassereldine

MCP Weather Server

🌦️ 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: ai-mcp

πŸ“ Project Structure

mcp-server/
β”œβ”€β”€ main.py           # Starts the FastMCP server
β”œβ”€β”€ tools   
|------ get_forcast.py         # MCP tools: get_coordinates and get_forecast
β”œβ”€β”€ pyproject.toml   # Python dependencies
└── README.md         # You're here!

πŸš€ Getting Started

1. Clone the Repo

git clone https://github.com/jeannassereldine/mcp-server.git
cd mcp-server

3. Run the Server

uv run weather.py

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.


Available Tools

2 tools
get_coordinatesC
Returns the latitude and longitude of the specified city as a tuple.
 Args:
    city: the city of 
ParametersJSON Schema
NameRequiredDescriptionDefault
cityYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it states the return format (tuple), it doesn't mention error conditions, rate limits, authentication requirements, or what happens with invalid city names. For a tool with no annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is brief but poorly structured. The first sentence is clear, but the 'Args:' section is incomplete ('the city of' ends abruptly). While it's concise, the incomplete sentence undermines its effectiveness. Every sentence should earn its place, and the incomplete second sentence doesn't.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (one parameter) and the presence of an output schema, the description is somewhat complete but has gaps. The output schema existence means the description doesn't need to explain return values in detail, but it should still cover behavioral aspects. With no annotations and minimal parameter documentation, it's adequate but with clear room for improvement.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal parameter semantics beyond what the schema provides. It mentions 'city: the city of' but this is incomplete and adds little value. With 0% schema description coverage and only one parameter, the baseline would be 4 for zero parameters, but here we have one undocumented parameter. The description doesn't compensate for the coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Returns the latitude and longitude of the specified city as a tuple.' This is a specific verb (returns) + resource (latitude and longitude) combination. However, it doesn't distinguish this tool from its sibling 'get_forecast' - both likely involve geographic data but serve different purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance about when to use this tool versus alternatives. There's no mention of the sibling tool 'get_forecast' or any context about when coordinate retrieval is appropriate versus weather forecasting. The description only states what the tool does, not when to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_forecastC

Get weather forecast for a location. Args: latitude: Latitude of the location longitude: Longitude of the location

ParametersJSON Schema
NameRequiredDescriptionDefault
latitudeYes
longitudeYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't describe important behavioral aspects: whether this is a read-only operation, what data format is returned, if there are rate limits, authentication requirements, or error conditions. The description is minimal and lacks operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with a clear purpose statement followed by parameter documentation. The two-sentence structure is efficient with no wasted words. However, the 'Args:' formatting is slightly redundant since parameters are already documented in the schema, preventing a perfect score.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which handles return values) and simple parameters, the description is minimally adequate. However, for a weather forecasting tool with no annotations, users would benefit from more context about forecast type, time horizon, data sources, or common use cases. The description meets basic requirements but leaves important questions unanswered.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must compensate. It explicitly lists both parameters (latitude, longitude) and their purpose ('of the location'), which adds value beyond the bare schema. However, it doesn't provide format details (e.g., decimal degrees), valid ranges, or examples. The baseline would be lower without this parameter listing.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with 'Get weather forecast for a location' - a specific verb ('Get') and resource ('weather forecast'). It distinguishes from the sibling tool 'get_coordinates' by focusing on forecast rather than location data. However, it doesn't specify what type of forecast (e.g., daily, hourly, current) or time range, keeping it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention the sibling tool 'get_coordinates' or suggest when one might be preferred over the other (e.g., use get_coordinates first to obtain coordinates, then get_forecast). There's no context about prerequisites or limitations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 2 tool updates
    • First observedget_coordinates
    • First observedget_forecast

TDQS

B3.1/5.0

Scored across 2 tools

Disambiguation5/5

The two tools have completely distinct purposes: get_coordinates converts a city name to geographic coordinates, while get_forecast provides weather data for given coordinates. There is no overlap or ambiguity between these functions.

Naming Consistency5/5

Both tools follow a consistent 'verb_noun' naming pattern (get_coordinates, get_forecast) with identical verb style and snake_case convention throughout. The naming is perfectly uniform and predictable.

Tool Count2/5

With only 2 tools, this server feels severely under-scoped for a weather domain. A weather server should typically include current conditions, forecasts, historical data, alerts, and multiple location input methods. Two tools cannot provide meaningful coverage.

Completeness2/5

The tool surface is severely incomplete for a weather server. Missing essential operations like getting current weather conditions, temperature data, precipitation forecasts, weather alerts, or supporting direct city name input for forecasts. The workflow requires manual coordinate lookup before getting forecasts, creating unnecessary friction.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers