MCP Financial Analyst
Enables financial analysis by fetching real market data from Yahoo Finance, computing moving averages, returns, and volatility, and generating price charts.
README
MCP Financial Analyst
A local MCP (Model Context Protocol) server that acts as a financial analyst: it fetches real market data from Yahoo Finance, runs lightweight analysis (moving averages, returns, volatility), and generates price charts. No hallucinated numbers—all data comes from yfinance.
Quick start (how to use the app)
1. Create a venv and install dependencies
Use a virtual environment so you avoid conda/base Python and Homebrew’s “externally managed” pip. Use Python 3.12+ (MCP currently supports 3.10–3.13; 3.14 support may lag).
cd MCP_StockTool
python3.12 -m venv .venv # or: python -m venv .venv
.venv/bin/pip install -r requirements.txt
If you don't have Python 3.12, install it with your package manager (e.g. Homebrew on macOS), then run the two commands above with that Python.
2. Add the MCP server to MCP Client
Link this MCP Server to an existing MCP Client + LLM platforms like GitHub Copilot, Cursor or Claude Desktop to use: ** Repace /absolute/path/to with location of this server on your local computer.
{
"mcpServers": {
"financial-analyst": {
"command": "python",
"args": ["server.py"],
"cwd": "/absolute/path/to/MCP_StockTool"
}
}
}
- Save. Restart Cursor (or reload the window) so it picks up the server.
3. Use it in chat
In the Platform / IDE of your choice, open the chat, ask things like:
- "Fetch the last 3 months of daily data for AAPL."
- "Analyze MSFT from 2026-01-01 to 2026-02-01 and show me the chart and key metrics."
- "What’s the 30-day moving average and return for GOOGL over the last 6 months?"
The AI will call the financial tools, get real data, and answer with numbers and (when you use analyze) a chart path. Charts are saved under MCP_StockTool/charts/.
- fetch_market_data – Get OHLCV data for a ticker over a date range.
- analyze_and_chart – Get the same data, compute 7-day/30-day MAs, return %, and volatility, and save a price chart.
Requirements
- Python 3.10+
- Dependencies:
mcp,yfinance,pandas,matplotlib
Install
From the project root:
cd MCP_StockTool
pip install -r requirements.txt
Or with uv:
uv pip install -r requirements.txt
Run the server (stdio)
For use by an MCP client (Cursor, Claude Desktop, etc.):
python server.py
The server uses stdio transport: the client spawns this process and talks over stdin/stdout. Do not run it interactively; the client will start it.
MCP Client Integration
Add this MCP server in Github Copilot/Cursor/Claude Desktop so the AI can use the financial tools.
- Add a server entry like this (adjust
pathif your project lives elsewhere):
{
"mcpServers": {
"financial-analyst": {
"command": "python",
"args": ["server.py"],
"cwd": "/absolute/path/to/MCP_StockTool",
"env": {}
}
}
}
If you use a virtualenv or uv:
{
"mcpServers": {
"financial-analyst": {
"command": "/path/to/venv/bin/python",
"args": ["server.py"],
"cwd": "/absolute/path/to/MCP_StockTool"
}
}
}
Or with uv:
{
"mcpServers": {
"financial-analyst": {
"command": "uv",
"args": ["run", "python", "server.py"],
"cwd": "/absolute/path/to/MCP_StockTool"
}
}
}
Restart App (or reload MCP) so it picks up the server. The AI will then see fetch_market_data and analyze_and_chart as available tools.
Tools
fetch_market_data
- ticker (str): Symbol, e.g.
AAPL,MSFT. - start_date (str): Start date
YYYY-MM-DD. - end_date (str): End date
YYYY-MM-DD. - interval (str):
"daily"|"weekly"|"monthly"(default"daily").
Returns a JSON object with ticker, start_date, end_date, interval, row_count, and data (list of OHLCV rows). On error, returns an error field and empty or partial data.
analyze_and_chart
- ticker (str): Symbol, e.g.
AAPL,MSFT. - start_date (str): Start date
YYYY-MM-DD. - end_date (str): End date
YYYY-MM-DD. - interval (str):
"daily"|"weekly"|"monthly"(default"daily"). - output_path (str, optional): Path for the chart image. If omitted, saves to
charts/<ticker>_<timestamp>.png.
Returns a JSON object with:
- chart_path: Absolute path to the saved chart.
- metrics:
ma_7d,ma_30d(when enough data),return_pct,volatility_annual_pct,data_points,first_close,last_close. - ticker, start_date, end_date, interval.
Volatility is the annualized standard deviation of daily (or period) returns in percent.
Example prompts (for the AI using this server)
- “Fetch the last 3 months of daily data for AAPL.”
- “Analyze MSFT from 2024-01-01 to 2024-12-01 and show me the chart and key metrics.”
- “What’s the 30-day moving average and return for GOOGL over the last 6 months?”
The AI will call the MCP tools with the right parameters and report back using the real data and chart path returned by the server.
Project layout
MCP_StockTool/
├── pyproject.toml
├── README.md
├── server.py # MCP entrypoint (stdio)
├── tools/
│ ├── __init__.py
│ ├── market_data.py # fetch_market_data implementation
│ └── chart_analyzer.py # analyze_and_chart implementation
└── charts/ # created at runtime for saved images
License
Use and modify as you like. Data is from Yahoo Finance via yfinance.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.