Skip to main content
Glama
moltrus

Google News MCP

by moltrus

Google News MCP

一个 模型上下文协议 (MCP) 服务器,将 Google News RSS 源 作为 MCP 工具公开,允许 AI 助手(Claude、GPT-4 等)通过自动 URL 解码、并发处理和智能缓存访问实时新闻数据。

主要功能

异步与并发 - 所有操作均异步运行,并进行并发 URL 解码,以实现最高性能 智能缓存 - 具有 LRU 缓存(1024 条目),可快速重复进行 URL 解码 批量 URL 解码 - 并行解码多个 Google News URL 简洁摘要 - 从 HTML 摘要中提取纯文本,并附带已解码的文章链接 面向标记的对象表示法 (TOON) - 支持紧凑、节省标记的响应格式(减少 30-60%) 多语言支持 - 可配置任何语言/国家组合 高级搜索 - 完全支持 Google News 搜索运算符(site:、when:、intitle: 等) 页面提取 - 使用 Jina ReaderGroq 获取并总结全文内容


工具概览

工具

用途

参数

get_top_headlines

按国家/地区获取最新头条

language, country

get_category_feed

按类别获取新闻 (TECH, BUSINESS 等)

category, language, country

get_search_feed

使用高级运算符搜索新闻

query, language, country

get_geo_feed

特定地点的新闻

location, language, country

get_topic_feed

按 ID 获取热门话题

topic_id, language, country

decode_google_news_url

解码 Google News URL

urls (列表)

list_categories

可用的新闻类别

(无)

fetch_content

获取并总结页面内容

url, summarize

总计:8 个工具


快速入门

安装

选项 1:使用 uv (推荐)

# Clone the repository
git clone https://github.com/moltrus/google-news-mcp.git
cd google-news-mcp

# Install with uv
uv sync

选项 2:使用 pip 和虚拟环境

# Clone the repository
git clone https://github.com/moltrus/google-news-mcp.git
cd google-news-mcp

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install in development mode
pip install -e .

全局使用(任何方法)

要在任何地方全局使用 google-news-mcp 命令:

pip install -e .

这将把命令行入口点安装到系统范围内,允许您从任何目录运行 google-news-mcp

配置

根据 .env.example 创建一个 .env 文件:

# RSS Preferences
GOOGLE_NEWS_LANGUAGE=en
GOOGLE_NEWS_COUNTRY=US

# Response Optimization
# Options: "json" (standard) or "toon" (token-optimized)
RESPONSE_FORMAT=json

# Fetching & Summarization
JINA_API_KEY=your_jina_key
GROQ_API_KEY=your_groq_key
GROQ_MODEL=qwen/qwen3-32b

运行服务器

google-news-mcp

或直接运行:

python -m google_news_mcp.server

工具文档

get_top_headlines

获取某个国家的最新头条新闻。

参数:

  • language (字符串,可选):语言代码(例如 'en', 'fr', 'es')。默认为 GOOGLE_NEWS_LANGUAGE 环境变量。

  • country (字符串,可选):国家代码(例如 'US', 'GB', 'JP')。默认为 GOOGLE_NEWS_COUNTRY 环境变量。

返回:

{
  "title": "Google News",
  "link": "https://news.google.com",
  "description": "Latest news",
  "entries": [
    {
      "title": "Article Title",
      "link": "https://source.com/article",
      "published": "2026-03-31T10:00:00Z",
      "summary": "Article Title (https://source.com/article)\nAnother Article (https://another.com/news)",
      "source": "Source Name"
    }
  ]
}

注意:

  • 文章按相关性排序(Google News 默认)

  • URL 会自动从 Google News 重定向中解码

  • 摘要包含纯文本格式的提取链接


get_category_feed

获取特定类别的新闻头条。

参数:

  • category (字符串,必需):新闻类别。有效值:

    • WORLD - 国际新闻

    • NATION - 国内/本地头条

    • BUSINESS - 商业与金融

    • TECHNOLOGY - 科技与 AI

    • ENTERTAINMENT - 娱乐与流行文化

    • SPORTS - 体育

    • SCIENCE - 科学与研究

    • HEALTH - 健康与医学

  • language (字符串,可选):语言代码。默认为配置值。

  • country (字符串,可选):国家代码。默认为配置值。

返回:get_top_headlines

示例:

get_category_feed(category="TECHNOLOGY")
get_category_feed(category="BUSINESS", country="UK")

get_search_feed

使用关键字查询和高级运算符搜索 Google News。

参数:

  • query (字符串,必需):带有可选运算符的搜索查询

  • language (字符串,可选):语言代码。默认为配置值。

  • country (字符串,可选):国家代码。默认为配置值。

支持的搜索运算符:

  • 精确短语: "Artificial Intelligence"(必须完全匹配)

  • 排除项: -apple(排除包含 "apple" 的文章)

  • 特定站点: site:techcrunch.com(仅来自该域名)

  • 时间范围(相对): when:1h, when:24h, when:7d, when:30d, when:1y, when:1m

  • 时间范围(绝对): after:2026-01-01, before:2026-03-31

  • 标题搜索: intitle:merger(术语仅出现在标题中)

  • 布尔 OR: Tesla OR SpaceX(任一术语)

  • 组合: "GPT-4" site:openai.com when:7d(组合使用)

返回:get_top_headlines(最多约 100 篇文章)

查询示例:

"OpenAI Sora"                                # Exact phrase
AI -hype                                     # Include AI, exclude hype
site:arxiv.org quantum computing             # From academic site
when:1h breaking                             # Last hour
when:24h -rumor Bitcoin                      # Last 24h, exclude rumors
after:2026-03-01 before:2026-03-31 merger    # Date range
intitle:IPO tech companies                   # IPO in headline
SpaceX OR Blue Origin                        # Either company OR other

重要: 日期过滤器按 计算(非小时/分钟精度)。


get_geo_feed

获取特定地理位置的新闻。

