RSS聚合服务

一个基于TypeScript的RSS聚合服务,提供REST API和多种MCP传输选项,支持AI助手集成,简化部署和使用。

  • by GTuritto
  • JavaScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 GTuritto/RSS-MCPserver

使用说明

RSS MCP服务器

🌐 可用语言/习语


一个全面的基于类型脚本的RSS聚合服务,在统一的服务器架构中提供REST API和多个模型上下文协议(MCP)传输选项。它通过完整的AI助手集成功能获取、解析和提供RSS提要,所有这些功能都在一个端口上运行,以简化部署和使用。

🚀 快速开始

统一服务器(推荐)

一切都在继续 一个端口 为了最大限度地简化:

# Start the unified server (REST API + MCP HTTP + MCP SSE)
docker-compose up -d

# All services available on port 3000:
# 🌐 REST API:        http://localhost:3000/
# 📚 API Docs:        http://localhost:3000/api-docs  
# 🔌 MCP HTTP:        http://localhost:3000/mcp
# 📡 MCP SSE:         http://localhost:3000/sse
# 💬 SSE Messages:    http://localhost:3000/messages

# Test REST API
curl -X POST http://localhost:3000/Fetch_RSSfeed \
  -H "Content-Type: application/json" \
  -d '{"urls": ["https://feeds.bbci.co.uk/news/rss.xml", "https://rss.cnn.com/rss/edition.rss"]}'

# Test MCP HTTP with Inspector
npx @modelcontextprotocol/inspector
# Connect to: http://localhost:3000/mcp

个人交通选项(高级)

对于特殊用例,您仍然可以运行单独的传输:

# Stdio transport - for CLI/subprocess integration
npm run mcp

# HTTP transport only - for web clients  
npm run mcp:http:dev

# SSE transport only - for legacy streaming clients
npm run mcp:sse:dev

🏗️ 统一架构

统一服务器将所有协议组合在一个Express.js应用程序中:

协议 端点 目的 状态
REST API /, /health, /api-docs, /Fetch_RSSfeed 传统HTTP API,Swagger文档 ✅ 活动
MCP HTTP /mcp 现代MCP客户端,网络集成 ✅ 活动
MCP SSE /sse, /messages 实时流媒体、传统SSE客户端 ✅ 活动

统一架构的好处

  • ✅ 单端口:仅需管理和公开端口3000
  • ✅ 简化部署:一个集装箱,一项服务
  • ✅ 统一监控:所有协议的单一健康终点
  • ✅ 更好地利用资源:共享内存和进程管理
  • ✅ 更容易开发:启动、停止和调试一台服务器
  • ✅ 协议无关:每个运输工具都保持完整的功能

统一传输端点:

  • REST API: http://localhost:3000/ (健康、RSS端点)
  • HTTP传输: http://localhost:3000/mcp (基于HTTP的MCP)
  • 苏格兰和南方能源公司运输: http://localhost:3000/sse (连接)+ http://localhost:3000/messages (消息)

特性

  • ✅ TypeScript:完全类型安全和现代JavaScript功能
  • ✅ Express.js:快速、无异议的web框架
  • ✅ RSS聚合:获取并解析多个RSS源
  • ✅ 多个MCP传输:Stdio、HTTP(流式HTTP)、SSE和多传输
  • ✅ 健康监测:对所有交通工具进行基本和全面的健康检查
  • ✅ 输入验证:包含详细错误的全面请求验证
  • ✅ OpenAPI 3.0:完整的API规范和文件
  • ✅ Swagger用户界面:交互式API文档和测试
  • ✅ MCP检查器兼容:与基于网络的MCP测试工具配合使用
  • ✅ 会话管理:基于HTTP的传输的高级会话处理
  • ✅ CORS支持:Web客户端兼容性
  • ✅ Jest测试:全面的单元和集成测试(65次测试,90%以上的覆盖率)
  • ✅ Docker支持:生产就绪的集装箱化
  • ✅ 安全:非根容器,输入消毒
  • ✅ 人工智能集成:用于AI助手的MCP工具、资源和提示

