System Overview
The Financial MCP Server is built as a hybrid platform supporting both Model Context Protocol (MCP) and REST API interfaces, providing seamless access to financial data from multiple sources.Core Components
1. Protocol Handlers
MCP Protocol Handler
- Purpose: Native AI agent integration
- Technology: Model Context Protocol standard
- Features: Structured tool calls, type safety, error handling
- Use Case: Claude Desktop, custom AI agents
REST API Handler
- Purpose: Traditional web/mobile application integration
- Technology: FastAPI with automatic OpenAPI documentation
- Features: HTTP endpoints, JSON responses, CORS support
- Use Case: Frontend applications, mobile apps, webhooks
2. Application Core
Financial MCP Server (main.py)
- Protocol routing and handling
- Server lifecycle management
- Configuration management
- Logging and monitoring
Tool Registry
- Single function, dual exposure (MCP + REST)
- Consistent error handling
- Parameter validation
- Response formatting
3. Data Access Layer
YFinance Tools (tools/yfinance_tools.py)
- Rate limiting protection
- Automatic retry logic
- Error handling and fallback
- Data normalization
FMP Tools (tools/fmp_tools.py)
- Professional API reliability
- Structured data responses
- Comprehensive error handling
- Rate limit monitoring
Utility Layer (tools/fmp_utils.py)
Design Patterns
1. Adapter Pattern
Each data source implements a common interface:2. Strategy Pattern
Different strategies for data retrieval:3. Decorator Pattern
Cross-cutting concerns handled via decorators:Modular Structure
Benefits of Modular Design
Maintainability
Maintainability
- Clear separation of concerns
- Easy to locate and modify specific functionality
- Reduced coupling between components
Scalability
Scalability
- Add new data sources without affecting existing code
- Independent scaling of different components
- Easy to extend with additional tools
Testability
Testability
- Unit test individual components in isolation
- Mock external dependencies easily
- Clear interfaces for testing
Reusability
Reusability
- Tools can be used in both MCP and REST contexts
- Utilities shared across different data sources
- Easy integration into other projects
Data Flow
Request Processing Flow
Error Handling Flow
Performance Considerations
1. Asynchronous Processing
2. Connection Pooling
3. Response Caching
Security Architecture
1. API Key Management
2. Input Validation
3. Rate Limiting
Deployment Architecture
Development
Production (Railway)
Container (Docker)
Monitoring & Observability
Logging Strategy
Health Checks
Next Steps
Development Setup
Set up local development environment
API Reference
Explore all available endpoints and tools
Deployment Guide
Deploy to production environments
Contributing
Extend and customize the server