Skip to main content
Glama
TradingAssistantMCP

TradingAssistantMCP

by kchinna

TradingAssistantMCP

Ein Lernprojekt: ein MCP-Server (Model Context Protocol), der es einem Agenten (z. B. Claude) ermöglicht, Aktiendaten abzurufen und schließlich Backtests und benutzerdefinierte Handelsstrategien auszuführen.

Einrichtung

Erfordert Python 3.11+. Noch keine API-Schlüssel nötig (die aktuellen Tools verwenden yfinance, das keine Anmeldung erfordert).

python3 -m venv .venv
.venv/bin/pip install -e .

Das erstellt eine isolierte Umgebung in .venv/ und installiert die Abhängigkeiten dieses Projekts hinein. .venv/ ist gitignored – jeder, der dieses Repo klont, muss diese beiden Befehle selbst ausführen, bevor etwas funktioniert.

Related MCP server: Yahoo Finance MCP Server

Server ausführen

Der Server (src/trading_assistant_mcp/server.py) ist nicht dafür gedacht, direkt von dir ausgeführt zu werden – er soll von einem MCP-Client (einem Agenten) über stdio gestartet werden. Zwei Möglichkeiten, ihn zu testen:

1. MCP Inspector (manuelles Testen, kein Agent nötig) – eine Browser-Oberfläche zum direkten Aufrufen von Tools:

.venv/bin/mcp dev src/trading_assistant_mcp/server.py

Öffnet eine lokale URL (z. B. http://127.0.0.1:6274). Klicke auf Connect, gehe zum Tab Tools und rufe ein Tool manuell auf.

Erfordert, dass uv installiert ist (mcp dev startet den Server intern über uv run, unabhängig von der obigen venv).

2. Claude Code (echter Agent) – registriert als projektspezifischer MCP-Server in .mcp.json. Öffne eine Claude-Code-Sitzung in diesem Verzeichnis und stelle einfach eine Frage wie „Wie ist der Preis von AAPL?“ – Claude entscheidet selbst, ob es das Tool aufruft.

Hinweis zur Portabilität: .mcp.json codiert einen absoluten Pfad zu .venv/bin/python dieser Maschine. Wenn du dieses Repo woanders klonst, führe erneut aus:

claude mcp add -s project trading-assistant -- /absolute/path/to/.venv/bin/python /absolute/path/to/src/trading_assistant_mcp/server.py

Was es bisher gibt

  • get_quote(symbol) – aktueller Preis, Tagesspanne, Volumen für ein Aktienkürzel.

Projektstruktur

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 built

server.py ist bewusst ein dünner Adapter: Es ist die einzige Datei, die mcp importiert. Datenabruf- und (später) Analyselogik bleiben in einfachen Python-Modulen, damit sie unabhängig von der Protokollschicht testbar und wiederverwendbar sind.

Roadmap

Analyse aktueller Daten (Candlesticks, Fundamentaldaten/Kennzahlen, technische Indikatoren) vor Backtesting und benutzerdefinierten natürlichen Sprachstrategien (z. B. „Kaufe AMD jedes Mal, wenn es um 1 % fällt, verkaufe jedes Mal, wenn es um 5 % steigt“). Siehe Projektentscheidungen für den vollständigen Plan.

Available Tools

4 tools
get_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

    A4.2/5.0

    Scored across 4 tools

    Disambiguation5/5

    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.

    Naming Consistency5/5

    All tools follow a consistent get_<noun> pattern with snake_case naming. The naming convention is uniform and predictable across the entire set.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables 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
    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides real-time stock quotes, historical data, and stock search via Yahoo Finance, enabling AI assistants to access and analyze financial market data.
      24 npm
      19
      MIT