参数:

  • location (字符串,必需):城市、州、地区或国家(例如 'San Francisco', 'California', 'Japan'

  • language (字符串,可选):语言代码。默认为配置值。

  • country (字符串,可选):国家代码。默认为配置值。

返回:get_top_headlines

示例:

get_geo_feed(location="New York")
get_geo_feed(location="London", language="en")
get_geo_feed(location="Tokyo", country="JP")

fetch_content

使用 Jina Reader API 从 URL 获取干净的页面内容,并可通过 Groq 进行可选的总结。

参数:

  • url (字符串,必需):要获取的绝对 URL(必须以 http:// 或 https:// 开头)

  • summarize (布尔值,可选):如果为 true,则通过 Groq 返回简洁摘要,并省略完整的原始内容以节省标记。默认为 false

返回:

{
  "url": "https://example.com/article",
  "reader_url": "https://r.jina.ai/https://example.com/article",
  "content": "Full article text...",
  "summary": "Concise summary points...",
  "summary_model": "qwen/qwen3-32b",
  "summary_error": "Error message if summarization fails"
}

注意:

  • 标记效率:summarizetrue 时,响应中会自动删除 content 字段,以防止上下文窗口过大。

  • 环境变量:

    • JINA_API_KEY:内容提取必需。

    • GROQ_API_KEY:总结必需。

    • GROQ_MODEL:可选。要使用的特定模型(默认为 qwen/qwen3-32b)。


decode_google_news_url

并行解码多个 Google News URL 到其实际文章目标地址。

参数:

  • urls (字符串列表,必需):要解码的 Google News 重定向 URL 数组

返回:

{
  "decoded_urls": [
    {
      "original_url": "https://news.google.com/articles/CBMi8wFAUU...",
      "decoded_url": "https://techcrunch.com/2026/03/31/ai-news"
    },
    {
      "original_url": "https://news.google.com/articles/CBMixAFAUU...",
      "decoded_url": "https://theverge.com/2026/3/31/10987654"
    }
  ]
}

性能:

  • 所有 URL 并发解码(无顺序延迟)

  • 结果缓存以供重复查找(缓存命中时即时返回)

  • 具有 1024 条目限制的 LRU 缓存

示例:

decode_google_news_url(urls=[
  "https://news.google.com/articles/CBMi8wFAUU...",
  "https://news.google.com/articles/CBMixAFAUU...",
  "https://news.google.com/articles/CBMi5gFAUU..."
])

get_topic_feed

按主题 ID 获取特定热门话题的新闻。

Google News 将热门话题跟踪为哈希值(例如公司、事件、重复出现的主题)。

参数:

  • topic_id (字符串,必需):Google News 主题哈希标识符

  • language (字符串,可选):语言代码。默认为配置值。

  • country (字符串,可选):国家代码。默认为配置值。

返回:get_top_headlines

常见主题 ID:

  • CAAqKAgKIiJDQkFTRXdvS0wyMHZNSFp3YWpSZlloSUZaVzR0UjBJb0FBUAE - 加密货币

  • 通过浏览 Google News 并检查 URL 中的主题参数来查找更多信息

示例:

get_topic_feed(topic_id="CAAqKAgKIiJDQkFTRXdvS0wyMHZNSFp3YWpSZlloSUZaVzR0UjBJb0FBUAE")

list_categories

获取可用新闻类别的列表。

参数:

返回:

{
  "categories": [
    "WORLD",
    "NATION",
    "BUSINESS",
    "TECHNOLOGY",
    "ENTERTAINMENT",
    "SPORTS",
    "SCIENCE",
    "HEALTH"
  ]
}

架构

性能优化

  1. Async/Await - 所有 I/O 操作(HTTP、解码)均为非阻塞

  2. 并发处理 - 通过 asyncio.gather() 并行处理多个 URL 和条目

  3. LRU 缓存 (1024 条目) - 在函数级别缓存已解码的 URL

  4. 内存字典缓存 - 为已解码 URL 提供额外的快速查找缓存

  5. 批量操作 - decode_google_news_url 并发处理 URL 列表

摘要格式

文章摘要从 HTML 中提取,并以 纯文本 形式返回,附带已解码的链接:

Article Title 1 (https://original-source.com/article1)
Image caption link (https://image-source.com/photo)
Article Title 2 (https://original-source.com/article2)

HTML 标签、CDATA 包装器和实体被剥离,以获得干净、可读的文本。


使用示例

1. 获取过去一小时的突发新闻

get_search_feed(query="when:1h breaking", country="US")

2. 一次解码多个文章 URL

decode_google_news_url(urls=[
  "https://news.google.com/articles/CBMi8wFAUU...",
  "https://news.google.com/articles/CBMixAFAUU..."
])

3. 来自特定来源的科技新闻

get_search_feed(query="site:techcrunch.com AI")

4. 城市本地新闻

get_geo_feed(location="San Francisco")

5. 按日期范围搜索

get_search_feed(query="SpaceX after:2026-03-01 before:2026-03-31")

6. 获取健康新闻

get_category_feed(category="HEALTH")

7. 热门加密货币新闻

get_topic_feed(topic_id="CAAqJggKIiBDQkFTRWdvSUwyMHZNR3d5YldFeVpYVXVhVzV6U0FpQkFQAQ")

8. 获取并总结全文文章

fetch_content(url="https://techcrunch.com/article-url", summarize=true)

标记效率与 TOON

此服务器支持 面向标记的对象表示法 (TOON),这是一种专为 LLM 设计的紧凑数据格式。

为什么要使用 TOON?

由于重复的键和标点符号,标准 JSON 对 LLM 来说可能过于冗长。TOON 通过以下方式减少了 30-60% 的标记使用量:

  • 为对象数组定义一次键(表格格式)。

  • 删除不必要的大括号、方括号和引号。

  • 使用缩进和简单的分隔符。

配置

要在全局范围内为所有工具响应启用 TOON,请在您的 .env 中设置以下内容:

RESPONSE_FORMAT=toon

对比

JSON (冗长)

TOON (紧凑)

{"entries": [{"id": 1, "title": "A"}, {"id": 2, "title": "B"}]}

entries[2,]{id,title}:

  1,A

  2,B


限制

  1. 结果限制: Google News RSS 每次请求最多返回约 100 篇文章

  2. 排序: 默认为相关性。使用 when: 过滤器进行时间排序

  3. 日期精度: 过滤器按 计算,而非小时/分钟

  4. 速率限制: RSS 不需要 API 密钥,但 Jina Reader 和 Groq 有其自身的限制/配额

  5. 内容提取: fetch_content 取决于 Jina Reader 解析目标站点的能力

  6. 主题 ID: 必须从 Google News URL 中发现;没有查找 API


许可证

MIT

Install Server
F
license - not found
A
quality
-
maintenance - not tested

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/moltrus/google-news-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server