mcp-server

kevinthomasissac/mcp-server

3.2

If you are the rightful owner of mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The MCP Server for Weather provides U.S. weather forecasts and severe weather alerts using data from the National Weather Service (NWS).

Tools
2
Resources
0
Prompts
0

🌦️ MCP Server – Weather

A Model Context Protocol (MCP) server providing U.S. weather forecasts and severe weather alerts using data from the National Weather Service (NWS).


🧩 Features

  • get-alerts: Fetch current weather alerts for a U.S. state
  • get-forecast: Get a short-term forecast for a U.S. location (latitude/longitude)

📦 Project Setup

1. Clone and install dependencies

git clone <your-repo-url>
cd mcp-server-weather
npm install

2. Build the TypeScript code

npm run build

This compiles the source from src/ to dist/.


3. Run the server directly

node dist/index.js

You should see:

Weather MCP Server running on stdio

🧰 Testing with the MCP Inspector CLI

The official CLI tool for interacting with MCP servers is @modelcontextprotocol/inspector.


4. List available tools

npx @modelcontextprotocol/inspector --cli node dist/index.js --method tools/list

Expected output:

{
  "tools": [
    { "name": "get-alerts", "description": "Get weather alerts for a US state" },
    { "name": "get-forecast", "description": "Get weather forecast for a location in the US" }
  ]
}

5. Get weather alerts

npx @modelcontextprotocol/inspector --cli node dist/index.js \
  --method tools/call \
  --params '{"name":"get-alerts","arguments":{"state":"CA"}}'

6. Get forecast

npx @modelcontextprotocol/inspector --cli node dist/index.js \
  --method tools/call \
  --params '{"name":"get-forecast","arguments":{"latitude":37.7749,"longitude":-122.4194}}'

⚙️ Publishing to npm

To publish this MCP server as an npm CLI tool:

  1. Update the name, version, and repository fields in your package.json.
  2. Ensure the executable mapping is correct:
    "bin": {
      "mcp-server-weather": "dist/index.js"
    }
    
  3. Build the project:
    npm run build
    
  4. Make sure the binary file is executable:
    chmod +x dist/index.js
    
  5. Log in to npm:
    npm login
    
  6. Publish:
    npm publish --access public
    

After publishing, anyone can install and run your server globally:

npm install -g mcp-server-weather
mcp-server-weather

⚙️ Node.js Version

  • Minimum required: Node.js 18
  • Recommended: Node.js ≥ 22.7.5 (to match the latest @modelcontextprotocol/inspector)
  • Update using:
    brew upgrade node@22
    

🧱 Project Structure

mcp-server-weather/
├── src/
│   └── index.ts
├── dist/
│   └── index.js
├── package.json
├── tsconfig.json
└── README.md

🧩 Development Commands

CommandDescription
npm run buildCompile TypeScript into dist/
npm run watchWatch for changes and rebuild automatically
npm run cleanClean build artifacts
npm run do-publishClean, install, and publish package to npm
npm run publish-dry-runTest npm publish process without uploading

⚙️ Notes

  • The server uses STDIO transport and must not write to stdout (use console.error() for logs).
  • MCP clients (like OpenAI ChatGPT or the MCP Inspector) communicate via JSON-RPC.
  • Works only for U.S. coordinates, as the NWS API doesn’t cover other countries.

📜 License

MIT License © 2025