Skip to main content

A minimal, educational MCP server that provides a single stock snapshot tool using the free Alpha Vantage API.

Project description

📈 Stock Snapshot MCP

A minimal, educational MCP server for stock snapshots using the free Alpha Vantage API.

Stock Snapshot MCP is a tiny, easy-to-read reference implementation of a
Model Context Protocol (MCP) server.

It exposes a single, clean tool: get_stock_snapshot(symbol, history_days=60)

This tool queries the free Alpha Vantage API and returns:

  • Company metadata (name, sector, industry, exchange, currency)
  • Latest quote (price, change, percent, previous close, volume)
  • Basic fundamentals (PE ratio, EPS, market cap, ROE, profit margin — if available)
  • Recent OHLCV price history (daily candles)

This project is ideal for:

  • People learning MCP through a small, realistic example
  • Developers building RAG-ready financial research agents
  • Students who want a simple MCP server to extend or customize
  • Anyone experimenting with Claude / ChatGPT MCP integrations
  • Mini-projects where clean, structured stock data is useful

Note: This project is not affiliated with Alpha Vantage.
It is designed solely as an educational reference.
Not for real trading or investment decisions.


✨ Features

  • 📦 Lightweight Python package (pip install stock-snapshot-mcp)
  • 🔌 MCP server (stdio) compatible with Claude Desktop, ChatGPT MCP, and other tools
  • 🔍 Clean JSON output suitable for LLM reasoning & agent pipelines

⚙️ Installation

1. Install the package

pip install stock-snapshot-mcp

2. Set your Alpha Vantage API key

Create a .env file or export it:

export ALPHAVANTAGE_API_KEY=your_key_here

🚀 Running the MCP server

Once installed:

stock-snapshot-mcp

This launches the MCP server over stdio, ready to be used by MCP-compatible clients. To see logs:

STOCK_SNAPSHOT_MCP_LOG=info stock-snapshot-mcp

🧪 Testing locally (Python)

You can call the helper function directly:

from stock_snapshot_mcp import get_stock_snapshot
import asyncio

async def main():
    snap = await get_stock_snapshot("AAPL", history_days=5)
    print(snap)

asyncio.run(main())

🧪 Example: manual MCP client

For debugging or learning MCP, you can run:

python examples/manual_mcp_client.py

🖥️ Using with Claude Desktop (example config)

Place this inside Claude’s configuration file:

macOS

~/Library/Application Support/Claude/claude_desktop_config.json

Windows

%APPDATA%\Claude\claude_desktop_config.json

Add:

{
  "mcpServers": {
    "stock-snapshot-mcp": {
      "command": "stock-snapshot-mcp",
      "env": {
        "ALPHAVANTAGE_API_KEY": "your_key_here"
      }
    }
  }
}

Restart Claude Desktop → you should see Stock Snapshot MCP under "Connected Servers".

Then you can ask Claude:

Call get_stock_snapshot for AAPL and summarize the fundamentals.


📤 Using with ChatGPT MCP (OpenAI Desktop / browser)

Add a new MCP connection:

  • Command: stock-snapshot-mcp
  • Environment:
    • ALPHAVANTAGE_API_KEY=your_key_here And that’s it.

📚 Tool Definition (JSON Schema)

get_stock_snapshot(
  symbol: string (required),
  history_days: integer (optional, 1–100, default: 60)
)

Output fields

{
  "symbol": "AAPL",
  "meta": {
    "name": "Apple Inc",
    "sector": "TECHNOLOGY",
    "industry": "CONSUMER ELECTRONICS",
    "currency": "USD",
    "exchange": "NASDAQ"
  },
  "quote": {
    "price": 278.78,
    "change": -1.92,
    "change_percent": -0.684,
    "previous_close": 280.7,
    "latest_trading_day": "2025-12-05",
    "volume": 47265845
  },
  "fundamentals": {
    "market_cap": 4137203794000,
    "pe_ratio_ttm": 37.32,
    "eps_ttm": 7.47,
    "roe_ttm": 1.714,
    "profit_margin": 0.269
  },
  "daily_history": [ ... ]
}

🧱 Project Structure

stock-snapshot-mcp/
  ├─ src/
  │   └─ stock_snapshot_mcp/
  │        ├─ __init__.py             # Public API
  │        ├─ alpha_vantage_client.py # API wrapper
  │        └─ server.py               # MCP stdio server
  ├─ tests/
  │   └─ test_smoke.py
  ├─ examples/
  │   ├─ claude_desktop_config.json
  │   └─ chat_prompt_examples.md
  ├─ .env.example
  ├─ pyproject.toml
  ├─ README.md
  ├─ LICENSE
  └─ .gitignore

🛑 Disclaimer

This project:

  • is not affiliated with Alpha Vantage
  • is not financial advice
  • is provided for educational and research purposes only

📜 License

MIT License — free to use, modify, and learn from.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stock_snapshot_mcp-0.1.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stock_snapshot_mcp-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file stock_snapshot_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: stock_snapshot_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for stock_snapshot_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b5a34fa41e9db4e92e699906bb2ee2fddf9c53d92f015e127014d0d9ad23d5f9
MD5 23182a12415e0a2360533f557f05497e
BLAKE2b-256 004a51d663bb3a6a6673b73c8a2cc688b6a262d6bdf358f3f084b3e58d8a78c9

See more details on using hashes here.

File details

Details for the file stock_snapshot_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for stock_snapshot_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9b92a93497211fed90ce5c9fcb81191dfe89001cdeab22fd3cab3712f5fe929d
MD5 c333c38be90d5c346241f108b0dc1739
BLAKE2b-256 902c5168ea4fdaa87e307004ce80c1d9ec3c9d66405f6753ee5f6c5315451e80

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page