3.1 KiB
3.1 KiB
MCPServer
A Flask-based server that provides an API for accessing and analyzing financial data, with integration for stock analysis and news processing.
Overview
The MCPServer (Model Calling Protocol Server) is designed to provide an API interface for financial data processing including stock market analysis, news aggregation, and financial metrics calculation. It serves as the backend service for processing financial information and making it available through HTTP endpoints.
Project Structure
MCPServer/
├── app.py # Main Flask application
├── config.py # Configuration settings
├── requirements.txt # Python dependencies
├── Dockerfile # Docker configuration
├── README.md # This file
└── api/ # API endpoints and handlers
├── __init__.py
├── stock_analysis.py # Stock analysis functions
└── news_processing.py # News processing functions
Features
- Stock Analysis: Financial metrics calculation and market data processing
- News Integration: APIs for retrieving and processing financial news
- Data Aggregation: Consolidation of multiple data sources into unified responses
- RESTful API: Clean HTTP interface for external services to consume data
Endpoints
Stock Analysis
- GET
/api/stock/metrics- Get financial metrics for a stock - GET
/api/stock/history- Get historical price data - POST
/api/stock/analyze- Perform comprehensive stock analysis
News Processing
- GET
/api/news- Retrieve news articles related to stocks - GET
/api/news/outlets- List available news sources - POST
/api/news/process- Process and categorize news content
Data Management
- GET
/api/data/refresh- Refresh data from sources - GET
/api/status- Server health check
Configuration
Environment Variables
The server supports configuration through environment variables:
FLASK_ENV- Set to 'development' or 'production' (default: 'development')DATABASE_URL- URL for database connection (e.g., PostgreSQL)API_KEY- API key for external servicesLOG_LEVEL- Logging level (DEBUG, INFO, WARNING, ERROR)
Installation
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables (optional but recommended):
export FLASK_ENV=production
export DATABASE_URL="postgresql://user:password@localhost/dbname"
- Run the server:
python app.py
Usage Examples
Get stock metrics:
curl "http://localhost:5000/api/stock/metrics?symbol=AAPL"
Get historical data:
curl "http://localhost:5000/api/stock/history?symbol=AAPL&days=30"
Process news for a stock:
curl -X POST "http://localhost:5000/api/news/process" \
-H "Content-Type: application/json" \
-d '{"symbol":"AAPL","articles":["/path/to/article1.txt","/path/to/article2.txt"]}'
Requirements
- Python 3.6+
- Flask 2.3.3
- Additional dependencies listed in
requirements.txt
License
This project is licensed under the MIT License.