🔗 集成选项

REST API接口

用于与应用程序直接进行HTTP集成的传统REST API。

MCP服务器接口(多路传输)

具有灵活传输选项的模型上下文协议服务器:

  • 工作室:用于命令行工具和子流程通信
  • 流式HTTP:现代基于HTTP的传输,完全支持MCP
  • 上海证券交易所:用于实时流媒体的服务器发送事件(已弃用但受支持)
  • 多运输:在单个服务器上组合HTTP和SSE支持

📊 API端点(REST)

端点 方法 描述
/ GET 基本健康检查
/health GET 全面健康监测
/Fetch_RSSfeed POST 聚合多个RSS源
/docs 获取 API文档(重定向)
/api-docs GET 交互式Swagger用户界面
/api-docs.json GET OpenAPI 3.0规范

🔗 MCP传输端点

传输 端点 方法 目的
工作室 N/A stdin/stdout 子进程集成
超文本传输协议 http://localhost:3000/mcp POST Web客户端,MCP检查器
上海证券交易所 http://localhost:3000/sse EventSource SSE连接端点
上海证券交易所 http://localhost:3000/messages POST SSE消息端点

🤖 MCP能力(AI助手)

类型 名称 描述
工具 fetch_rss_feeds 获取并聚合多个RSS源
get_feed_info 获取特定RSS源的信息
资源 rss-feed 访问单个RSS源数据
available-feeds 热门RSS源列表
提示 analyze_rss_content 分析RSS内容以获取见解
news_briefing 从RSS源生成新闻简报

📖 文档

API文档

MCP运输文件

额外资源

安装

地方发展

  1. 克隆仓库

  2. 安装依赖项:

    npm install
    

Docker安装

先决条件:您的系统上安装了Docker和Docker Compose。

Docker Compose快速入门(推荐)

# Production deployment
docker-compose up -d

# Development with hot reload
npm run compose:dev

手动Docker命令

# Build the Docker image
npm run docker:build

# Run the container
npm run docker:run

# Stop the container
npm run docker:stop

🔧 MCP配置

运输选择指南

选择最适合您用例的运输方式:

  • 工作室 (npm run mcp):最适合Claude Desktop和CLI集成
  • 超文本传输协议 (统一服务器):最适合web应用程序和MCP Inspector
  • 上海证券交易所 (统一服务器):适用于需要实时流媒体的传统SSE客户端
  • 统一 (npm run unified 或Docker):所有传输都在单个端口3000上(推荐)

客户端配置示例

克劳德桌面(标准传输)

{
  "mcpServers": {
    "rss-server": {
      "command": "node",
      "args": ["dist/mcp-server.js"],
      "env": {
        "NODE_ENV": "production"
      }
    }
  }
}

MCP检查器(HTTP传输)

{
  "name": "RSS MCP Server (HTTP)",
  "transport": "http",
  "endpoint": "http://localhost:3000/mcp"
}

自定义SSE客户端

// SSE connection
const eventSource = new EventSource('http://localhost:3000/sse');

// Send messages
fetch('http://localhost:3000/messages', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ jsonrpc: '2.0', method: 'ping' })
});

用法

地方发展模式

使用TypeScript编译在开发模式下运行服务器:

npm run dev

生产模式

  1. 构建TypeScript代码:

    npm run build
    
  2. 启动服务器:

    npm start
    

MCP服务器模式

启动MCP服务器以集成AI助手(选择您的传输方式):

# Build all MCP transport variants
npm run build

# Stdio transport (original) - for CLI/subprocess integration
npm run mcp              # Production (shortcut for mcp:stdio)
npm run mcp:stdio:dev    # Development mode

# HTTP transport (recommended) - for web clients & MCP Inspector
npm run mcp:http         # Production
npm run mcp:http:dev     # Development mode

