Skip to content

feat: Add MCP News system #918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: Add MCP News system #918

wants to merge 1 commit into from

Conversation

Vasco0x4
Copy link

MCP News - Implementation

Overview

The MCP News system allows users to retrieve real-time news.

Usage Example

image)

Illustrated Flow:

  1. User Query (blue): "Give me the latest news in India"
  2. MCP Call (orange): self.news.search
  3. Structured Response (light blue): Relevant articles with titles, descriptions and sources

Architecture

Main Components

NewsManager: Central manager

  • News providers management
  • Smart cache with TTL
  • Multi-source results merging
  • Persistent configuration (NVS)

NewsProvider: Provider interface

  • FreeNewsProvider: RSS without API key
  • Extensible for other providers (NewsAPI, etc.)

Data structures:

struct NewsArticle {
    string title, description, content, url, source;
    string published_at, category, language;
    double relevance_score;
    vector<string> keywords;
};

struct NewsSearchParams {
    string query, category, language, country, sort_by;
    int max_results;
    string date_from, date_to;
    bool include_content;
};

Available MCP Tools (3 tools)

1. self.news.search

Keyword search (as shown in example)

{
    "query": "latest news in India",
    "category": "general", 
    "language": "en",
    "max_results": 10
}

2. self.news.get_headlines

Daily headlines by category

{
    "category": "general",
    "country": "us",
    "max_results": 5
}

3. self.news.get_trending

Trending topics

{
    "language": "en",
    "max_results": 8
}

Demonstrated Features

In the example:

  • Contextual search ("India" → articles about India)
  • Caching 10 articles
  • Detailed article content
  • Multiple sources (Sky News in example)

RSS Sources Used

Available categories with RSS feeds:

  • General News: Sky News, Yahoo News, The Guardian, Time Magazine, Reuters
  • Technology: Wired, TechCrunch, O'Reilly Radar
  • Business: Wall Street Journal, Bloomberg, Guardian Business
  • Sports: ESPN, Sky Sports, Guardian Sport
  • Science: Nature, Science Daily, Guardian Science
  • Health: Medical News Today, Guardian Health

Note: All sources are international/English feeds.

Configuration

NVS Settings (news namespace):

cache_duration (default: 15 min)
max_cache_size (default: 50 articles)  
enable_cache (default: true)

Smart cache:

  • Key based on search parameters
  • Configurable TTL
  • Automatic cleanup
  • Thread-safe (mutex)

Configuration is handled programmatically, NOT via MCP tools:

// Configure via code only
g_news_manager->SetCacheDuration(30);     // minutes
g_news_manager->SetMaxCacheSize(100);     // articles  
g_news_manager->EnableCache(true);        // boolean

System Integration

Initialization

// In mcp_server.cc
void AddNewsMcpTools(); // Registers the 3 tools

// Automatic instantiation
static std::unique_ptr<NewsManager> g_news_manager;

Standard MCP Pattern

  • Tool names: self.news.*
  • Structured JSON response
  • Automatic language detection via Lang::CODE

Dependencies

#include "mcp_news_tools.h"
// Requires: cJSON, http, settings, board

Source Files

main/mcp_news_tools.h # Interfaces and structures
main/mcp_news_tools.cc # NewsManager + MCP tools
main/news_providers.cc # NewsProvider RSS

Add RSS news integration with 3 MCP tools:
- search_news: Search articles by keywords
- get_headlines: Get latest headlines from multiple news sources
- get_trending_news: Get trending articles

Features:
- RSS-based implementation (no API keys required)
- Multi-source news aggregation
- Automatic retry mechanisms for failed requests
- Support for international news sources
@Vasco0x4
Copy link
Author

If you have questions about my modification, please let's me know, I can also adapt my code

@78
Copy link
Owner

78 commented Jul 17, 2025

This is a great use case for MCP, as it's a productized feature. However, we want to keep the core functionalities of the open-source framework simple and easy for newcomers to get started quickly. Therefore, this pull request should not merge the "news" MCP into common tools. We can, however, consider it in the future if multiple development boards end up using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants