新闻-mcp MCP 服务器
mcp新闻服务器
成分
资源
服务器通过资源 URI 公开存储在数据库中的新闻文章:
news://{category}/{limit}
:检索给定类别的最新文章列表。{category}
:按类别过滤文章(例如,tech
、data_science
、news
)。完整列表请参阅工具说明。{limit}
(可选,默认为 10):指定要返回的最大文章数量。
- 每篇返回的文章都包含标题、链接、发布日期和来源。
提示
服务器目前未公开任何提示。(摘要逻辑存在于内部,但无法通过 MCP 提示使用)。
工具
服务器实现了一个工具:
summarize_news
:从数据库中检索原始新闻文章,允许客户端(LLM)对其进行总结。- 采用可选的
category
(字符串)和limit
(整数,默认 20)参数。 - 返回文章字典列表,每个字典包含
id
、title
、link
、published
、source
和content
。 - 可用类别:
tech
、data_science
、llm_tools
、cybersecurity
、linux
、audio_dsp
、startups
、news
、science
、research
、policy
。
- 采用可选的
配置
该服务器依赖于通过DATABASE_URL
环境变量配置的 PostgreSQL 数据库(默认为postgresql://localhost/mcp_news
)。
news_gatherer.py
脚本(旨在单独运行/安排)从各种 RSS 提要填充数据库。
摘要逻辑(内部,不通过 MCP 公开)使用 OpenAI API,通过OPENAI_API_KEY
环境变量进行配置。
其他配置(通过环境变量或默认值):
LOOKBACK_HOURS
:news_gatherer.py
回溯多久以前查找新文章(默认值:6)。SUMMARY_WORD_TARGET
:内部摘要的目标字数(默认值:500)。MAX_ARTICLES_PER_SUMMARY
:一批摘要中包含的最大文章数(默认值:25)。KEYWORD_FILTER
:内部摘要逻辑使用的关键字。
快速入门
安装
克劳德桌面
在 MacOS 上: ~/Library/Application\ Support/Claude/claude_desktop_config.json
在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json
发展
构建和发布
准备分发包:
- 同步依赖项并更新锁文件:
- 构建软件包分发版:
这将在dist/
目录中创建源和轮子分布。
- 发布到 PyPI:
注意:您需要通过环境变量或命令标志设置 PyPI 凭据:
- 令牌:
--token
或UV_PUBLISH_TOKEN
- 或用户名/密码:
--username
/UV_PUBLISH_USERNAME
和--password
/UV_PUBLISH_PASSWORD
调试
由于 MCP 服务器通过 stdio 运行,调试起来可能比较困难。为了获得最佳调试体验,我们强烈建议使用MCP Inspector 。
您可以使用以下命令通过npm
启动 MCP Inspector:
启动后,检查器将显示一个 URL,您可以在浏览器中访问该 URL 以开始调试。
Related MCP Servers
- AsecurityAlicenseAqualityThis server enables users to perform Google News searches with automatic categorization and multi-language support via SerpAPI integration.Last updated -155972JavaScriptMIT License
- AsecurityAlicenseAqualityProvides tools to fetch and search news from The Verge's RSS feed, allowing users to get today's news, retrieve random articles from the past week, and search for specific keywords in recent Verge content.Last updated -352TypeScriptMIT License
Juhe News MCP Serverofficial
AsecurityFlicenseAqualityA Model Context Protocol server that enables large language models to access the latest trending news headlines and detailed content across various categories including recommended, domestic, technology, and sports news.Last updated -2Python- -securityFlicense-qualityA modular, scalable news aggregation backend that provides a unified interface to TheNewsAPI for retrieving current and historical news articles with advanced filtering capabilities, designed specifically for consumption by AI agents.Last updated -4