Skip to main content
Glama
MCP TradingView Server

MCP TradingView Server

MCP TradingView Server

Serveur MCP (Model Context Protocol) en Python qui expose les données de marché TradingView à un client MCP — Claude Desktop, claude.ai ou tout autre client compatible. Les données sont récupérées via tvdatafeed (OHLCV) et tradingview-ta (screener).

Outils exposés

Outil MCP

Description

tv_get_historical_data

Bougies OHLCV historiques (actions, crypto, forex, futures)

tv_get_quote

Dernière bougie + variation % par rapport à la précédente

tv_get_indicators

Indicateurs techniques, contexte multi-timeframe et score composite

tv_screener

Filtrage par marché, volume et RSI sur un univers prédéfini

tv_get_indicators en détail

Indicateurs calculés : RSI, MACD, Bollinger Bands (avec détection de squeeze), EMA, SMA, ATR (avec niveaux de stop long/short), Stochastique, ADX (+DI/−DI), OBV, moyenne et ratio de volume 20 périodes, et détection de divergences RSI.

Trois options désactivées par défaut :

Paramètre

Effet

include_weekly: true

Ajoute un contexte hebdomadaire : weekly_rsi, weekly_adx, weekly_trend

benchmark_symbol: "CW8"

Calcule la force relative à 1 mois et 3 mois contre ce benchmark

include_score: true

Calcule un score technique composite dans [-1, +1] et ses sous-scores

Intervalles acceptés : 1, 3, 5, 15, 30, 45 (minutes), 1H, 2H, 3H, 4H, 1D, 1W, 1M.

Portée du screener

tvdatafeed n'expose pas d'API de screener. tv_screener parcourt donc un univers prédéfini en dur dans MARKET_SYMBOLS (src/mcp_tradingview/client.py) et calcule les indicateurs sur chaque symbole via tradingview-ta :

Marché

Univers couvert

france

29 symboles Euronext Paris — CAC 40, quelques midcaps tech, ETF éligibles PEA

america

20 blue chips Nasdaq / NYSE

crypto

8 paires majeures Binance

forex

6 paires majeures

L'énumération ScreenerMarket accepte aussi futures, india, brazil, australia, canada, europe et hongkong, mais aucun univers n'est défini pour ces marchés : l'appel retourne une liste vide. Ajouter une entrée dans MARKET_SYMBOLS suffit à les activer.

Related MCP server: TradingView MCP Server

Architecture

Client MCP (Claude Desktop, claude.ai…)
    │
    ├── stdio ──► process local
    └── SSE   ──► serveur HTTP (Starlette + uvicorn)
              │
              ├──► tvdatafeed    : bougies OHLCV
              └──► tradingview-ta : screener
                        │
                        └──► cache TTL en mémoire

Prérequis

  • Python ≥ 3.11

  • Un compte TradingView est optionnel — l'accès anonyme fonctionne, avec des limites de débit plus strictes.

  • Le SDK MCP est épinglé en < 2.0.0 : la version 2.x supprime les décorateurs @server.list_tools() / @server.call_tool() et renomme Tool.inputSchema en Tool.input_schema. Une migration est nécessaire avant de lever ce plafond.

Installation

git clone https://github.com/mathieubernardi/tradingview_mcp.git
cd tradingview_mcp

pip install -e ".[dev]"

cp .env.example .env   # puis éditer .env

Configuration

Toutes les variables sont préfixées TV_ et peuvent être passées soit par un fichier .env, soit par l'environnement.

Variable

Défaut

Description

TV_TV_USERNAME

(vide)

Identifiant TradingView (optionnel)

TV_TV_PASSWORD

(vide)

Mot de passe TradingView (optionnel)

TV_TRANSPORT

stdio

stdio ou sse

TV_HOST

127.0.0.1

Hôte du serveur SSE

TV_PORT

8765

Port du serveur SSE (1024–65535)

TV_DEFAULT_EXCHANGE

EURONEXT

Place par défaut si l'appel n'en précise pas

TV_DEFAULT_N_BARS

500

Nombre de bougies par défaut

TV_MAX_N_BARS

5000

Plafond du nombre de bougies

TV_CACHE_TTL_SECONDS

60

Durée de vie du cache mémoire (0 = désactivé)

TV_LOG_LEVEL

INFO

DEBUG, INFO, WARNING ou ERROR

Le double préfixe de TV_TV_USERNAME / TV_TV_PASSWORD est voulu : le préfixe d'environnement TV_ s'ajoute aux champs tv_username / tv_password.

Lancer le serveur

Deux points d'entrée équivalents : le script console mcp-tradingview et le module python -m mcp_tradingview. Le second ne dépend pas du PATH, ce qui le rend plus fiable sous Windows.

# Linux / macOS — stdio
TV_TRANSPORT=stdio python -m mcp_tradingview

# Linux / macOS — SSE
TV_TRANSPORT=sse python -m mcp_tradingview
# Windows PowerShell — stdio
$env:TV_TRANSPORT = "stdio"; python -m mcp_tradingview

# Windows PowerShell — SSE
$env:TV_TRANSPORT = "sse"; python -m mcp_tradingview

Intégration Claude Desktop (stdio)

Ajouter dans claude_desktop_config.json — ~/Library/Application Support/Claude/ sous macOS, %APPDATA%\Claude\ sous Windows :

