基于 FastMCP 的 RSS 新闻聚合和处理代理,可以发现、获取和汇总来自各种 RSS 提要的内容。
特征
- 发现任何网站的 RSS 源
- 从 RSS 源获取条目
- 从 feed 条目中提取并格式化内容
- 从任何 URL 提取并处理 Web 内容
- 按关键字搜索新闻文章
- 生成新闻文章摘要
- 按类别和国家获取热门新闻
安装
- 克隆存储库
- 安装所需的依赖项:
pip install -r requirements.txt
- 如果需要环境变量,请创建一个
.env
文件(可选)
用法
启动 MCP 服务器
这将启动 MCP 服务器,提供各种 RSS 相关工具。
可用工具
- get_rss_feed_entries :从 RSS feed URL 获取条目
- discover_rss_feeds :查找网站上可用的 RSS 提要
- download_feed_content :下载并处理 feed 条目的内容
- fetch_webpage :使用高级技术从任何网页 URL 中提取主要内容(新)
- search_news_by_keyword :使用关键字在多个 feed 中搜索新闻文章
- create_news_summary :创建新闻文章摘要
- get_top_news_from_category :获取特定类别和国家的热门新闻
示例
response = mcp.invoke("discover_rss_feeds", {"website_url": "https://www.theguardian.com"})
print(f"Found {response['feeds_count']} feeds")
for feed in response['feeds']:
print(f"- {feed['title']}: {feed['url']}")
通过关键字获取新闻文章
response = mcp.invoke("search_news_by_keyword", {
"keyword": "climate change",
"max_results": 5
})
for article in response['results']:
print(f"- {article['title']} ({article['source']})")
print(f" Link: {article['link']}")
print()
从任何网页提取内容
response = mcp.invoke("fetch_webpage", {
"url": "https://example.com/article",
"output_format": "markdown",
"include_images": True
})
print(f"Title: {response['title']}")
print(f"Extraction method: {response['extracted_by']}")
print(f"Content preview: {response['content'][:200]}...")
获取某个类别的热门新闻
response = mcp.invoke("get_top_news_from_category", {
"category": "technology",
"country": "us",
"max_results": 3
})
for article in response['results']:
print(f"- {article['title']} ({article['source']})")
客户端示例
该项目包括一个命令行客户端( client_example.py
),可以轻松访问所有 MCP 服务器工具:
# Get feed entries
python client_example.py feed https://www.theguardian.com/international/rss
# Search news by keyword
python client_example.py search "artificial intelligence"
# Extract content from a webpage with advanced extraction
python client_example.py webpage https://example.com/article --format markdown --images --save
# Get news by category
python client_example.py category technology --country us
贡献
欢迎贡献代码!欢迎提交 Pull 请求。
执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。