TradingAssistantMCP
TradingAssistantMCP
Un proyecto de aprendizaje: un servidor MCP (Model Context Protocol) que permite a un agente (p. ej. Claude) obtener datos bursátiles y, eventualmente, ejecutar backtests y estrategias de trading personalizadas.
Configuración
Requiere Python 3.11+. Aún no se necesitan claves de API (las herramientas actuales usan yfinance, que no requiere registro).
python3 -m venv .venv
.venv/bin/pip install -e .Eso crea un entorno aislado en .venv/ e instala las dependencias de este proyecto en él. .venv/ está en gitignore: cualquiera que clone este repositorio debe ejecutar estos dos comandos por su cuenta antes de que funcione nada.
Related MCP server: Yahoo Finance MCP Server
Ejecutar el servidor
El servidor (src/trading_assistant_mcp/server.py) no está pensado para que lo ejecutes directamente tú, sino para que lo lance un cliente MCP (un agente) a través de stdio. Dos formas de probarlo:
1. MCP Inspector (pruebas manuales, sin necesidad de agente): una interfaz de navegador para llamar a las herramientas directamente:
.venv/bin/mcp dev src/trading_assistant_mcp/server.pyAbre una URL local (p. ej. http://127.0.0.1:6274). Haz clic en Connect, ve a la pestaña Tools y llama a una herramienta manualmente.
Requiere tener instalado uv (mcp dev lanza el servidor mediante uv run internamente, independientemente del venv anterior).
2. Claude Code (agente real): registrado como servidor MCP a nivel de proyecto en .mcp.json. Abre una sesión de Claude Code en este directorio y simplemente haz una pregunta como "¿cuál es el precio de AAPL?" — Claude decide por sí mismo si llamar a la herramienta.
Nota de portabilidad:
.mcp.jsontiene codificada una ruta absoluta al.venv/bin/pythonde esta máquina. Si clonas este repositorio en otro lugar, vuelve a ejecutar:claude mcp add -s project trading-assistant -- /absolute/path/to/.venv/bin/python /absolute/path/to/src/trading_assistant_mcp/server.py
Lo que hay hasta ahora
get_quote(symbol)— precio actual, rango del día, volumen de un ticker bursátil.
Estructura del proyecto
src/trading_assistant_mcp/
├── server.py # MCP server: wraps data functions as tools
├── data/
│ └── yfinance_client.py # plain Python, no MCP dependency — reusable/testable on its own
└── analysis/ # reserved for indicators (SMA/EMA/RSI/MACD), not yet builtserver.py es intencionadamente un adaptador delgado: es el único archivo que importa mcp. La obtención de datos y (más adelante) la lógica de análisis permanecen en módulos Python simples para que sean comprobables y reutilizables independientemente de la capa de protocolo.
Hoja de ruta
Análisis de datos actuales (velas, fundamentales/ratios, indicadores técnicos) antes de backtesting y estrategias personalizadas en lenguaje natural (p. ej. "comprar AMD cada vez que baje un 1%, vender cada vez que suba un 5%"). Consulta las decisiones del proyecto para el plan completo.
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