AR

ali-rajabpour/tradingview-mcp

Browser automation

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

18 stars 10 forks Качество 67 Тренд 22MIT

A lightweight Python MCP server that fetches TradingView chart snapshots using Playwright for fast, secure, and customizable browser automation.

Обзор

A Model Context Protocol (MCP) server for fetching TradingView chart snapshots. Uses Playwright for efficient browser automation with persistent sessions and cookie-based authentication. : This uses Playwright because TradingView renders charts client-side with JavaScript/Canvas. There is no pure HTTP API for chart images. This is the lightest possible working solution (~150MB RAM vs ~500MB with Selenium). - 🪶 : Playwright in headless mode (~150MB vs ~500MB with Selenium) - 🚀 : Persistent browser reuse, 3-5 seconds per chart - 🔐 : Session-based authentication via cookies - 🎨 : Configure chart dimensions, intervals, and themes - 🔧 : Works with any MCP-enabled client (Claude Desktop, etc.) - ♻️ : Reuses browser instances across multiple requests - Python 3.10 or higher - A TradingView account (free or paid) - TradingView session cookies 2. - Log into TradingView in your browser - Press to open Developer Tools - Go to tab (Chrome) or tab (Firefox) - Navigate to > https://www.

README

Показан фрагмент оригинального README. Открыть оригинал.

TradingView MCP Server 📈

A lightweight Model Context Protocol (MCP) server for fetching TradingView chart snapshots. Uses Playwright for efficient browser automation with persistent sessions and cookie-based authentication.

Note: This uses Playwright because TradingView renders charts client-side with JavaScript/Canvas. There is no pure HTTP API for chart images. This is the lightest possible working solution (~150MB RAM vs ~500MB with Selenium).

✨ Features

  • 🪶 Lightweight: Playwright in headless mode (~150MB vs ~500MB with Selenium)
  • 🚀 Fast: Persistent browser reuse, 3-5 seconds per chart
  • 🔐 Secure: Session-based authentication via cookies
  • 🎨 Customizable: Configure chart dimensions, intervals, and themes
  • 🔧 MCP Compatible: Works with any MCP-enabled client (Claude Desktop, etc.)
  • ♻️ Efficient: Reuses browser instances across multiple requests

📋 Prerequisites

  • Python 3.10 or higher
  • A TradingView account (free or paid)
  • TradingView session cookies

Table of Contents

🚀 Installation

1. Clone the repository

git clone https://github.com/yourusername/tradingview-mcp.git
cd tradingview-mcp

2. Create a virtual environment

# Windows
python -m venv venv
.\venv\Scripts\activate

# Linux/Mac
python3 -m venv venv
source venv/bin/activate

3. Install dependencies

pip install -r requirements.txt

# Install Playwright browsers (one-time setup, ~150MB download)
python -m playwright install chromium

4. Configure credentials

  1. Copy .env.example to .env:

    # Windows
    copy .env.example .env
    
    # Linux/Mac
    cp .env.example .env
    
  2. Get your TradingView session cookies:

    • Log into TradingView in your browser
    • Press F12 to open Developer Tools
    • Go to Application tab (Chrome) or Storage tab (Firefox)
    • Navigate to Cookies > https://www.tradingview.com
    • Find and copy these two cookie values:
      • sessionid → Copy the entire value
      • sessionid_sign → Copy the entire value

    ⚠️ Important: Copy the full values including any special characters (slashes, equals signs, etc.). Don’t add quotes or extra spaces.

  3. Edit .env and paste your values:

    TRADINGVIEW_SESSION_ID=your_actual_session_id_here
    TRADINGVIEW_SESSION_ID_SIGN=your_actual_session_id_sign_here
    

    Example (with fake values):

    TRADINGVIEW_SESSION_ID=47zlhkbl2weohrhmjgufeg1o24droaod
    TRADINGVIEW_SESSION_ID_SIGN=v3:6S2OD9ta349/yqN0RdCeK3UKxTl/tJr4AOoPRUa0Crk=
    
Открыть полный README на GitHub

Установка

This server does not publish a one-line install command.

Open the repository installation guide Новичок в MCP? Начните с руководства на mcpskill.org →

Конфигурация

{ "mcpServers": { "tradingview": { "command": "python", "args": ["C:\\path\\to\\tradingview-mcp\\src\\tradingview_mcp\\server.py"], "cwd": "C:\\path\\to\\tradingview-mcp" } } }