MCP Server Sample
About
Provides weather information tools using the US National Weather Service API.
Details
- Author
- williammian
- Categories
- Cloud Service, Other
Jump to
Setup
Install MCP Server Sample in your MCP client (Claude Desktop, Cursor, Windsurf, and others).
Repository: https://github.com/williammian/mcp-server-sample
Follow the installation instructions in the repository README, then restart your MCP client.
Provides weather information tools using the US National Weather Service API.
Este projeto demonstra como construir um servidor MCP com integração a APIs externas e validação de dados.
Este repositório contém um exemplo de implementação de um servidor MCP (Model Context Protocol) em Node.js/TypeScript, que fornece duas ferramentas para obter informações meteorológicas usando a API do National Weather Service (NWS) dos EUA.
- get-alerts: Retorna alertas meteorológicos ativos para um estado (código de duas letras, ex:CA,NY).
- get-forecast: Retorna a previsão do tempo para coordenadas geográficas (latitude, longitude).
- Validação de entrada usandoZod.
- Integração com a API do NWS usandofetch(camada de infraestrutura).
- Comunicação viastdiousando o protocolo MCP (@modelcontextprotocol/sdk).
O projeto segue uma arquitetura em camadas inspirada em padrões deDomain-Driven Design(DDD):
-
Domain(src/domain): Definição de interfaces e tipos que representam as estruturas de dados (ex:AlertFeature,ForecastPeriod,AlertsResponse).
Infrastructure(src/infrastructure): Implementação de serviços externos, como oNWSApiService, responsável por realizar as chamadas HTTP à API do NWS.
Application(src/application): Contém a lógica de negócio noWeatherService, que processa e formata os dados vindos da infraestrutura.
Interface(src/interface): Inclui controladores (WeatherToolsController) que registram as ferramentas no servidor MCP, definem schemas de validação e retornam os resultados.
Entry Point(src/main.ts): Inicializa oMcpServer, configura o transporte (StdioServerTransport), instancia serviços e controladores, e inicia escuta emstdio.
src/ ├── domain/ │ └── models/ # Interfaces de domínio ├── infrastructure/ │ └── services/ # Implementações da API externa (NWS) ├── application/ │ └── services/ # Lógica de negócio e formatação de dados ├── interface/ │ └── controllers/ # Registro das ferramentas MCP e validação └── main.ts # Ponto de entrada do servidor build/ # Código JavaScript compilado
git clone <REPOSITÓRIO_URL> cd mcp-server-sample npm install npm run build
Após o build, você pode executar o servidor diretamente:
Ou, se registrado como binário (weather):
O servidor iniciará na saída padrão (stdio) e aguardará requisições MCP.
Consumir com clients IA (Claude Desktop)
Em Arquivo > Configurações > Desenvolvedor
{ "mcpServers": { "weather": { "command": "node", "args": ["C:\\Fontes\\mcp-server-sample\\build\\main.js"] } } }
Provides aviation weather information for flight planning from aviationweather.gov.
Fetches precipitation forecast data for a specific location using the Buienradar service.
Query weather information and meteorological warnings for Chinese cities using the QWeather API.
Integrates the US National Weather Service API to provide real-time weather data and forecasts.
A server for fetching weather information using the OpenWeather API.
Provides hourly weather forecasts using the AccuWeather API.
Fetches weather data for any city using the Open-Meteo API.
Access global weather forecasts and historical data through the Open-Meteo API.
Access global weather data and forecasts using the OpenMeteo API, including current conditions, historical data, and location search.
Provides comprehensive weather data and forecasts using the OpenWeatherMap API.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.




