Content
# AI News Collector MCP
An AI-based intelligent news event collection and analysis system that supports the MCP (Model Context Protocol) protocol.
## 🚀 Quick Start
### Prerequisites
- Node.js 18+
- Docker & Docker Compose
- Git
### 1. Clone the Project
```bash
git clone <repository-url>
cd ai-news-collector-mcp
```
### 2. Initialize the Environment
```bash
# Linux/macOS
./deploy.sh setup
# Windows
deploy.bat setup
```
### 3. Configure Environment Variables
```bash
cp .env.example .env
# Edit the .env file to configure necessary parameters
```
### 4. Start the Services
```bash
# Start the basic services
./deploy.sh start default
# Start the services with monitoring
./deploy.sh start monitoring
# Start all services
./deploy.sh start all
```
### 5. Verify Deployment
```bash
# Health check
./deploy.sh health
# Check service status
./deploy.sh status
```
## 📋 Service Endpoints
### API Service (http://localhost:3001)
- `GET /health` - Health check
- `POST /api/test` - Test interface
- `GET /api/test-data` - Generate test data
- `GET /api/system/info` - System information
### MCP Server
The system includes a basic MCP server that provides the following tools:
- `test_function` - Simple test function
- `health_check` - Health check
- `generate_test_data` - Generate test data
## 🔧 Development
### Install Dependencies
```bash
npm install
```
### Development Mode
```bash
# Start the API server
npm run api-server
# Start the MCP server
npm run mcp-server
# Start the main application
npm run dev
```
### Run Tests
```bash
npm test
npm run test:watch
```
### Build the Project
```bash
npm run build
```
## 🐳 Docker Deployment
### Supported Service Combinations
- `default` - Main application + Redis
- `mcp` - Includes MCP server
- `monitoring` - Includes Prometheus + Grafana
- `all` - All services
### Common Commands
```bash
# Start services
./deploy.sh start [service]
# Stop services
./deploy.sh stop [service]
# Restart services
./deploy.sh restart [service]
# View logs
./deploy.sh logs [service]
# Create backup
./deploy.sh backup
# Clean up data
./deploy.sh cleanup
```
## 📊 Monitoring
### Prometheus
- Address: http://localhost:9090
- Configuration file: `monitoring/prometheus.yml`
### Grafana
- Address: http://localhost:3002
- Default user: admin
- Default password: admin
## 🔍 Testing
The system includes a complete test suite:
- Unit tests
- Integration tests
- API tests
Run tests:
```bash
# Run all tests
npm test
# Run tests and generate coverage report
npm run test:coverage
# Run tests in watch mode
npm run test:watch
```
## 📁 Project Structure
```
ai-news-collector-mcp/
├── src/ # Source code
│ ├── api/ # API service
│ ├── mcp/ # MCP server
│ ├── models/ # Data models
│ ├── config/ # Configuration management
│ ├── types/ # Type definitions
│ ├── utils/ # Utility functions
│ └── index.ts # Main entry point
├── tests/ # Test files
├── data/ # Data storage
├── logs/ # Log files
├── monitoring/ # Monitoring configuration
├── docker-compose.yml # Docker orchestration
├── deploy.sh # Deployment script (Linux/macOS)
├── deploy.bat # Deployment script (Windows)
└── README.md # Project description
```
## ⚙️ Configuration
### Environment Variables
Main configuration items:
- `RSSHUB_URL` - RSSHub service address
- `REDIS_HOST` - Redis host address
- `PYTHON_SERVICE_URL` - Python service address
- `OPENAI_API_KEY` - OpenAI API key
### External Service Integration
- **RSSHub**: Default using http://124.221.80.250:5678
- **Redis**: Supports external Redis server configuration
- **Python Service**: Supports integration with external Python analysis services
## 🛠️ Development Plan
### Current Stage
- ✅ Basic framework setup
- ✅ Simple testing module
- ✅ MCP server
- ✅ API service
- ✅ Docker deployment
- 🔄 Monitoring system
### Next Stage
- 📋 Data collection module
- 📋 Storage and caching
- 📋 Python analysis service
- 📋 Advanced feature modules
## 🤝 Contribution
Feel free to submit Issues and Pull Requests!
## 📄 License
MIT License