Skip to main content
Glama
RSS MCP Server

RSS MCP Server

by GTuritto
README.md
# RSS MCP Server

## 🌐 Available Languages / Idiomas Disponibles

- [🇺🇸 English](README.md) - English documentation
- [🇪🇸 Español](README-ES.md) - Documentación en español

---

A comprehensive TypeScript-based RSS aggregation service that provides both a REST API and multiple Model Context Protocol (MCP) transport options in a unified server architecture. It fetches, parses, and serves RSS feeds with full AI assistant integration capabilities, all running on a single port for simplified deployment and usage.

## 🚀 Quick Start

### Unified Server (Recommended)

Everything runs on **one port** for maximum simplicity:

```bash
# 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
```

### Individual Transport Options (Advanced)

For specialized use cases, you can still run individual transports:

```bash
# 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
```

## 🏗️ Unified Architecture

The unified server combines all protocols in a single Express.js application:

| Protocol | Endpoint | Purpose | Status |
|----------|----------|---------|--------|
| **REST API** | `/`, `/health`, `/api-docs`, `/Fetch_RSSfeed` | Traditional HTTP API, Swagger docs | ✅ Active |
| **MCP HTTP** | `/mcp` | Modern MCP clients, web integration | ✅ Active |
| **MCP SSE** | `/sse`, `/messages` | Real-time streaming, legacy SSE clients | ✅ Active |

### Benefits of Unified Architecture

- ✅ **Single Port**: Only port 3000 to manage and expose
- ✅ **Simplified Deployment**: One container, one service  
- ✅ **Unified Monitoring**: Single health endpoint for all protocols
- ✅ **Better Resource Usage**: Shared memory and process management
- ✅ **Easier Development**: One server to start, stop, and debug
- ✅ **Protocol Independence**: Each transport maintains full functionality

**Unified Transport Endpoints:**

- **REST API**: `http://localhost:3000/` (health, RSS endpoints)
- **HTTP Transport**: `http://localhost:3000/mcp` (MCP over HTTP)
- **SSE Transport**: `http://localhost:3000/sse` (connection) + `http://localhost:3000/messages` (messages)

## Features

- ✅ **TypeScript**: Full type safety and modern JavaScript features
- ✅ **Express.js**: Fast, unopinionated web framework
- ✅ **RSS Aggregation**: Fetch and parse multiple RSS feeds
- ✅ **Multiple MCP Transports**: Stdio, HTTP (StreamableHTTP), SSE, and Multi-transport
- ✅ **Health Monitoring**: Basic and comprehensive health checks across all transports
- ✅ **Input Validation**: Comprehensive request validation with detailed errors
- ✅ **OpenAPI 3.0**: Complete API specification and documentation
- ✅ **Swagger UI**: Interactive API documentation and testing
- ✅ **MCP Inspector Compatible**: Works with web-based MCP testing tools
- ✅ **Session Management**: Advanced session handling for HTTP-based transports
- ✅ **CORS Support**: Web client compatibility
- ✅ **Jest Testing**: Comprehensive unit and integration tests (65 tests, 90%+ coverage)
- ✅ **Docker Support**: Production-ready containerization
- ✅ **Security**: Non-root containers, input sanitization
- ✅ **AI Integration**: MCP tools, resources, and prompts for AI assistants

## 🔗 Integration Options

### REST API Interface

Traditional REST API for direct HTTP integration with applications.

### MCP Server Interface (Multiple Transports)

Model Context Protocol server with flexible transport options:

- **Stdio**: For command-line tools and subprocess communication
- **StreamableHTTP**: Modern HTTP-based transport with full MCP support
- **SSE**: Server-Sent Events for real-time streaming (deprecated but supported)
- **Multi-Transport**: Combined HTTP and SSE support on single server

## 📊 API Endpoints (REST)

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/` | GET | Basic health check |
| `/health` | GET | Comprehensive health monitoring |
| `/Fetch_RSSfeed` | POST | Aggregate multiple RSS feeds |
| `/docs` | GET | API documentation (redirect) |
| `/api-docs` | GET | Interactive Swagger UI |
| `/api-docs.json` | GET | OpenAPI 3.0 specification |

## 🔗 MCP Transport Endpoints

| Transport | Endpoint | Method | Purpose |
|-----------|----------|--------|---------|
| **Stdio** | N/A | stdin/stdout | Subprocess integration |
| **HTTP** | `http://localhost:3000/mcp` | POST | Web clients, MCP Inspector |
| **SSE** | `http://localhost:3000/sse` | EventSource | SSE connection endpoint |
| **SSE** | `http://localhost:3000/messages` | POST | SSE message endpoint |

## 🤖 MCP Capabilities (AI Assistant)

| Type | Name | Description |
|------|------|-------------|
| **Tools** | `fetch_rss_feeds` | Fetch and aggregate multiple RSS feeds |
| | `get_feed_info` | Get information about a specific RSS feed |
| **Resources** | `rss-feed` | Access individual RSS feed data |
| | `available-feeds` | List of popular RSS feeds |
| **Prompts** | `analyze_rss_content` | Analyze RSS content for insights |
| | `news_briefing` | Generate news briefings from RSS feeds |

## 📖 Documentation

### API Documentation

- **Interactive API Docs**: [http://localhost:3000/api-docs](http://localhost:3000/api-docs)
- **OpenAPI Specification**: [http://localhost:3000/api-docs.json](http://localhost:3000/api-docs.json)

### MCP Transport Documentation

- **Transport Comparison**: [README-TRANSPORTS.md](./README-TRANSPORTS.md) | [Español](./README-TRANSPORTS-ES.md) - Comprehensive guide to all transport options
- **HTTP Transport Guide**: [README-HTTP.md](./README-HTTP.md) | [Español](./README-HTTP-ES.md) - StreamableHTTP transport setup and usage
- **MCP Setup Guide**: [MCP_SETUP.md](./MCP_SETUP.md) - Original stdio transport setup

### Additional Resources

- **Detailed Guide**: [OPENAPI_POSTMAN_GUIDE.md](./OPENAPI_POSTMAN_GUIDE.md)
- **Project Summary**: [PROJECT_SUMMARY.md](./PROJECT_SUMMARY.md)

## Installation

### Local Development

1. Clone the repository
2. Install dependencies:

   ```bash
   npm install
   ```

### Docker Installation

**Prerequisites**: Docker and Docker Compose installed on your system.

#### Quick Start with Docker Compose (Recommended)

```bash
# Production deployment
docker-compose up -d

# Development with hot reload
npm run compose:dev
```

#### Manual Docker Commands

```bash
# Build the Docker image
npm run docker:build

# Run the container
npm run docker:run

# Stop the container
npm run docker:stop
```

## 🔧 MCP Configuration

### Transport Selection Guide

Choose the transport that best fits your use case:

- **Stdio** (`npm run mcp`): Best for Claude Desktop and CLI integration
- **HTTP** (unified server): Best for web applications and MCP Inspector  
- **SSE** (unified server): For legacy SSE clients requiring real-time streaming
- **Unified** (`npm run unified` or Docker): All transports on single port 3000 (recommended)

### Client Configuration Examples

#### Claude Desktop (Stdio Transport)

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

#### MCP Inspector (HTTP Transport)

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

#### Custom SSE Client

```javascript
// 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' })
});
```

## Usage

### Local Development Mode

Run the server in development mode with TypeScript compilation:

```bash
npm run dev
```

### Production Mode

1. Build the TypeScript code:

   ```bash
   npm run build
   ```

2. Start the server:

   ```bash
   npm start
   ```

### MCP Server Mode

Start the MCP server for AI assistant integration (choose your transport):

```bash
# 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 Usage

#### Production Deployment

```bash
# Start with Docker Compose
docker-compose up -d

# Check logs
npm run compose:logs

# Stop services
npm run compose:down
```

#### Development with Docker

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

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

#### Docker Container Management

```bash
# Build image
npm run docker:build

# Run container
npm run docker:run

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

The server will start on port 3000 (or the port specified in the `PORT` environment variable).

## API Endpoints

### Health Check

- **URL**: `GET /`
- **Description**: Basic server status check
- **Response**:

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

### Enhanced Health Check

- **URL**: `GET /health`
- **Description**: Comprehensive health and system information
- **Response**:

  ```json
  {
    "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"
      ]
    }
  }
  ```

### Fetch RSS Feeds

- **URL**: `POST /Fetch_RSSfeed`
- **Description**: Aggregates multiple RSS feeds and returns parsed articles
- **Request Body**:

  ```json
  {
    "urls": [
      "https://feeds.bbci.co.uk/news/rss.xml",
      "https://rss.cnn.com/rss/edition.rss"
    ]
  }
  ```

- **Success Response** (200):

  ```json
  {
    "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"
          }
        ]
      }
    ]
  }
  ```

- **Error Responses**:
  - **400 Bad Request**: Invalid request format or URLs
  - **500 Internal Server Error**: Server error

## MCP Integration

### Setup with AI Clients

1. **Claude Desktop Configuration**:

   Add to your Claude Desktop config:

   ```json
   {
     "mcpServers": {
       "rss-aggregator": {
         "command": "node",
         "args": ["/path/to/RSS-MCPserver/dist/mcp-server.js"]
       }
     }
   }
   ```

2. **Other MCP Clients**:

   Use the provided `mcp-config.json` file or configure manually using the server path.

### Available MCP Tools

- **fetch_rss_feeds**: Aggregate multiple RSS feeds
- **get_feed_info**: Get information about a specific RSS feed

### Available MCP Resources

- **rss-feed**: Access individual RSS feed data via `rss://{feedUrl}`
- **available-feeds**: List of popular RSS feeds

### Available MCP Prompts

- **analyze_rss_content**: Analyze RSS content for insights
- **news_briefing**: Generate news briefings from RSS feeds

## Example Usage

Using curl:

```bash
# 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"]}'
```

## Project Structure

```text
```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 Information

### Container Features

- **Base Image**: Node.js 18 Alpine (lightweight)
- **Security**: Non-root user execution
- **Health Checks**: Built-in health monitoring
- **Multi-stage Build**: Optimized production image size
- **Port**: 3000 (configurable via PORT environment variable)

### Available Docker Scripts

```bash
# 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
```

### Environment Variables

- `PORT`: Server port (default: 3000)
- `NODE_ENV`: Environment mode (development/production)

## Testing

Run the comprehensive test suite:

```bash
# Run all tests
npm test

# Run tests with coverage
npm run test:coverage

# Run tests in watch mode
npm run test:watch
```

### Test Coverage

The project includes 65+ tests covering:

- ✅ Health endpoints
- ✅ RSS aggregation functionality
- ✅ MCP server implementation
- ✅ Integration tests
- ✅ Error handling
- ✅ Input validation

## Development

### MCP Development Workflow

1. **Make changes** to the MCP server code
2. **Build** the MCP server:

   ```bash
   npm run mcp:build
   ```

3. **Test** with development mode:

   ```bash
   npm run mcp:dev
   ```

4. **Run tests** to validate:

   ```bash
   npm test
   ```

### REST API Development Workflow

1. **Make changes** to the REST API code
2. **Start development server**:

   ```bash
   npm run dev
   ```

3. **Test endpoints** using the Swagger UI or curl
4. **Run tests** to validate:

   ```bash
   npm test
   ```

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests for new functionality
5. Ensure all tests pass
6. Submit a pull request

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.