About My MCP Weather Server
A TypeScript example MCP server for developers testing MCP clients or agents. It returns structured dummy weather data for a few predefined cities over Streamable HTTP.
Key features
- 01get_city_weather tool
- 02Dummy weather for predefined cities
- 03Metric or imperial units
- 04Structured output schema
- 05In-memory session handling
Use cases
- 01Testing an MCP client’s tool calls
- 02Prototyping an agent that uses weather tools
MCP support
Implements MCP with Streamable HTTP transport and exposes the get_city_weather tool to MCP clients.
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 READMEMy MCP Weather Server
This project is an example of an MCP (Model Context Protocol) server built with the @modelcontextprotocol/sdk for TypeScript. It demonstrates how to expose a simple tool that provides dummy weather information for a few predefined cities.
This server is intended to be used as a backend for an MCP-compliant client, such as an LLM-powered agent that can leverage the tools exposed by this server.
Features
- MCP Compliant: Implements the Model Context Protocol.
- Streamable HTTP Transport: Uses the recommended
StreamableHTTPServerTransportfor communication. - Tool Exposure: Exposes a
get_city_weathertool.- Input:
city(string, e.g., "paris", "london", "tokyo") and optionalunit(enum: "metric" or "imperial", defaults to "metric"). - Output: Returns dummy weather information including temperature, description, and humidity.
- Structured Output: Provides
structuredContentmatching a definedoutputSchemafor reliable parsing by clients.
- Input:
- Basic Session Management: Demonstrates simple in-memory session handling for
StreamableHTTPServerTransport.
Prerequisites
- Node.js (v18 or higher recommended, as per MCP SDK)
- npm (or yarn/pnpm)
Setup
-
Clone the repository (or create the project files):
# If you have it in a git repo: # git clone <your-repo-url> # cd my-mcp-weather-server # Otherwise, ensure you have the project directory with src/server.ts, package.json, tsconfig.json -
Install dependencies:
npm install
Running the Server
For Development
This command uses ts-node to run the TypeScript source directly and nodemon to automatically restart the server on file changes.
npm run build
npm start
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.