Skip to main content
Glama
LeelaissakAttota

toolbridge-mcp-server

README.md
# ToolBridge MCP Server

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
[![Tests Passing](https://img.shields.io/badge/tests-344%20passing-brightgreen.svg)](https://github.com/LeelaissakAttota/toolbridge-mcp-server/actions)
[![Code Style: Ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](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*