StockMCP
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@StockMCPwhat's the current price and market cap of Apple (AAPL)?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
đ StockMCP
A comprehensive Model Context Protocol (MCP) server for real-time stock market data using Yahoo Finance
StockMCP provides a powerful, JSON-RPC 2.0 compliant interface for accessing comprehensive stock market data, built on the Model Context Protocol standard. Perfect for AI applications, financial analysis tools, and trading bots.
đ Free Hosted Endpoint
Use StockMCP immediately without any setup! We provide a free hosted endpoint at:
Endpoint:
https://stockmcp.leoguerin.fr/mcpNo API key required - Just add to your MCP client configuration
Claude Desktop Configuration
For immediate access, use this configuration in your claude_desktop_config.json:
{
"mcpServers": {
"stock-mcp": {
"command": "npx",
"args": [
"mcp-remote",
"https://stockmcp.leoguerin.fr/mcp",
"--header",
"--allow-http"
]
}
}
}Configuration file locations:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\\Claude\\claude_desktop_config.json
Related MCP server: YFinance Trader MCP Tool
đ ī¸ Available Tools
Tool Name | Description |
| Retrieve current market data including price, volume, market cap, and key financial ratios |
| Access comprehensive financial statements (income, balance sheet, cash flow) and calculated ratios |
| Get historical OHLCV data with optional total return calculation including reinvested dividends |
| Analyze dividend payment history and corporate actions with quality metrics and consistency scoring |
| Get analyst price targets, consensus ratings (Buy/Hold/Sell), and EPS forecasts from professional analysts |
| Forward growth projections for revenue, earnings (EPS), and free cash flow with 1-year, 3-year, and 5-year CAGR estimates |
đ Quick Start
API Key Setup
Get a free Alpha Vantage API key: Visit https://www.alphavantage.co/support/#api-key
Configure environment:
# Copy the example environment file cp .env.example .env # Edit .env and add your API key ALPHAVANTAGE_KEY=your-actual-api-key-here
Using Docker (Recommended)
# Clone the repository
git clone https://github.com/yourusername/StockMCP.git
cd StockMCP
# Configure your API key (see API Key Setup above)
cp .env.example .env
# Edit .env with your Alpha Vantage API key
# Build and run with Docker
docker build -t stockmcp .
docker run -p 3001:3001 --env-file .env stockmcpLocal Development
# Install dependencies with uv (fastest)
uv sync
# Or with pip
pip install -e .
# Configure your API key (see API Key Setup above)
cp .env.example .env
# Edit .env with your Alpha Vantage API key
# Run the server
python src/main.py
# Server runs on http://localhost:3001/mcpMCP Client Integration
Once your server is running, integrate it with MCP clients:
Claude Desktop
Edit the configuration file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Add this configuration:
{
"mcpServers": {
"stock-mcp": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:3001/mcp",
"--header",
"--allow-http"
]
}
}
}Cursor
Add to your MCP configuration:
{
"stock-mcp": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:3001/mcp",
"--header",
"--allow-http"
]
}
}Other MCP Clients
For any MCP-compatible client, use:
Endpoint:
http://localhost:3001/mcpProtocol: JSON-RPC 2.0 over HTTP
Tools: Available via
tools/listmethod
đ Usage
StockMCP implements the Model Context Protocol (MCP) for seamless integration with AI applications. Once running, the server provides:
Endpoint:
http://localhost:3001/mcpProtocol: JSON-RPC 2.0 over HTTP
Discovery: Use
tools/listto get available toolsExecution: Use
tools/callto execute tools with parameters
For detailed API examples and JSON schemas, access the interactive documentation at http://localhost:3001/mcp/docs when the server is running.
đ ī¸ Development
Project Structure
StockMCP/
âââ src/
â âââ main.py # FastAPI server and endpoints
â âââ models.py # Pydantic models for MCP and stock data
â âââ mcp_handlers.py # MCP protocol request handlers
â âââ tools.py # Tools package entry point
â âââ tools/ # Modular tools implementation
â âââ market_data.py # Real-time quotes, history, fundamentals
â âââ analysis.py # Forecasts and growth projections
â âââ registry.py # Tool registration and execution
âââ tests/ # Comprehensive test suite (100 tests)
âââ Dockerfile # Container configuration
âââ pyproject.toml # Project dependencies and configuration
âââ README.md # This fileRunning Tests
# Run all tests
uv run pytest
# Run with verbose output
uv run pytest -v
# Run specific test file
uv run pytest tests/test_api.py
# Run with coverage
uv run pytest --cov=srcDependencies
Core Dependencies:
FastAPI - Modern web framework for APIs
Pydantic - Data validation using Python type hints
yfinance - Yahoo Finance data retrieval (primary data source)
pandas - Data manipulation and analysis
scipy - Scientific computing (required by yfinance)
Development Dependencies:
pytest - Testing framework
httpx - HTTP client for testing
pytest-mock - Mocking utilities
đŗ Docker Deployment
Build and Run
# Build the image
docker build -t stockmcp .
# Run the container
docker run -p 3001:3001 stockmcp
# Run in background
docker run -d -p 3001:3001 --name stockmcp-server stockmcpEnvironment Configuration
The container exposes the API on port 3001 by default. You can customize this:
# Custom port mapping
docker run -p 8080:3001 stockmcp
# With environment variables
docker run -p 3001:3001 -e LOG_LEVEL=DEBUG stockmcpđ§ Configuration
Server Configuration
The server can be configured through environment variables:
LOG_LEVEL- Logging level (DEBUG, INFO, WARNING, ERROR)HOST- Server host (default: 0.0.0.0)PORT- Server port (default: 3001)
API Limits & Data Sources
Primary Data Source: Yahoo Finance (yfinance)
Free tier with reasonable rate limits
Real-time and historical data
No API key required for basic usage
Secondary Data Source: Alpha Vantage (optional)
Enhanced earnings estimates and forecasts
Requires free API key for extended features
Graceful fallback when unavailable
Production Recommendations:
Implement request caching
Add retry logic with exponential backoff
Monitor API usage patterns
Consider data source redundancy
đ¤ Contributing
We welcome contributions! Here's how to get started:
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Make your changes with proper tests
Run the test suite (
uv run pytest)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
Development Guidelines
Type Hints - All functions should have proper type annotations
Tests - New features must include comprehensive tests
Documentation - Update README and docstrings for any API changes
Code Style - Follow PEP 8 and use meaningful variable names
đ License
This project is licensed under the MIT License - see the LICENSE file for details.
đ Acknowledgments
Yahoo Finance - For providing free stock market data
Model Context Protocol - For the excellent protocol specification
FastAPI - For the amazing web framework
Pydantic - For robust data validation
đ Support
đ Bug Reports - Open an issue
đĄ Feature Requests - Start a discussion
đ Documentation - Check our comprehensive API docs
đŦ Community - Join our discussions for help and ideas
Made with â¤ī¸ for the financial data community by LÊo Guerin
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/leogue/StockMCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server