MCP Weather & News Assistant

MCP Weather & News Assistant

An MCP server that provides real-time weather data and latest news headlines via custom tools.

Category
Visit Server

README

MCP Weather & News Assistant

An AI assistant project built with the Model Context Protocol (MCP) that connects an LLM to real-world data sources via custom MCP tools.
It provides real-time weather information and latest news headlines by allowing the model to call external APIs through an MCP server.


Features

  • Real-time Weather Data: Get current weather conditions (temperature, humidity, wind speed, description) for any city
  • Latest News Articles: Fetch top 5 news articles by topic using NewsAPI
  • MCP Protocol: Standards-based integration with any MCP-compatible client using FastMCP
  • Two Tools: weather(city) and news(topic) tools exposed via MCP
  • Secure: API keys stored in environment variables using python-dotenv

Prerequisites

Before deploying this MCP server, ensure you have:


Installation

1. Clone the Repository

git clone https://github.com/ZiliOussema/mcp_weather_and_news_assistant.git
cd mcp_weather_and_news_assistant

2. Create Virtual Environment

# Windows
python -m venv venv
venv\Scripts\activate

# macOS/Linux
python3 -m venv venv
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Set Up Environment Variables

Create a .env file in the project root (you can copy from .env.sample):

# Copy the sample file
cp .env.sample .env

# Then edit .env and add your API keys

Your .env file should contain:

OPENWEATHER_API_KEY=your_openweather_api_key_here
NEWS_API_KEY=your_newsapi_key_here

IMPORTANT: Never commit your .env file to version control!


Finding Your Project Path

Before configuring any MCP client, you need to know your project's full path.

Windows

Open Command Prompt in your project folder and run:

cd

Or use PowerShell:

pwd

macOS/Linux

Open Terminal in your project folder and run:

pwd

Deployment

1. Claude Desktop

Windows

Step 1: Locate the Claude Desktop configuration file

Path: %APPDATA%\Claude\claude_desktop_config.json

Step 2: Open claude_desktop_config.json and add your MCP server:

{
  "mcpServers": {
    "weather-news": {
      "command": "C:\\path\\to\\your\\project\\venv\\Scripts\\python.exe",
      "args": [
        "src/server.py"
      ],
      "cwd": "C:\\path\\to\\your\\project"
    }
  }
}

Important Notes:

  • Replace C:\\path\\to\\your\\project\\ with your actual project path
  • Use double backslashes (\\) in Windows paths
  • Paths must be absolute (full path from C:)

Step 3: Verify the paths exist

"C:\path\to\your\project\mcp_weather_and_news_assistant\venv\Scripts\python.exe" --version

Step 4: Restart Claude Desktop

  • Completely close Claude Desktop
  • Check Task Manager to ensure no Claude processes are running
  • Reopen Claude Desktop

Step 5: Verify the server is loaded

  • Look for a plug icon or "MCP" section in Claude Desktop
  • You should see weather and news tools available
  • Try asking: "What's the weather in Paris?"

macOS

Step 1: Locate the configuration file

~/Library/Application Support/Claude/claude_desktop_config.json

Step 2: Edit the configuration:

nano ~/Library/Application\ Support/Claude/claude_desktop_config.json

Add:

{
  "mcpServers": {
    "weather-news": {
      "command": "/Users/YOUR_USERNAME/mcp_weather_and_news_assistant/venv/bin/python",
      "args": [
        "src/server.py"
      ],
      "cwd": "/Users/YOUR_USERNAME/mcp_weather_and_news_assistant"
    }
  }
}

Step 3: Restart Claude Desktop

killall Claude

Then reopen Claude Desktop from Applications.


Linux

Step 1: Configuration location

~/.config/Claude/claude_desktop_config.json

Step 2: Edit configuration:

nano ~/.config/Claude/claude_desktop_config.json

Add:

{
  "mcpServers": {
    "weather-news": {
      "command": "/home/YOUR_USERNAME/mcp_weather_and_news_assistant/venv/bin/python",
      "args": [
        "src/server.py"
      ],
      "cwd": "/home/YOUR_USERNAME/mcp_weather_and_news_assistant"
    }
  }
}

Step 3: Restart Claude Desktop

pkill claude

2. Continue (VS Code)

Step 1: Install Continue extension

  1. Open VS Code
  2. Go to Extensions (Ctrl+Shift+X)
  3. Search for "Continue"
  4. Click Install

Step 2: Open Continue configuration

  • Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS)
  • Type: Continue: Open config.json
  • Press Enter

Step 3: Add MCP server to Continue config

For Windows:

mcpServers:
  weather-news:
    command: C:\path\to\your\project\venv\Scripts\python.exe
    args:
      - src/server.py
    cwd: C:\path\to\your\project

For macOS/Linux:

mcpServers:
  weather-news:
    command: /Users/YOUR_USERNAME/mcp_weather_and_news_assistant/venv/bin/python
    args:
      - src/server.py
    cwd: /Users/YOUR_USERNAME/mcp_weather_and_news_assistant

