Skip to main content

Add your description here

Project description

MCP NewNow Server

MCP Compatible

一个基于 Model Context Protocol (MCP) 的新闻聚合服务器,通过 NewNow API 提供多平台热点新闻和趋势话题。

功能特点

  • 多平台热点聚合:一站式获取来自酷安、知乎、微博、B站、抖音、GitHub等14+平台的热点内容
  • 中英文源名识别:支持中英文新闻源名称,并提供模糊匹配功能
  • 并发请求优化:使用异步并发技术,高效获取多源新闻
  • 自定义API端点:通过环境变量或命令行参数配置NewNow API端点
  • 智能错误处理:全面的错误报告和优雅降级机制
  • LLM友好输出:专为大型语言模型设计的输出格式

安装方法

方法一:直接使用

克隆代码库并安装依赖:

git clone https://github.com/yourusername/mcp_newsnow_server.git
cd mcp_newsnow_server
uv pip install -r requirements.txt

方法二:配置 Claude Desktop

在 Claude Desktop 配置文件中添加服务器配置:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json

添加以下配置:

{
  "mcpServers": {
    "get_news": {
      "name": "get_newsnow",
      "command": "uv",
      "args": [
        "--directory",
        "path/to/your/mcp_newsnow",
        "run",
        "server.py"
      ]
    }
  }
}

使用方法

使用 Claude Desktop

  1. 安装并配置 Claude Desktop
  2. 在配置文件中添加上述 MCP 服务器配置
  3. 重启 Claude Desktop
  4. 在对话中使用新闻相关工具

使用 MCP CLI 进行开发

# 通过环境变量设置API端点
NEWS_API_URL=https://newsnow.example.com mcp dev server.py

# 运行测试
mcp test server.py

可用工具

1. 获取单一源新闻 (get_newsnow)

async def get_newsnow(source: str) -> dict[str, Any] | None

从指定源获取最新新闻。

参数:

  • source: 新闻源名称 (支持中英文,例如"知乎"、"zhihu"、"B站"等)

返回: 包含新闻数据的字典

2. 获取多源新闻 (get_multi_news)

async def get_multi_news(sources: list[str] = None) -> dict[str, Any]

从多个源获取最新新闻 (最多5个)。

参数:

  • sources: 新闻源名称列表

返回: 包含多个新闻源数据的字典

3. 获取所有源新闻 (get_all_news)

async def get_all_news() -> dict[str, Any]

获取所有配置的新闻源数据。

返回: 包含所有新闻源数据和元数据的字典

4. 列出可用新闻源 (list_sources)

async def list_sources() -> dict[str, str]

列出所有可用的新闻源及其中文名称。

返回: 新闻源ID到中文名称的映射字典

环境变量

支持的新闻源

  • 酷安 (coolapk)
  • B站热搜 (bilibili-hot-search)
  • 知乎 (zhihu)
  • 微博 (weibo)
  • 今日头条 (toutiao)
  • 抖音 (douyin)
  • GitHub趋势 (github-trending-today)
  • Linux热榜 (linuxdo-hot)
  • 贴吧 (tieba)
  • 华尔街见闻 (wallstreetcn)
  • 澎湃新闻 (thepaper)
  • 财联社 (cls-hot)
  • 雪球 (xueqiu)
  • 快手 (kuaishou)

贡献指南

欢迎提交问题和拉取请求!以下是一些潜在的改进方向:

  • 添加更多新闻源支持
  • 增强内容提取和处理能力
  • 添加缓存层减少API调用
  • 改进错误处理和重试机制
  • 添加结果过滤和分类功能

许可证

本项目采用 MIT 许可证。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_newsnow-0.1.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_newsnow-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file mcp_newsnow-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_newsnow-0.1.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for mcp_newsnow-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5d3c449e4272b5477a8f1557afc2b82f3b7d4aa5f1abcb30f616bb5b70ad44df
MD5 7aed5c8e53872bcdc78bc78a0c9ec607
BLAKE2b-256 71a541c83653b638cd380d9b9e0cddc669141ca2ad6a45844e1435de33461364

See more details on using hashes here.

File details

Details for the file mcp_newsnow-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_newsnow-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for mcp_newsnow-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71fd8e5ec458475de62d2ec472f2194ee2deb21f5f1b8cd9038a3be1f19603f7
MD5 81ab12bf354315d1ba78f3511bf58bdc
BLAKE2b-256 2087427ac04f72a102c8877e405269cff3fc7a49a1cebb8da76c5dcf3acf1f17

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page