toolbridge-mcp-server
README.md
# ToolBridge MCP Server
[](https://opensource.org/licenses/MIT)
[](https://www.python.org/downloads/)
[](https://github.com/LeelaissakAttota/toolbridge-mcp-server/actions)
[](https://github.com/astral-sh/ruff)
A production-ready **Model Context Protocol (MCP) Server** with enterprise-grade financial intelligence tools. Built with clean architecture, SOLID principles, and full async/await support.
## ποΈ Architecture
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ToolBridge MCP Server β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Interface Layer (MCP Tools) β
β ββββββββββββ ββββββββββββ ββββββββββββ βββββββββββββββββββββ β
β β Stock β β Currency β βHistoricalβ β Technical β β
β β Price β β Exchange β β Price β β Indicators β β
β ββββββββββββ ββββββββββββ ββββββββββββ βββββββββββββββββββββ β
β ββββββββββββ ββββββββββββ ββββββββββββ βββββββββββββββββββββ β
β β Company β β Market β βFinancial β β News β β
β β Info β β Movers β β Analysis β β Sentiment β β
β ββββββββββββ ββββββββββββ ββββββββββββ βββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Application Layer (Services) β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββ β
β β FinanceService β β CurrencyService β β ProviderRouterβ β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββ β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββ β
β β HealthMonitor β β MetricsCollectorβ β FinanceCache β β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Infrastructure Layer (Providers) β
β ββββββββββββββ ββββββββββββββ ββββββββββββββ ββββββββββββββ β
β β Yahoo β β Alpha β β Twelve β β Finnhub β β
β β Finance β β Vantage β β Data β β β β
β ββββββββββββββ ββββββββββββββ ββββββββββββββ ββββββββββββββ β
β ββββββββββββββ ββββββββββββββ ββββββββββββββ β
β β Frankfurterβ βExchangeRateβ βCurrency β β
β β (ECB) β β-API β βLayer β β
β ββββββββββββββ ββββββββββββββ ββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Domain Layer (Models, Exceptions, Base Interfaces) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
## β¨ Features
### π Stock Market Tools (7 MCP Tools)
| Tool | Description |
|------|-------------|
| `stock_price` | Real-time quotes with company info, OHLC, volume, market cap |
| `historical_price` | OHLCV data, multiple intervals, date ranges, adjusted close |
| `company_info` | Profile, financials, leadership, key stats, dividends |
| `market_movers` | Gainers, losers, most active, trending, market summary |
| `technical_indicators` | SMA, EMA, RSI, MACD, Bollinger, ATR, VWAP, crossovers, S/R, trend |
| `financial_news` | Company/market/sector news with filters |
| `news_sentiment` | LLM-powered sentiment analysis (bullish/bearish/neutral) |
| `financial_analysis` | Comprehensive LLM-generated investment reports |
### π± Currency Tools (3 MCP Tools)
| Tool | Description |
|------|-------------|
| `currency_exchange` | Convert currencies, latest/historical rates |
| `supported_currencies` | List all supported currency codes with names/symbols |
### π Provider Failover (Automatic)
| Priority | Stock Providers | Currency Providers |
|----------|-----------------|-------------------|
| 1 | Yahoo Finance (free) | Frankfurter/ECB (free) |
| 2 | Alpha Vantage (free tier) | ExchangeRate-API (free tier) |
| 3 | Twelve Data (free tier) | CurrencyLayer (free tier) |
| 4 | Finnhub (free tier) | - |
| 5 | Polygon (optional) | - |
### π€ LLM Provider Layer
| Provider | Models |
|----------|--------|
| Cerebras | llama3.1-8b, 70b, 405b |
| NVIDIA NIM | Various |
| OpenRouter | Claude, GPT, Llama, etc. |
### ποΈ Enterprise Features
- **Clean Architecture** - Domain, Application, Infrastructure, Interface layers
- **SOLID Principles** - All components follow SRP, OCP, LSP, ISP, DIP
- **Async/Await** - Full async implementation for high concurrency
- **Provider Failover** - Automatic with health monitoring, circuit breaker, exponential backoff
- **TTL Caching** - Multi-tier (30s stock, 5min currency, 24h currencies)
- **Health Monitoring** - Background checks with Prometheus-style metrics
- **Retry Logic** - Configurable retries with exponential backoff (max 3)
- **Schema Validation** - JSON Schema Draft 2020-12 for all tool I/O
- **Type Safety** - Complete type hints, Pydantic v2 models
## π Quick Start
```bash
# Clone
git clone https://github.com/LeelaissakAttota/toolbridge-mcp-server.git
cd toolbridge-mcp-server
# Setup
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install
pip install -e .
# Configure
cp .env.example .env
# Edit .env with your API keys
# Run
python -m mcp_server.server
```
## π§ Configuration
Create `.env` with your API keys:
```bash
# LLM Providers (at least one required)
CEREBRAS_API_KEY=your_key
NVIDIA_API_KEY=your_key
OPENROUTER_API_KEY=your_key
# Optional: Finance provider keys (free tiers available)
ALPHA_VANTAGE_API_KEY=your_key
TWELVE_DATA_API_KEY=your_key
# Provider Routing
DEFAULT_PROVIDER=openrouter
DEFAULT_MODEL=claude-3.5-sonnet
ENABLE_FAILOVER=true
# Cache & Performance
CACHE_TTL=300
REQUEST_TIMEOUT=30
MAX_RETRIES=3
ENABLE_CACHE=true
ENABLE_HEALTH_MONITOR=true
```
## π§ͺ Testing
```bash
# Run all tests
pytest tests/ -q
# Run with coverage
pytest tests/ --cov=mcp_server --cov-report=html
# Run specific module
pytest tests/test_technical_indicators_tool.py -v
# Output: 344 passed, 2 warnings in ~5s
```
## π Test Coverage
| Phase | Tests | Description |
|-------|-------|-------------|
| Phase 1 (Foundation) | ~50 | Config, logging, models, base provider |
| Phase 2 (MCP Core) | ~100 | Tools, registry, validation, server |
| Phase 3 (Provider Layer) | ~104 | Provider abstraction, routing, failover |
| Sprint 4.1 (Finance Services) | ~17 | Cache, finance service, currency service |
| Sprint 4.2 (Advanced Finance) | ~73 | 7 new financial intelligence tools |
| **Total** | **344** | **100% passing** |
## π Project Progress
| Phase | Status | Description |
|-------|--------|-------------|
| Phase 1 | β
**Completed** | Foundation - Config, logging, models, base provider |
| Phase 2 | β
**Completed** | MCP Core Engine - Tools, registry, validation, server |
| Phase 3 | β
**Completed** | Provider Abstraction Layer - Cerebras, NVIDIA, OpenRouter with failover |
| Phase 4 | β
**Completed** | Financial Intelligence Platform |
| βββ Sprint 4.1 | β
**Completed** | Enterprise Financial Services Layer |
| βββ Sprint 4.2 | β
**Completed** | Advanced Financial Intelligence Tools |
## π¦ Requirements
- Python 3.11+
- Dependencies (auto-installed):
- `pydantic>=2.0,<3.0` - Settings & validation
- `pydantic-settings>=2.0,<3.0` - Environment config
- `uvicorn[standard]>=0.23` - ASGI server
- `mcp>=1.0.0` - Model Context Protocol
- `jsonschema>=4.0,<5.0` - Schema validation
- `numpy>=1.24.0` - Technical indicators
- `aiohttp>=3.8.0` - HTTP client
## ποΈ Development
```bash
# Install dev dependencies
pip install -e ".[dev]"
# Format code
ruff check . --fix
black .
# Type check
mypy mcp_server
# Security scan
bandit -r mcp_server
# Run tests
pytest tests/ -q
```
## π Project Structure
```
toolbridge-mcp-server/
βββ mcp_server/
β βββ config/ # Settings, environment config
β βββ core/ # Health, server core
β βββ exceptions/ # Exception hierarchy
β βββ health/ # Health checks
β βββ logging/ # Structured logging
β βββ mcp_core/ # MCP protocol errors
β βββ models/ # Base Pydantic models
β βββ providers/ # LLM & Finance providers
β βββ services/ # Finance, Currency services
β βββ tools/ # MCP tools (10 finance tools)
β βββ validation/ # Schema validation
β βββ server.py # FastMCP entry point
βββ tests/ # 344 tests (100% passing)
βββ docs/ # Documentation
βββ docker/ # Docker configs (future)
βββ scripts/ # Helper scripts
βββ LICENSE # MIT License
βββ pyproject.toml # Build & tool config
βββ requirements.txt # Runtime dependencies
βββ README.md # This file
```
## π License
MIT License - see [LICENSE](LICENSE) file.
## π€ Contributing
1. Fork the repository
2. Create feature branch
3. Add tests for new functionality
4. Ensure all tests pass (`pytest tests/ -q`)
5. Submit PR with description
## π Support
- **Issues:** [GitHub Issues](https://github.com/LeelaissakAttota/toolbridge-mcp-server/issues)
- **Discussions:** [GitHub Discussions](https://github.com/LeelaissakAttota/toolbridge-mcp-server/discussions)
---
**ToolBridge MCP Server v1.0.0** - *Empowering AI with Professional Financial Intelligence*This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessSyncing