Skip to main content
Glama
MCP Finance Server

MCP Finance Server

by edwiniac
README.md
# πŸ“ˆ MCP Finance Server

[![CI](https://github.com/edwiniac/mcp-finance/actions/workflows/ci.yml/badge.svg)](https://github.com/edwiniac/mcp-finance/actions/workflows/ci.yml)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![MCP](https://img.shields.io/badge/MCP-1.0-green.svg)](https://modelcontextprotocol.io/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A Model Context Protocol (MCP) server that provides financial data tools for AI assistants. Get real-time stock prices, company info, market news, and technical analysis through a standardized interface.

## πŸš€ Features

- **Stock Prices** β€” Real-time and historical price data
- **Company Info** β€” Fundamentals, financials, and company profiles  
- **Market News** β€” Latest news and sentiment for any ticker
- **Technical Analysis** β€” Moving averages, RSI, MACD, and key indicators
- **Portfolio Tracking** β€” Track multiple positions with P&L calculations
- **Market Overview** β€” Major indices (S&P 500, NASDAQ, Dow) and market status
- **Stock Screener** β€” Filter stocks by market cap, P/E, sector, dividends
- **Crypto Prices** β€” Bitcoin, Ethereum, and other cryptocurrency data

## πŸ“¦ Installation

```bash
# Clone the repository
git clone https://github.com/edwiniac/mcp-finance.git
cd mcp-finance

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt
```

## πŸ”§ Configuration

### Claude Desktop

Add to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "finance": {
      "command": "python",
      "args": ["/path/to/mcp-finance/server.py"]
    }
  }
}
```

### With uvx (Recommended)

```json
{
  "mcpServers": {
    "finance": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/edwiniac/mcp-finance", "mcp-finance"]
    }
  }
}
```

## πŸ› οΈ Available Tools

| Tool | Description |
|------|-------------|
| `get_stock_price` | Current price, daily change, volume, 52-week range |
| `get_company_info` | Full company profile, financials, analyst ratings |
| `get_market_news` | Latest news articles for any ticker |
| `get_technical_analysis` | MA, RSI, MACD, support/resistance levels |
| `get_market_overview` | Major indices and market status |
| `calculate_portfolio` | Portfolio value and P&L tracking |
| `compare_stocks` | Side-by-side stock comparison |
| `get_crypto_price` | Cryptocurrency prices (BTC, ETH, etc.) |
| `get_earnings` | Earnings dates and history |
| `screen_stocks` | Filter stocks by criteria |

## πŸ’¬ Example Conversations

Once connected to Claude (or any MCP-compatible assistant):

**Stock Price Check:**
```
User: What's Apple trading at?
Assistant: Apple (AAPL) is currently at $185.92, up +1.24% today.
          Day range: $184.50 - $186.75
          52-week range: $164.08 - $199.62
```

**Technical Analysis:**
```
User: Give me a technical analysis of NVDA
Assistant: NVDA Technical Analysis (3-month):
          - Trend: Bullish
          - RSI(14): 62.5 (Neutral)
          - Price vs MA20: +4.2%
          - Support: $875 | Resistance: $950
```

**Portfolio Tracking:**
```
User: Calculate my portfolio: 10 AAPL at $150, 5 GOOGL at $140, 20 MSFT at $380
Assistant: Portfolio Summary:
          Total Value: $12,450.30
          Total P&L: +$1,892.50 (+17.9%)
          
          Holdings:
          - AAPL: +$359 (+23.9%)
          - GOOGL: +$285 (+40.7%)
          - MSFT: +$1,248 (+16.4%)
```

**Stock Comparison:**
```
User: Compare AAPL, MSFT, and GOOGL
Assistant: Comparison:
          | Metric      | AAPL    | MSFT    | GOOGL   |
          |-------------|---------|---------|---------|
          | Price       | $185.92 | $442.50 | $175.20 |
          | P/E Ratio   | 31.2    | 37.8    | 25.4    |
          | Market Cap  | $2.87T  | $3.29T  | $2.15T  |
          | 1Y Return   | +28.5%  | +19.2%  | +45.3%  |
```

## πŸ—οΈ Architecture

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           MCP Finance Server            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ Stock   β”‚  β”‚Technicalβ”‚  β”‚Portfolioβ”‚ β”‚
β”‚  β”‚ Data    β”‚  β”‚Analysis β”‚  β”‚ Calc    β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β”‚
β”‚       β”‚            β”‚            β”‚       β”‚
β”‚  β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”‚
β”‚  β”‚         Yahoo Finance API         β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β”‚ MCP Protocol (stdio)
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     Claude / AI Assistant               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

## πŸ”Œ Data Sources

- **Yahoo Finance** β€” Stock prices, company info, historical data (via `yfinance`)
- Free tier, no API key required
- Rate limits apply for heavy usage

## πŸ“Š Technical Indicators

The `get_technical_analysis` tool provides:

- **Moving Averages**: MA20, MA50, MA200
- **Momentum**: RSI(14), MACD, Signal Line
- **Levels**: Support, Resistance, 52-week range
- **Volatility**: Annualized volatility, average daily range
- **Trend**: Bullish/Bearish/Neutral classification

## πŸš€ Development

```bash
# Run server directly (for testing)
python server.py

# Run with MCP inspector
npx @modelcontextprotocol/inspector python server.py
```

## πŸ“ License

MIT License - see [LICENSE](LICENSE) for details.

## 🀝 Contributing

Contributions welcome! Please feel free to submit a Pull Request.

---

**Built with** [Model Context Protocol](https://modelcontextprotocol.io/) β€’ [yfinance](https://github.com/ranaroussi/yfinance) β€’ Python