# SSE transport - for legacy real-time streaming clients
npm run mcp:sse          # Production
npm run mcp:sse:dev      # Development mode

# Multi-transport - supports both HTTP and SSE
npm run mcp:multi        # Production
npm run mcp:multi:dev    # Development mode

Docker使用

生产部署

# Start with Docker Compose
docker-compose up -d

# Check logs
npm run compose:logs

# Stop services
npm run compose:down

Docker开发

# Start development container with hot reload
npm run compose:dev

# View logs
docker-compose logs -f rss-mcp-server-dev

Docker容器管理

# Build image
npm run docker:build

# Run container
npm run docker:run

# Stop and cleanup
npm run docker:stop
npm run docker:remove

服务器将在端口3000(或 PORT 环境变量)。

API终点

健康检查

  • 统一资源定位符: GET /

  • 描述:基本服务器状态检查

  • 回应:

    {
      "message": "RSS MCP Server is running",
      "status": "OK",
      "timestamp": "2025-09-21T11:57:05.000Z"
    }
    

增强健康检查

  • 统一资源定位符: GET /health

  • 描述:全面的健康和系统信息

  • 回应:

    {
      "status": "healthy",
      "message": "RSS MCP Server is running successfully",
      "timestamp": "2025-09-21T11:57:05.000Z",
      "uptime": {
        "seconds": 3661,
        "formatted": "0d 1h 1m 1s"
      },
      "memory": {
        "usage": {
          "rss": 45.2,
          "heapTotal": 20.1,
          "heapUsed": 15.3,
          "external": 2.1
        },
        "unit": "MB"
      },
      "system": {
        "nodeVersion": "v18.17.0",
        "platform": "darwin",
        "architecture": "x64",
        "pid": 12345
      },
      "performance": {
        "responseTime": 1.23,
        "unit": "ms"
      },
      "endpoints": {
        "available": [
          "GET /",
          "GET /health", 
          "POST /Fetch_RSSfeed"
        ]
      }
    }
    

获取RSS源

  • 统一资源定位符: POST /Fetch_RSSfeed

  • 描述:聚合多个RSS提要并返回解析后的文章

  • 请求体:

    {
      "urls": [
        "https://feeds.bbci.co.uk/news/rss.xml",
        "https://rss.cnn.com/rss/edition.rss"
      ]
    }
    
  • 成功响应 (200):

    {
      "success": true,
      "totalFeeds": 2,
      "totalArticles": 45,
      "feeds": [
        {
          "url": "https://feeds.bbci.co.uk/news/rss.xml",
          "title": "BBC News",
          "description": "BBC News - Home",
          "articles": [
            {
              "title": "Article Title",
              "description": "Article description",
              "link": "https://www.bbc.com/news/article",
              "pubDate": "2025-01-21T10:00:00.000Z",
              "author": "BBC News"
            }
          ]
        }
      ]
    }
    
  • 错误响应:

    • 400错误请求:请求格式或URL无效
    • 500内部服务器错误:服务器错误

MCP集成

使用AI客户端进行设置

  1. Claude桌面配置:

    添加到您的Claude Desktop配置中:

    {
      "mcpServers": {
        "rss-aggregator": {
          "command": "node",
          "args": ["/path/to/RSS-MCPserver/dist/mcp-server.js"]
        }
      }
    }
    
  2. 其他MCP客户端:

    使用提供的 mcp-config.json 文件或使用服务器路径手动配置。

可用的MCP工具

  • fetch_rss_feeds:聚合多个RSS源
  • get_feed_info:获取特定RSS源的信息

可用MCP资源

  • 订阅:通过以下方式访问单个RSS提要数据 rss://{feedUrl}
  • 可用提要:常用RSS源列表

可用MCP提示

  • 分析sss内容:分析RSS内容以获取见解
  • 新闻_简报:从RSS源生成新闻简报

示例用法

使用curl:

# Basic health check
curl http://localhost:3000/