Step 4: Reload VS Code

  • Press Ctrl+Shift+P / Cmd+Shift+P
  • Type: Developer: Reload Window
  • Press Enter

Step 5: Test in Continue

Open Continue sidebar and ask:

What's the weather in New York?

3. Cline

Step 1: Install Cline

  1. Open VS Code
  2. Go to Extensions (Ctrl+Shift+X)
  3. Search for "Cline"
  4. Click Install

Step 2: Configure Cline MCP settings

  • Click the Cline icon in VS Code sidebar
  • Go to Cline Settings (gear icon)
  • Find "MCP Servers" section

Step 3: Add configuration

Click "Add MCP Server" and fill in:

  • Name: weather-news
  • Command: Path to your Python executable
  • Args: Path to your server.py

Or edit settings.json:

{
  "cline.mcpServers": [
    {
      "name": "weather-news",
      "command": "C:\\path\\to\\your\\project\\venv\\Scripts\\python.exe",
      "args": [
        "src/server.py"
      ],
      "cwd": "C:\\path\\to\\your\\project"
    }
  ]
}

Step 4: Restart Cline or reload VS Code


Usage Examples

Weather Queries

User: What's the weather like in Tokyo?

Response:

The current weather in Tokyo is 18°C with clear skies. 
Humidity is at 65% with a light breeze of 5 m/s.

News Queries

User: Show me the latest technology news

Response:

Here are the top 5 tech headlines:
1. New AI breakthrough announced by researchers
   Source: TechCrunch | Published: 2026-02-03
2. Tech company releases innovative product
   Source: The Verge | Published: 2026-02-03
...

Combined Queries

User: What's the weather in London and any technology news?

Troubleshooting

Server Not Loading in Claude Desktop

  1. Check configuration file location

    # Windows
    echo %APPDATA%\Claude\claude_desktop_config.json
    
    # macOS
    echo ~/Library/Application\ Support/Claude/claude_desktop_config.json
    
    # Linux
    echo ~/.config/Claude/claude_desktop_config.json
    
  2. Verify JSON syntax at jsonlint.com

  3. Check Python path

    # Windows
    "C:\path\to\your\project\venv\Scripts\python.exe" --version
    
    # macOS/Linux
    /path/to/your/project/venv/bin/python --version
    
  4. View Claude logs

    • Windows: %APPDATA%\Claude\logs\
    • macOS: ~/Library/Logs/Claude/
    • Linux: ~/.local/state/Claude/logs/

"Module not found" Error

  1. Activate virtual environment and reinstall

    # Windows
    venv\Scripts\activate
    pip install -r requirements.txt
    
    # macOS/Linux
    source venv/bin/activate
    pip install -r requirements.txt
    
  2. Verify packages are installed

    pip list
    

API Errors (401, 403, 404)

  1. Verify API keys in .env file

    cat .env
    
  2. Test API keys manually

    # Test OpenWeatherMap
    curl "https://api.openweathermap.org/data/2.5/weather?q=Paris&appid=YOUR_KEY&units=metric"
    
    # Test NewsAPI
    curl "https://newsapi.org/v2/everything?q=technology&apiKey=YOUR_KEY&pageSize=5"
    
  3. Check API key limits

    • OpenWeatherMap: 60 calls/minute
    • NewsAPI: 100 requests/day (free tier)

Tools Not Appearing in Continue/Cline

  1. Reload VS Code: Ctrl+Shift+P → "Developer: Reload Window"

  2. Check logs in VS Code Output panel

  3. Test server manually

    python src/server.py
    

"Permission Denied" on macOS/Linux

chmod +x server.py

Project Structure

mcp_weather_and_news_assistant/
├── src/
│   ├── __pycache__/           
│   ├── tools/
│   │   ├── __pycache__/      
│   │   ├── __init__.py
│   │   ├── news.py            # News tool implementation
│   │   └── weather.py         # Weather tool implementation
│   └── server.py              # Main MCP server entry point
├── test/
│   ├── interactive_test.py    # Interactive testing script
│   └── test_tools.py          # Unit tests for tools
├── venv/                      # Virtual environment 
├── .env                       # Environment variables
├── .env.sample                # Sample environment file
├── .gitignore
├── requirements.txt           # Python dependencies
└── README.md                  # Documentation

Testing the Server

Manual Testing

# Activate environment
source venv/bin/activate  # or venv\Scripts\activate on Windows

# Run server
python src/server.py

Interactive Testing

The project includes an interactive test script to verify your API keys and tools:

# Activate environment
source venv/bin/activate  # or venv\Scripts\activate on Windows

# Run interactive test
python test/interactive_test.py

This will test both the weather and news tools with sample queries.

Unit Tests

Run the unit tests to verify tool functionality:

# Run all tests
python -m pytest test/

# Run specific test file
python test/test_tools.py

Security Best Practices

  1. Never commit API keys - Always use .env file
  2. Add .env to .gitignore
  3. Rotate keys regularly
  4. Use read-only keys when possible

MCP Weather & News Assistant - A portfolio project demonstrating Model Context Protocol integration

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured