Skip to main content
Glama
Madhan-2096

Stock-MCP

by Madhan-2096
README.md
# šŸ“ˆ Stock-MCP
### AI-Powered Stock Market MCP Server for GitHub Copilot

> A production-ready **Model Context Protocol (MCP) Server** built with **Python** and **FastMCP** that enables **GitHub Copilot Agent Mode** to access live stock market data, company information, technical analysis, news, and portfolio analytics through intelligent AI tool calling.

---

## šŸš€ Overview

Stock-MCP transforms GitHub Copilot into an intelligent financial assistant by exposing stock market capabilities as MCP tools.

Instead of relying on static knowledge, Copilot can invoke this server to fetch live financial information and perform real-time analysis.

Example:

> **User:** *What is the current stock price of Apple?*

↓

GitHub Copilot

↓

MCP Server

↓

Yahoo Finance

↓

Live Price Returned

↓

Copilot explains the result.

---

# ✨ Features

- šŸ“Š Live Stock Price Lookup
- šŸ¢ Company Information
- šŸ“° Latest Financial News
- šŸ“ˆ Technical Analysis
- šŸ’¼ Portfolio Valuation
- šŸ“‰ Portfolio Performance Analysis
- ⚔ FastMCP-based Tool Registration
- šŸ¤– GitHub Copilot Agent Mode Integration
- šŸ Pure Python Implementation
- šŸ”§ Easily Extendable Architecture

---

# šŸ— Architecture

```text
                    User
                      │
                      ā–¼
            GitHub Copilot Agent
                      │
             Model Context Protocol
                      │
                      ā–¼
              Stock-MCP Server
                      │
      ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
      │               │                │
      ā–¼               ā–¼                ā–¼
 Stock Tool      Company Tool      News Tool
      │               │                │
      ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                      │
               Yahoo Finance API
```

---

# šŸ“‚ Project Structure

```text
Stock-MCP/

ā”œā”€ā”€ server.py
ā”œā”€ā”€ mcp_app.py
ā”œā”€ā”€ mcp.json
ā”œā”€ā”€ requirements.txt
ā”œā”€ā”€ README.md
│
ā”œā”€ā”€ tools/
│   ā”œā”€ā”€ ping.py
│   ā”œā”€ā”€ stock.py
│   ā”œā”€ā”€ company.py
│   ā”œā”€ā”€ news.py
│   ā”œā”€ā”€ technical.py
│   ā”œā”€ā”€ portfolio.py
│   └── prediction.py
│
ā”œā”€ā”€ services/
ā”œā”€ā”€ utils/
ā”œā”€ā”€ models/
ā”œā”€ā”€ config/
└── tests/
```

---

# šŸ›  Tech Stack

| Technology | Purpose |
|------------|---------|
| Python 3.12+ | Backend |
| FastMCP | MCP Framework |
| MCP SDK | Protocol Support |
| yfinance | Stock Data |
| Pandas | Data Processing |
| NumPy | Numerical Computing |
| TA | Technical Indicators |
| Pydantic | Validation |
| GitHub Copilot | MCP Client |

---

# šŸ“¦ Installation

Clone the repository

```bash
git clone https://github.com/Madhan-2096/Stock-MCP.git

cd Stock-MCP
```

Create a virtual environment

```bash
python -m venv .venv
```

Activate it

### Windows

```bash
.venv\Scripts\activate
```

### Linux / macOS

```bash
source .venv/bin/activate
```

Install dependencies

```bash
pip install -r requirements.txt
```

---

# ā–¶ Running the MCP Server

```bash
python server.py
```

Expected Output

```text
Starting MCP Server...

Transport: stdio

Waiting for requests...
```

---

# šŸ”— Connecting with GitHub Copilot

Create an `mcp.json` configuration.

Example:

```json
{
  "servers": {
    "stock-market-assistant": {
      "command": "python",
      "args": [
        "server.py"
      ]
    }
  }
}
```

Reload GitHub Copilot Agent Mode.

Your tools will automatically become available.

---

# 🧰 Available MCP Tools

| Tool | Description |
|------|-------------|
| ping | Health check |
| get_stock_price | Get latest stock price |
| get_company_info | Company fundamentals |
| get_stock_news | Latest market news |
| technical_analysis | RSI, SMA, EMA, MACD |
| calculate_portfolio_value | Portfolio valuation |
| get_portfolio_performance | Portfolio return analysis |

---

# šŸ’¬ Example Prompts

### Get Stock Price

```
What is the current price of AAPL?
```

---

### Company Information

```
Tell me about Microsoft.
```

---

### Technical Analysis

```
Perform technical analysis for TSLA.
```

---

### News

```
Show today's news about NVIDIA.
```

---

### Portfolio

```
Calculate my portfolio.

AAPL - 10

MSFT - 5

GOOGL - 8
```

---

# šŸ“Š Current Capabilities

āœ… Live Stock Prices

āœ… Company Information

āœ… Technical Indicators

āœ… Financial News

āœ… Portfolio Valuation

āœ… Portfolio Performance

āœ… GitHub Copilot Integration

---

# 🚧 Roadmap

- [ ] Real-Time WebSocket Stock Streaming
- [ ] AI Investment Recommendations
- [ ] Sentiment Analysis
- [ ] Candlestick Pattern Detection
- [ ] Portfolio Optimization
- [ ] Stock Comparison Tool
- [ ] PDF Report Generator
- [ ] Alpha Vantage Integration
- [ ] Finnhub Integration
- [ ] Docker Support
- [ ] GitHub Actions CI/CD

---

# šŸ¤ Contributing

Contributions are welcome.

1. Fork the repository

2. Create a new feature branch

```bash
git checkout -b feature/new-feature
```

3. Commit your changes

```bash
git commit -m "Added new feature"
```

4. Push

```bash
git push origin feature/new-feature
```

5. Open a Pull Request

---

# šŸ“œ License

This project is licensed under the MIT License.

---

# šŸ‘Øā€šŸ’» Author

**Madhan J R**

B.Tech Artificial Intelligence & Data Science

Meenakshi Sundararajan Engineering College

GitHub: https://github.com/Madhan-2096

---

## ⭐ Support

If you found this project useful,

please consider giving it a ⭐ on GitHub.

It helps others discover the project and motivates future development.

---