# Enhanced health check
curl http://localhost:3000/health

# Fetch RSS feeds
curl -X POST http://localhost:3000/Fetch_RSSfeed \
  -H "Content-Type: application/json" \
  -d '{"urls": ["https://feeds.bbci.co.uk/news/rss.xml", "https://rss.cnn.com/rss/edition.rss"]}'

项目结构

```text
RSS-MCPserver/
├── src/
│   ├── index.ts              # Legacy REST API server file
│   ├── unified-server.ts     # Main unified server (REST + MCP HTTP + SSE)
│   ├── mcp-server.ts         # MCP server implementation (stdio)
│   ├── mcp-server-http.ts    # HTTP transport MCP server (legacy)
│   ├── mcp-server-sse.ts     # SSE transport MCP server (legacy)
│   ├── mcp-server-multi.ts   # Multi-transport MCP server (legacy)
│   ├── services/
│   │   └── rss-service.ts    # RSS aggregation service
│   └── types/
│       └── rss.types.ts      # TypeScript type definitions
├── tests/                    # Test suites
├── dist/                     # Compiled JavaScript (after build)
├── package.json              # Dependencies and scripts
├── tsconfig.json             # TypeScript configuration
├── mcp-config.json           # MCP server configuration (stdio)
├── mcp-config-http.json      # HTTP transport configuration (legacy)
├── mcp-config-sse.json       # SSE transport configuration (legacy)
├── mcp-config-multi.json     # Multi-transport configuration (legacy)
├── MCP_SETUP.md              # MCP setup documentation (stdio)
├── README-HTTP.md            # HTTP transport guide
├── README-TRANSPORTS.md      # Transport comparison guide
├── Dockerfile                # Production Docker image (unified server)
├── Dockerfile.dev            # Development Docker image
├── docker-compose.yml        # Docker Compose configuration (single port)
├── .dockerignore            # Docker ignore patterns
└── README.md                # This file

Docker信息

集装箱特征

  • 基本图像:Node.js 18 Alpine(轻量级)
  • 安全:非root用户执行
  • 健康检查:内置健康监测
  • 多阶段构建:优化了生产图像大小
  • 端口:3000(可通过PORT环境变量配置)

可用的Docker脚本

# Docker Compose (Recommended)
npm run compose:up          # Start production services
npm run compose:down        # Stop all services
npm run compose:logs        # View logs
npm run compose:dev         # Start development mode
npm run compose:restart     # Restart services

# Manual Docker Commands
npm run docker:build        # Build image
npm run docker:run          # Run container
npm run docker:stop         # Stop container
npm run docker:remove       # Remove container
npm run docker:clean        # Remove image

环境变量

  • PORT:服务器端口(默认值:3000)
  • NODE_ENV:环境模式(开发/生产)

测试

运行综合测试套件:

# Run all tests
npm test

# Run tests with coverage
npm run test:coverage

# Run tests in watch mode
npm run test:watch

测试覆盖率

该项目包括65+项测试,涵盖:

  • ✅ 健康终点
  • ✅ RSS聚合功能
  • ✅ MCP服务器实现
  • ✅ 集成测试
  • ✅ 错误处理
  • ✅ 输入验证

发展

MCP开发工作流程

  1. 进行更改 到MCP服务器代码

  2. 构建 MCP服务器:

    npm run mcp:build
    
  3. 测试 开发模式:

    npm run mcp:dev
    
  4. 运行测试 验证:

    npm test
    

REST API开发工作流程

  1. 进行更改 到REST API代码

  2. 启动开发服务器:

    npm run dev
    
  3. 测试终点 使用Swagger UI或curl

  4. 运行测试 验证:

    npm test
    

贡献

  1. 复刻仓库
  2. 创建要素分支
  3. 进行更改
  4. 添加新功能的测试
  5. 确保所有测试通过
  6. 提交拉取请求

许可证

该项目根据MIT许可证获得许可。请参阅 许可证 文件以获取详细信息。