Question-to-HeadlinesMCP-server

konapalask/Question-to-HeadlinesMCP-server

3.1

If you are the rightful owner of Question-to-HeadlinesMCP-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 FastMCP News Aggregator is a Model Context Protocol (MCP) server that integrates with NewsAPI.org to provide real-time news data to AI clients.

Tools
3
Resources
0
Prompts
0

#BuildWithPuch

📰 FastMCP News Aggregator

A Model Context Protocol (MCP) server built with FastMCP and NewsAPI.org.
This MCP server allows AI clients to fetch top headlines, search all articles, and list available news sources in real time.


🚀 Features

  • Top Headlines: Get the latest headlines filtered by category, source, or keyword.
  • Everything Search: Search historical and current news articles with date range and sorting.
  • News Sources: List available news publishers and sources.
  • Built with Python and FastMCP for quick integration into AI workflows.
  • Uses the official newsapi-python client.

📦 Installation

  1. Clone this repository
    git clone https://github.com/konapalask/Question-to-HeadlinesMCP-server
    cd Question-to-HeadlinesMCP-server
    

2. **Install dependencies**

   ```bash
   pip install fastmcp newsapi-python
  1. Get an API key from https://newsapi.org/register (Free tier available).

  2. Set your API key in .env

    NEWS_API_KEY=your_api_key
    

🖥 Usage

Run the MCP server:

python news_server.py

This server exposes three MCP tools:

  1. get_top_headlines → Fetch the latest news headlines
  2. get_everything → Search all news articles
  3. get_sources → List available news sources

📌 Example Calls

1️⃣ Get Top Headlines

{
  "query": "bitcoin",
  "sources": "bbc-news,the-verge",
  "category": "business",
  "country": "us"
}

2️⃣ Search All Articles

{
  "query": "artificial intelligence",
  "from_param": "2025-08-01",
  "to": "2025-08-09",
  "sort_by": "publishedAt"
}

3️⃣ Get Sources

{
  "category": "technology",
  "country": "us"
}

📂 Project Structure

fastmcp-news-aggregator/
│── news_server.py   # Main MCP server code
│── README.md        # Project documentation

🛠 Requirements

  • Python 3.8+
  • fastmcp
  • newsapi-python

Install all requirements:

pip install -r requirements.txt

⚠️ Limitations

  • The free tier of NewsAPI does not support get_everything for historical data older than 30 days.
  • Rate limits apply (check NewsAPI pricing).

📜 License

This project is licensed under the MIT License. Feel free to modify and use it for your own projects.


🙌 Acknowledgements