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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。