TradingAssistantMCP
TradingAssistantMCP
학습용 프로젝트: 에이전트(예: Claude)가 주식 데이터를 가져오고, 궁극적으로는 백테스트와 맞춤형 트레이딩 전략을 실행할 수 있게 해주는 MCP(Model Context Protocol) 서버입니다.
설정
Python 3.11+ 필요. 아직 API 키는 필요 없습니다(현재 도구는 가입이 필요 없는 yfinance를 사용합니다).
python3 -m venv .venv
.venv/bin/pip install -e .이 명령은 .venv/에 격리된 환경을 만들고 이 프로젝트의 의존성을 설치합니다. .venv/는 gitignore 처리되어 있으므로, 이 저장소를 클론하는 사람은 무엇이든 작동시키기 전에 이 두 명령을 직접 실행해야 합니다.
Related MCP server: Yahoo Finance MCP Server
서버 실행
서버(src/trading_assistant_mcp/server.py)는 사용자가 직접 실행하는 것이 아니라 MCP 클라이언트(에이전트)가 stdio를 통해 실행하도록 설계되었습니다. 테스트할 수 있는 두 가지 방법이 있습니다:
1. MCP Inspector (수동 테스트, 에이전트 불필요) — 도구를 직접 호출하기 위한 브라우저 UI:
.venv/bin/mcp dev src/trading_assistant_mcp/server.py로컬 URL(예: http://127.0.0.1:6274)이 열립니다. Connect를 클릭하고 Tools 탭으로 이동한 후 도구를 수동으로 호출하세요.
uv가 설치되어 있어야 합니다(mcp dev는 위의 venv와 관계없이 내부적으로 uv run을 통해 서버를 실행합니다).
2. Claude Code (실제 에이전트) — .mcp.json에 프로젝트 범위 MCP 서버로 등록되어 있습니다. 이 디렉터리에서 Claude Code 세션을 열고 "AAPL의 가격이 얼마야?" 같은 질문을 하면 됩니다. Claude가 도구를 호출할지 여부를 스스로 결정합니다.
이식성 참고:
.mcp.json은 이 머신의.venv/bin/python에 대한 절대 경로를 하드코딩합니다. 이 저장소를 다른 곳에 클론했다면 다음을 다시 실행하세요:claude mcp add -s project trading-assistant -- /absolute/path/to/.venv/bin/python /absolute/path/to/src/trading_assistant_mcp/server.py
현재 구현된 기능
get_quote(symbol)— 주식 티커의 현재 가격, 일일 변동 범위, 거래량.
프로젝트 구조
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는 의도적으로 얇은 어댑터입니다. mcp를 임포트하는 유일한 파일입니다. 데이터 가져오기 및 (추후) 분석 로직은 일반 Python 모듈에 유지되어 프로토콜 계층과 독립적으로 테스트하고 재사용할 수 있습니다.
로드맵
백테스트와 맞춤형 자연어 전략(예: "AMD가 1% 하락할 때마다 매수, 5% 상승할 때마다 매도")에 앞서 현재 데이터 분석(캔들스틱, 펀더멘털/비율, 기술적 지표)을 진행합니다. 전체 계획은 프로젝트 결정 사항을 참조하세요.
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