Weather MCP Server
Provides weather information and time utilities for AI assistants, enabling them to fetch current weather for any city and get the current timestamp.
README
Weather MCP Server
A Model Context Protocol (MCP) server that provides weather information and time utilities for AI assistants and applications.
Overview
This MCP server implements a simple weather service with two main tools:
- Weather Information: Get current weather data for any city
- Time Service: Retrieve the current timestamp
Built with TypeScript and the official MCP SDK, this server demonstrates how to create custom tools that can be used by Claude Desktop and other MCP-compatible clients.
Features
- š¤ļø Weather Data: Fetch weather information for any city worldwide
- ā° Time Service: Get current timestamp in ISO format
- š Input Validation: Robust parameter validation using Zod schemas
- š TypeScript: Full type safety and modern JavaScript features
- š” stdio Transport: Communicates via standard input/output for seamless integration
Installation
Prerequisites
- Node.js 18+
- npm or yarn package manager
Setup
-
Clone the repository
git clone <repository-url> cd my-mcp-server -
Install dependencies
npm install -
Build the project
npm run build
Usage
Development
Run the server in development mode:
npm run dev
Production
Start the built server:
npm start
Integration with Claude Desktop
Add this server to your Claude Desktop configuration:
{
"mcpServers": {
"weather-server": {
"command": "node",
"args": ["/path/to/my-mcp-server/build/index.js"]
}
}
}
Available Tools
get_weather
Retrieves weather information for a specified city.
Parameters:
city(string, required): The city to get weather forunits(string, optional): Temperature units - "metric" or "imperial" (defaults to "metric")
Example Response:
Weather in London:
Temperature: 18°C
Conditions: Partly cloudy
Humidity: 65%
get_time
Returns the current timestamp in ISO 8601 format.
Parameters: None
Example Response:
Current time: 2025-01-08T14:30:25.123Z
Project Structure
my-mcp-server/
āāā index.ts # Main server implementation
āāā package.json # Project dependencies and scripts
āāā tsconfig.json # TypeScript configuration
āāā build/ # Compiled JavaScript output
āāā README.md # This file
Technical Details
Dependencies
- @modelcontextprotocol/sdk: Official MCP SDK for server implementation
- axios: HTTP client for external API calls
- zod: Runtime type validation and parsing
Architecture
The server follows the MCP specification:
- Tool Registration: Tools are registered via
ListToolsRequestSchemahandler - Tool Execution: Tool calls are handled via
CallToolRequestSchemahandler - Error Handling: Proper MCP error codes and validation
- Transport: Uses stdio transport for communication
Weather Data
Currently returns mock weather data for demonstration purposes. To integrate with a real weather API:
- Sign up for a weather service (e.g., OpenWeatherMap)
- Replace the mock data generation in the
get_weathercase - Add proper API key handling and HTTP requests
Scripts
npm run build- Compile TypeScript to JavaScriptnpm run dev- Build and run in development modenpm start- Run the compiled server
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Build and test (
npm run build) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is open source and available under the MIT License.
Learn More
Built with ā¤ļø using TypeScript and the Model Context Protocol
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.