Get the FREE Ultimate OpenClaw Setup Guide →

mcp -sample

Modelo de Servidor MCP baseado na documentação oficial

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio gabrielfroes-mcp-server-sample node build/main.js

How to use

This MCP server is a Node.js/TypeScript implementation that exposes two MCP tools for weather information: get-alerts and get-forecast. The get-alerts tool fetches active weather alerts for a state using a two-letter code (for example, CA or NY), while the get-forecast tool returns weather forecasts for geographic coordinates (latitude and longitude). The server communicates over stdio via the MCP protocol, allowing tools to be invoked and results streamed back to MCP clients. The codebase is organized into domain, infrastructure, application, and interface layers, with a main entry point that boots the MCP server and registers the available tools.

To use the server, ensure it is built (npm install followed by npm run build) and then run the generated entry script. Tools are registered via the WeatherToolsController in the interface layer, which also defines Zod-based validation schemas to ensure correct input formats before calling the underlying NWS API service through the infrastructure layer.

How to install

Prerequisites:

  • Node.js (LTS version)
  • Git

Step-by-step:

  1. Clone the repository git clone <REPOSITÓRIO_URL> cd mcp-server-sample

  2. Install dependencies npm install

  3. Build the project (transpile TypeScript to JavaScript) npm run build

  4. Run the server (via Node on the compiled entry point) node build/main.js

Optional: If you want to test the CLI-style MCP interaction, you can register the server as a bin and run the provided weather command after npm link: npm link weather

Notes:

  • The server is designed to be run as a standard Node.js process that communicates over stdio using the MCP protocol.
  • The two exposed tools (get-alerts and get-forecast) rely on the NWS API via the infrastructure layer.

Additional notes

Tips and considerations:

  • The input validation uses Zod to ensure correct parameter formats (e.g., state codes like CA, NY for alerts; latitude/longitude for forecasts).
  • If you run into CORS or network issues when accessing the NWS API, verify network egress permissions and check for API rate limits.
  • Since the server communicates over stdio, you can integrate it with MCP clients or test harnesses that simulate MCP messages.
  • For production, consider pinning Node.js version and ensuring the built output (build/main.js) is included in deployment artifacts.
  • If you modify the API integration, maintain the separation between domain models and infrastructure services to preserve a clean DDD-like structure.

Related MCP Servers

Sponsor this space

Reach thousands of developers