Token导航 LogoToken导航TokenDH.com
Nyt MCP Server logo
运维云端stdio官方级别未说明来源级核验

Nyt MCP Server

MCP Server

NYT MCP服务器是一个统一的消息集中协议服务器,提供对纽约时报多个API的简化访问接口,适用于新闻聚合、数据分析和应用集成场景。

工具数

6

提示词数

0

GitHub Stars

0

资源数

0
API网关新闻聚合Python

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

aovabo

提供方

aovabo

最后核验

2026/5/17 20:43

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python -m venv venv

详细介绍

新 MCP 服务器

一种消息集中器协议(MCP)服务器,为《纽约时报》API提供统一、简单的接口。此服务器通过单个端点简化了与多个NYT API的交互。

概述

此MCP服务器充当各种《纽约时报》API的统一网关,包括:

  • 文章检索
  • 头条
  • Times Wire(实时新闻)
  • 最受欢迎
  • 档案
  • 书籍API

特性

  • 单一端点:通过一个一致的接口访问所有NYT API
  • 干净的响应:格式化和简化的API响应
  • 实时更新:通过Times Wire实时新闻推送
  • 灵活搜索:全面的文章搜索功能
  • 错误处理:强大的错误管理
  • 健康监测:内置健康检查端点
  • 易于集成:易于与任何应用程序集成

需求

  • Python 3.8+
  • 纽约时报API密钥(在 NYT 开发 门户)
  • 必需的Python包(见requirements.txt)

快速开始

  1. 克隆存储库:
git clone https://github.com/your-username/nyt-mcp-server.git
cd nyt-mcp-server
  1. 创建并激活虚拟环境:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. 安装依赖项:
pip install -r requirements.txt
  1. 创建 .env 文件:
NYT_API_KEY=your_api_key_here
MCP_PORT=8000
MCP_HOST=0.0.0.0
  1. 运行服务器:
python src/server.py

项目结构

nyt-mcp-server/
├── src/
│   ├── __init__.py
│   ├── server.py
│   └── config.py
├── .env
├── .gitignore
├── requirements.txt
└── README.md

API文档

基本URL

http://localhost:8000

端点

POST/mcp/消息

所有NYT API交互的主要终点。

GET/健康

健康检查端点。

示例用法

import httpx
import asyncio

async def get_news():
    async with httpx.AsyncClient() as client:
        response = await client.post(
            "http://localhost:8000/mcp/message",
            json={
                "message_type": "times_wire",
                "content": {"limit": 5},
                "timestamp": "2025-03-05T21:00:00Z"
            }
        )
        return response.json()

# Run the async function
asyncio.run(get_news())

消息类型

1.文章搜索

{
    "message_type": "article_search",
    "content": {
        "query": "technology",
        "sort": "newest",
        "page": 0
    },
    "timestamp": "2025-03-05T21:00:00Z"
}

2.热门故事

{
    "message_type": "top_stories",
    "content": {
        "section": "technology"
    },
    "timestamp": "2025-03-05T21:00:00Z"
}

3.Times Wire

{
    "message_type": "times_wire",
    "content": {
        "limit": 5,
        "source": "nyt"
    },
    "timestamp": "2025-03-05T21:00:00Z"
}

4.最受欢迎

{
    "message_type": "most_popular",
    "content": {
        "type": "viewed",
        "time_period": "7"
    },
    "timestamp": "2025-03-05T21:00:00Z"
}

5.档案

{
    "message_type": "archive",
    "content": {
        "year": 2025,
        "month": 3
    },
    "timestamp": "2025-03-05T21:00:00Z"
}

6.书籍

{
    "message_type": "books",
    "content": {
        "list": "hardcover-fiction"
    },
    "timestamp": "2025-03-05T21:00:00Z"
}

贡献

  1. 分叉存储库
  2. 创建功能分支(git checkout -b feature/AmazingFeature)
  3. 提交您的更改(git commit -m 'Add some AmazingFeature')
  4. 推到分支(git push origin feature/AmazingFeature)
  5. 打开拉取请求

许可证

MIT许可证

安全说明

  • 永远不要承诺你的 .env 文件
  • 将您的《纽约时报》API密钥保密
  • 对敏感数据使用环境变量

联系

为错误报告或功能请求创建问题。

目录标签

目录标签

API网关新闻聚合Python本地部署数据整合实时新闻简化接口

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

6

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP