A Model Context Protocol (MCP) server that provides weather information for various cities.
This is a TypeScript-based MCP server that implements weather-related tools and resources. It enables AI agents and tools compatible with the MCP protocol to access weather data in a standardized way.
- get_weather tool: Retrieve current weather conditions for supported cities
- weather://cities resource: List of supported cities with available weather data
- London (22° C, Sunny)
- Paris (25° C, Cloudy)
- Node.js 18+
- npm or yarn
# Install dependencies
npm install# Compile TypeScript to JavaScript
npx tsc# Execute the server
node server.jsOr use tsx for direct execution:
npx tsx server.ts.
├── server.ts # Main server implementation with tools and resources
├── package.json # Project dependencies and metadata
├── package-lock.json # Locked dependency versions
├── .gitignore # Git ignore rules
└── .github/
└── copilot-instructions.md # AI agent development guidelines
This project follows the MCP server architecture:
- Server Setup: Uses
McpServerfrom the official MCP SDK - Tool Registration: Weather tools defined with Zod input validation
- Resource Management: Static resources listing available weather data
- Type Safety: Full TypeScript with strict mode
Retrieves current weather for a specified city.
Input Schema:
{
city: string // City name (e.g., "London", "Paris")
}Response:
{
"temp": "22° C",
"conditions": "Sunny"
}Returns a list of supported cities for weather queries.
All configuration is in package.json. The server uses:
@modelcontextprotocol/sdk- MCP protocol implementationzod- Runtime schema validationtypescript- Type safety and compilation
See .github/copilot-instructions.md for detailed instructions for AI agents and developers working on this project.
When adding new tools:
- Define the input schema with Zod
- Register the handler with proper MCP ContentBlock structure
- Update this README with new features
ISC