{
  "mcpServers": {
    "tradingview": {
      "command": "python",
      "args": ["-m", "mcp_tradingview"],
      "env": {
        "TV_TRANSPORT": "stdio",
        "TV_CACHE_TTL_SECONDS": "60"
      }
    }
  }
}

Si l'environnement Python n'est pas celui par défaut, remplacer "python" par le chemin absolu de l'interpréteur du virtualenv. Pour utiliser un compte TradingView, ajouter TV_TV_USERNAME et TV_TV_PASSWORD dans le bloc env.

En mode stdio, la session TradingView est établie paresseusement au premier appel d'outil : le handshake MCP répond immédiatement et le client ne subit pas de timeout au démarrage.

Intégration SSE

TV_TRANSPORT=sse TV_PORT=8765 python -m mcp_tradingview

Endpoint

Rôle

GET /sse

Flux SSE à déclarer côté client MCP

POST /messages/

Canal de retour des messages client

GET /health

Sonde de vivacité, retourne ok

Développement

pytest tests/ -v          # tests
ruff check src/ tests/    # lint
mypy src/                 # type checking (strict)

Limites connues

  • tvdatafeed est un client non officiel qui s'appuie sur les endpoints web de TradingView : il peut cesser de fonctionner sans préavis.

  • tv_screener ne balaye pas un marché entier, seulement l'univers prédéfini décrit plus haut.

  • Sans compte Premium TradingView, les données peuvent accuser un retard de plusieurs minutes.

  • L'accès anonyme subit des limites de débit sensiblement plus strictes qu'un compte connecté.

  • Les erreurs d'un outil sont renvoyées au client sous forme de JSON {"error": ..., "tool": ..., "arguments": ...} plutôt que remontées comme erreurs de protocole.

Structure du projet

tradingview_mcp/
├── src/mcp_tradingview/
│   ├── __init__.py      # métadonnées du paquet (__version__)
│   ├── __main__.py      # entrée `python -m mcp_tradingview`
│   ├── config.py        # settings (pydantic-settings, préfixe TV_)
│   ├── models.py        # schémas Pydantic d'entrée / sortie
│   ├── client.py        # client TradingView, indicateurs, cache TTL
│   ├── tools.py         # définition JSON Schema + dispatch des outils
│   └── server.py        # serveur MCP (stdio + SSE) et entrée console
├── tests/
│   └── test_server.py
├── pyproject.toml
├── .env.example
├── .gitignore
├── LICENSE
└── README.md

Licence

Distribué sous licence MIT. Voir le fichier LICENSE.

Available Tools

4 tools
tv_get_historical_dataA

Fetch historical OHLCV (Open, High, Low, Close, Volume) bars for any symbol from TradingView. Supports stocks, crypto, forex, futures.

Inputs: symbol (required), n_bars, exchange, interval.

tv_get_indicatorsA

Compute technical indicators for any symbol. Includes RSI, MACD, Bollinger Bands (+ squeeze detection), EMA, SMA, ATR (+ stop levels), Stochastic, ADX (+DI/-DI), OBV, volume MA20/ratio, RSI divergence flags. Optional: weekly multi-timeframe context (include_weekly=true), relative strength vs benchmark (benchmark_symbol), composite technical score [-1,+1] (include_score=true).

Inputs: symbol (required), bb_std, n_bars, exchange, +16 more.

tv_get_quoteA

Get the latest price quote for a symbol: last OHLCV bar plus percentage change from the previous bar.

Inputs: symbol (required), exchange, interval.

tv_screenerA

Screen stocks, crypto or forex symbols by market, volume, RSI range. Markets include 'france' (Euronext Paris — PEA) and 'america' (Nasdaq / NYSE). Returns top matches with price, volume and RSI data.

Inputs: limit, market, max_rsi, min_rsi, +2 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool targets a distinct data need: historical bars, latest quote, indicator calculation, and symbol screening. The only potential overlap is RSI appearing in indicators and screener, but the intended use (computing vs scanning) is clear.

    Naming Consistency4/5

    Three tools follow the `tv_get_*` verb-object pattern and all use consistent snake_case with a `tv_` prefix. `tv_screener` is the outlier because it uses a noun instead of an action verb, but it is still recognizable within the family.

    Tool Count5/5

    Four tools is a reasonable, focused size for a market-data server, and each tool provides broad functionality (multi-symbol historical data, quotes, many indicators, and a screener). None feels redundant or unnecessary.

    Completeness4/5

    The server covers the core market-data workflow: retrieving history, checking current prices, computing technical analysis, and discovering symbols via screening. Minor gaps such as no dedicated symbol-search or fundamental data endpoint exist, but they are workable around for typical technical-analysis use cases.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP clients to control a local TradingView Desktop instance, providing tools to read chart state, change symbols and timeframes, and fetch OHLCV data.
      88 npm
      134
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Exposes TradingView data including quotes, technical ratings, historical OHLCV, and market screening through an MCP server using unofficial libraries.
      -
    • F
      license
      Not graded
      quality
      C
      maintenance
      Provides unified TradingView capabilities through one MCP server, including market data, screening, technical analysis, backtesting, sentiment, chart control via browser automation, Pine script transpilation and compilation, and alert webhooks.
      -
    • A
      license
      A
      quality
      C
      maintenance
      Enables MCP clients to access market data from TradingView with automatic fallback to licensed providers, including symbol search, quotes, OHLCV history, technical indicators, and health checks.
      5
      88 npm
      MIT