AR

ali-rajabpour/tradingview-mcp

浏览器自动化

本页由 AI 翻译,技术细节请以原文为准。 查看原文

18 stars 10 forks 质量 67 趋势 22MIT

一个轻量级的 Python MCP 服务器,使用 Playwright 获取 TradingView 图表快照,用于快速,安全和自定义的浏览器自动化.

概览

一个用于获取 TradingView 图表快照的模型上下文协议服务器 。 使用Playwright来高效地实现浏览器自动化,同时具有持久性会话和基于饼干的认证. : 使用 Playwright 是因为 TradingView 使图表客户端与 JavaScript/ Canvas 连接. 图表图像没有纯 HTTP API 。 这是最轻松的工作解决方案(~150MB RAM vs~500MB with Selenium). - QQ: 无头模式的 Playwright(~150MB vs ~500MB with Selenium) - QQ:持续浏览器再利用,每张图表3-5秒 - QQ:基于会话的认证通过cookie - QQ:配置图表尺寸,间隔,和主题 - QQ:与任何MCP启用的客户端(Claude桌面等)一起工作 - QQ:在多个请求中重复使用浏览器事件 - Python 3.10或以上 - A TradingView账户(免费或支付) - TradingView会话 cookie 2. - 在浏览器中登录 TradingView - 按下打开开发者工具 - 转到标签(Chrome)或标签(Firefox) - 导航到 > https://www.

概述(AI 翻译)

** 轻量级** 用于取取TradingView图表快照的上下文模式协议(MCP)服务器。 使用Playwright来高效地实现浏览器自动化,同时具有持久性会话和基于饼干的认证.

** 注**: 这使用 Playwright , 因为 TradingView 使图表客户端与 JavaScript/ Canvas 。 图表图像没有纯 HTTP API 。 这是最轻松的工作解决方案(~150MB RAM vs~500MB with Selenium).

□ * * * * 特点

  • 轻量级**: 无头模式的 Playwright( ~150MB vs ~500MB with Selenium)
  • 快速:持续浏览器再利用,每图3-5秒
  • ** 安全**:通过饼干进行基于会话的认证
  • 可控: 配置图表尺寸、间隔和主题
  • QQ ** MCP 兼容**: 与任何 MCP 启用的客户端相接的工程( Claude D桌面等)
  • 有效**: 在多个请求中重复使用浏览器实例

□□ 先决条件

  • Python 3.10 或 更高级
  • 交易维尤账户(免费或支付)
  • 贸易维尤会议饼干

□ 目录

  • 安装
  • 快开始
  • 使用费
  • 配置
  • 可用的工具
  • 符号格式
  • 解决问题
  • 业绩
  • 贡献

□ 安装

1.

本页由 AI 翻译,技术细节请以原文为准。

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=
    
在 GitHub 查看完整 README

安装

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

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

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