TradingAssistantMCP
Click on "Deploy 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., "@TradingAssistantMCP what's the current price and volume for 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.
TradingAssistantMCP
A learning project: an MCP (Model Context Protocol) server that lets an agent (e.g. Claude) fetch stock data and, eventually, run backtests and custom trading strategies.
Setup
Requires Python 3.11+. No API keys needed yet (current tools use yfinance, which needs no signup).
python3 -m venv .venv
.venv/bin/pip install -e .That creates an isolated environment in .venv/ and installs this project's dependencies into it. .venv/ is gitignored — anyone cloning this repo needs to run these two commands themselves before anything will work.
Related MCP server: Yahoo Finance MCP Server
Running the server
The server (src/trading_assistant_mcp/server.py) isn't meant to be run directly by you — it's meant to be spawned by an MCP client (an agent) over stdio. Two ways to exercise it:
1. MCP Inspector (manual testing, no agent needed) — a browser UI for calling tools directly:
.venv/bin/mcp dev src/trading_assistant_mcp/server.pyOpens a local URL (e.g. http://127.0.0.1:6274). Click Connect, go to the Tools tab, and call a tool manually.
Requires uv to be installed (mcp dev launches the server via uv run internally, regardless of the venv above).
2. Claude Code (real agent) — registered as a project-scoped MCP server in .mcp.json. Open a Claude Code session in this directory and just ask a question like "what's the price of AAPL?" — Claude decides on its own whether to call the tool.
Portability note:
.mcp.jsonhardcodes an absolute path to this machine's.venv/bin/python. If you clone this repo elsewhere, re-run:claude mcp add -s project trading-assistant -- /absolute/path/to/.venv/bin/python /absolute/path/to/src/trading_assistant_mcp/server.py
What's here so far
Tools:
get_quote(symbol)— current price, day range, volume for a stock ticker.get_fundamentals(symbol)— valuation/financial ratios (P/E, market cap, EPS, dividend yield, beta, 52-week range, margins, growth).get_candles(symbol, period, interval)— historical OHLCV bars. Note: returns can be large (hundreds of candles) — not meant to be chained into another tool call by an agent, just for direct inspection.get_technical_indicators(symbol, period, interval)— SMA-20/50, RSI-14, MACD, Bollinger Bands, ATR-14, volume vs. its average. Fetches its own candle data internally rather than takingget_candles's output as input, since that output is too large to round-trip through a tool call/agent context.
Prompts:
analyze_stock(symbol)— standardized workflow: call all three data tools above, then apply a fixed textbook-interpretation rubric (trend/momentum/volatility/valuation). Explicitly framed as "what conventional signals say," not a price prediction — short-term price movement is close to a random walk and technical analysis doesn't reliably forecast it.
Project layout
src/trading_assistant_mcp/
├── server.py # MCP server: wraps data/analysis functions as tools + the analyze_stock prompt
├── models.py # shared types (Candle) used across data/ and analysis/
├── data/
│ └── yfinance_client.py # plain Python, no MCP dependency — reusable/testable on its own
└── analysis/
└── indicators.py # technical indicators computed from candle data, hand-rolled pandas (no pandas-ta)server.py is intentionally a thin adapter: it's the only file that imports mcp. Data-fetching and (later) analysis logic stay in plain Python modules so they're testable and reusable independent of the protocol layer.
Roadmap
Current-data analysis (candlesticks, fundamentals/ratios, technical indicators) before backtesting and custom natural-language strategies (e.g. "buy AMD every time it drops 1%, sell every time it rises 5%"). See project decisions for the full plan.
Available Tools
4 toolsget_candlesA
Get historical OHLCV candlestick bars for a stock symbol.
Args: symbol: Stock ticker symbol, e.g. "AAPL" or "MSFT". period: How far back to fetch, e.g. "1mo", "3mo", "6mo". interval: Bar size, e.g. "1h", "1d".
Inputs: symbol (required), period, interval. Returns: result
get_fundamentalsA
Get valuation/financial ratios for a stock symbol (P/E, market cap, EPS, dividend yield, beta, 52-week range, margins, growth, etc.).
Fields may be null if not available for a given symbol/exchange.
Args: symbol: Stock ticker symbol, e.g. "AAPL" or "MSFT".
Inputs: symbol (required).
get_quoteA
Get the current price and day range for a stock symbol.
Args: symbol: Stock ticker symbol, e.g. "AAPL" or "MSFT".
Inputs: symbol (required).
get_technical_indicatorsA
Compute standard technical indicators (SMA-20/50, RSI-14, MACD, Bollinger Bands, ATR-14, volume vs its 20-period average) for a stock symbol.
Fetches its own candle data internally (not via get_candles - that tool's raw output is too large to round-trip through a tool call). Needs at least 50 candles for every indicator to be non-null (fewer still works, but indicators requiring more history than is available return null).
Args: symbol: Stock ticker symbol, e.g. "AAPL" or "MSFT". period: How far back to fetch, e.g. "1mo", "3mo", "6mo". interval: Bar size, e.g. "1h", "1d".
Inputs: symbol (required), period, interval.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool targets a distinct data domain: real-time quote, fundamentals, historical OHLCV, and computed indicators. Descriptions clearly separate concerns, so an agent should not confuse them.
All tools follow a consistent get_<noun> pattern with snake_case naming. The naming convention is uniform and predictable across the entire set.
Four tools is a focused, well-scoped set for a market-data-only server. Each tool covers a meaningful and non-redundant aspect of stock research.
The set covers the core read-only stock data needs: real-time price, fundamentals, historical price data, and technical indicators. Minor gaps exist, such as no symbol search/disambiguation or batch quote support, but these are workable around.
Maintenance
Related MCP Connectors
Live stock quotes, a stock screener, crypto prices and FX rates as agent tools.
Yahoo Finance stock quotes and multi-ticker comparison as agent tools.
Yahoo Finance for AI agents: quotes, price history, options with Greeks, financials, news, movers.
Live crypto + IDX stock market intelligence for AI agents — 19 tools, no API key.
Related MCP Servers
- FlicenseCqualityDmaintenanceEnables LLMs to retrieve real-time stock and cryptocurrency prices and news using ticker symbols through the yfinance API.25-
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to retrieve stock market data and financial information from Yahoo Finance using the yfinance Python library. Supports querying stock prices, historical data, and other financial metrics through natural language.MIT
- AlicenseNot gradedqualityCmaintenanceProvides real-time stock quotes, historical data, and stock search via Yahoo Finance, enabling AI assistants to access and analyze financial market data.24 npm19MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to access real-time stock, crypto, and market index data from Yahoo Finance, supporting queries for prices, history, company info, and comparisons.MIT