MCP 服务器 - TradingView 图表图片抓取工具 logo

MCP 服务器 - TradingView 图表图片抓取工具

Community
ertugrul59

MCP server that captures TradingView chart images via Selenium — supports any ticker/interval with browser pooling for concurrent performance

Publisherertugrul59
Repositorytradingview-chart-mcp
LanguagePython
Forks
26
Stars
94
Available tools
0
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    MCP 服务器 - TradingView 图表图片抓取工具 exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    94 stars and 26 forks from the linked repository.

MCP Server - TradingView Chart Image Scraper

🚀 Now with Browser Pooling Optimization for 70-80% Better Concurrent Performance!

This MCP server provides tools to fetch TradingView chart images based on ticker and interval with advanced browser pooling for maximum concurrent performance.

Demo — AI analyzing a BTCUSDT daily chart via MCP

🔥 Performance Optimizations

Browser Pooling Technology

  • Production Version: Uses main_optimized.py with browser pooling for maximum concurrent performance
  • Performance Improvement: 70-80% faster for concurrent requests
  • Concurrent Handling: Supports up to 4 simultaneous requests with pre-initialized browser instances
  • Expected Performance:
    • 1 request: ~6-8s (baseline)
    • 2 concurrent: ~3-4s each (60-70% faster)
    • 3 concurrent: ~2.5-3.5s each (70-80% faster)

Version Comparison

  • main_optimized.py (Production): Browser pooling, concurrent optimization, performance tracking
  • main.py (Legacy): Simple single-browser approach, kept for debugging/fallback

Features

  • 🚀 Optimized Chart Image Tool: Fetches direct chart images with browser pooling for maximum concurrent performance
  • 📊 Performance Statistics: Built-in performance monitoring and statistics
  • 🔄 Browser Pool Management: Pre-initialized browser instances for zero-overhead concurrent requests
  • 🎯 Natural Language Prompts: Easy chart requests with interval mapping
  • ⚙️ Environment Configuration: Fully configurable via environment variables
  • 🔐 TradingView Authentication: Secure session-based authentication
  • 💾 Clipboard Capture: Direct base64 image capture for faster performance

Tools

get_tradingview_chart_image

Description: Fetches the direct image URL for a TradingView chart snapshot with optimized concurrent performance.

Performance: This optimized version achieves 70-80% better performance for concurrent requests using browser pooling technology.

Arguments:

  • ticker (str): The TradingView ticker symbol (e.g., "BYBIT:BTCUSDT.P", "NASDAQ:AAPL"). Required.
  • interval (str): The chart time interval (e.g., '1', '5', '15', '60', '240', 'D', 'W'). Required.

Returns:

  • (str): The direct TradingView snapshot image URL (e.g., data:image/png;base64,... or https://s3.tradingview.com/snapshots/...).

Raises:

  • Error (MCP type): If the scraper encounters an error. Error codes:
    • 400: Input error (invalid ticker/interval format)
    • 503: Scraper error (failure during the scraping process)
    • 500: Unexpected internal server error

get_performance_stats

Description: Get performance statistics for the optimized TradingView MCP server.

Returns:

  • Detailed metrics about request performance, improvement over baseline, and browser pool status

Example Output:

🚀 OPTIMIZED TRADINGVIEW MCP SERVER PERFORMANCE STATS
• Total Requests: 12
• Average Time: 3.30s
• Performance Improvement: 70.8%
• Browsers in Pool: 4
• Max Concurrent: 4

Prompts

  • Get the {interval} chart for {ticker}
    • Maps common timeframe names (e.g., "1 minute", "5 minute", "1 hour", "daily") to TradingView codes
  • Show me the daily TradingView chart for {ticker}
    • Specifically requests the daily ('D') chart
  • Fetch TradingView chart image for {ticker} on the {interval} timeframe
    • Comprehensive prompt with timeframe mapping

Setup

  1. Create Virtual Environment:

    bash
    # Navigate to the project directory
    cd tradingview-chart-mcp
    # Create the venv (use python3 if python is not linked)
    python3 -m venv .venv
  2. Activate Virtual Environment:

    • macOS/Linux:
      bash
      source .venv/bin/activate
    • Windows (Git Bash/WSL):
      bash
      source .venv/Scripts/activate
    • Windows (Command Prompt):
      bash
      .venv\\Scripts\\activate.bat
    • Windows (PowerShell):
      bash
      .venv\\Scripts\\Activate.ps1
      (Note: You might need to adjust PowerShell execution policy: Set-ExecutionPolicy RemoteSigned -Scope CurrentUser)

    Your terminal prompt should now indicate you are in the (.venv).

  3. Install Dependencies (inside venv):

    bash
    pip install -r requirements.txt
  4. Configure Environment (for Local Testing):

    • Copy .env.example to .env.
    • Fill in your TRADINGVIEW_SESSION_ID and TRADINGVIEW_SESSION_ID_SIGN in the .env file. You can obtain these from your browser's cookies after logging into TradingView.
    • This .env file is used when running the server directly (e.g., python main.py) for local testing.
    • Adjust optional scraper settings (MCP_SCRAPER_HEADLESS, etc.) in .env if needed for local runs.
  5. Ensure ChromeDriver: Make sure chromedriver is installed and accessible in your system's PATH, or configure the tview-scraper.py accordingly if it allows specifying a path.

Running the Server

Production (Optimized)

bash
python main_optimized.py

Legacy (Simple)

bash
python main.py

Command Line Options

bash
# HTTP transport with custom port
python main_optimized.py --transport streamable-http --port 8003

# Enable authentication (default for TradingView)
python main_optimized.py --auth

# Adjust concurrency
python main_optimized.py --max-concurrent 6

# Disable browser pooling (fallback to traditional)
python main_optimized.py --disable-pooling

🧪 Performance Testing

Agent-Style Testing

Test the server using the same approach as the production agent:

bash
cd tests/

# Sequential performance test
python test_mcp_agent_style.py --runs 5 --ticker BYBIT:BTCUSDT.P --interval 240

# Concurrent performance test
python test_mcp_agent_style.py --concurrent 3 --ticker BYBIT:BTCUSDT.P --interval 240

# Test different symbols and timeframes
python test_mcp_agent_style.py --concurrent 4 --ticker NASDAQ:AAPL --interval 15
python test_mcp_agent_style.py --concurrent 2 --ticker BYBIT:ETHUSDT.P --interval D

Expected Results

  • Sequential: ~6-8s per request (baseline)
  • Concurrent (3x): ~2.5-3.5s per request (70-80% improvement)
  • Success Rate: 100% reliability under load
  • Throughput: Up to 4 concurrent requests efficiently handled

🔧 Technical Details

Browser Pooling Architecture

  • Pre-initialized Browsers: 4 browser instances ready for immediate use
  • Thread-Safe Pool: Concurrent access with proper locking
  • Async Semaphore: Optimal request limiting
  • Performance Tracking: Real-time statistics and monitoring
  • Graceful Cleanup: Proper browser lifecycle management

Save Shortcut Feature

The MCP_SCRAPER_USE_SAVE_SHORTCUT feature allows you to capture chart images directly to the clipboard as base64 data URLs:

Benefits:

  • Faster Performance: No HTTP requests needed
  • More Reliable: No dependency on TradingView's CDN
  • Offline Capability: Works once chart is loaded
  • Direct Integration: Base64 data URLs for immediate use

Configuration:

bash
# Enable clipboard image capture (DEFAULT)
MCP_SCRAPER_USE_SAVE_SHORTCUT=True

# Disable and use traditional screenshot links
MCP_SCRAPER_USE_SAVE_SHORTCUT=False

Usage Examples

Available Tools:

  • get_tradingview_chart_image(ticker: str, interval: str): Optimized chart fetching with browser pooling

Example Prompts:

  • "Get the 15 minute chart for NASDAQ:AAPL"
  • "Show me the daily chart for BYBIT:BTCUSDT.P"
  • "Fetch TradingView chart image for COINBASE:ETHUSD on the 60 timeframe"

Deactivating the Virtual Environment

When finished:

bash
deactivate

🔄 Fallback Options

If you encounter issues with the optimized version:

  1. Disable Browser Pooling:

    bash
    python main_optimized.py --disable-pooling
  2. Use Legacy Version:

    bash
    python main.py
  3. Debug Mode:

    bash
    python main_optimized.py --log-level DEBUG

📊 Performance Monitoring

The optimized server includes built-in performance monitoring:

  • Request success rates
  • Average response times
  • Performance improvement metrics
  • Browser pool utilization
  • Concurrent request handling statistics

Access these metrics via the get_performance_stats tool or through the server logs.

🔌 Using with MCP Clients (Claude Desktop / Cursor)

This server supports two ways of providing configuration:

  1. Via .env file (for local testing): When running python main.py directly, the server will load credentials and settings from a .env file in the project directory.
  2. Via Client Environment Variables (Recommended for Integration): When run by an MCP client (like Claude/Cursor), you should configure the client to inject the required environment variables directly. These will override any values found in a .env file.

Claude Desktop

  1. Open your Claude Desktop configuration file:

    • Windows: %APPDATA%\\Claude\\claude_desktop_config.json
    • macOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
  2. Add or merge the following within the mcpServers object. Provide your credentials in the env block:

    json
    {
      "mcpServers": {
        "tradingview-chart-mcp": {
          "command": "/absolute/path/to/your/tradingview-chart-mcp/.venv/bin/python3",
          "args": ["/absolute/path/to/your/tradingview-chart-mcp/main.py"],
          "env": {
            "TRADINGVIEW_SESSION_ID": "YOUR_SESSION_ID_HERE",
            "TRADINGVIEW_SESSION_ID_SIGN": "YOUR_SESSION_ID_SIGN_HERE"
            // Optional: Add MCP_SCRAPER_* variables here too if needed
            // "MCP_SCRAPER_HEADLESS": "False"
          }
        }
        // ... other servers if any ...
      }
    }
  3. Replace the placeholder paths (command, args) with your actual absolute paths.

  4. Replace YOUR_SESSION_ID_HERE and YOUR_SESSION_ID_SIGN_HERE with your actual TradingView credentials.

  5. Restart Claude Desktop.

Cursor

  1. Go to: Settings -> Cursor Settings -> MCP -> Edit User MCP Config (~/.cursor/mcp.json).

  2. Add or merge the following within the mcpServers object. Provide your credentials in the env block:

    json
    {
      "mcpServers": {
        "tradingview-chart-mcp": {
          "command": "/absolute/path/to/your/tradingview-chart-mcp/.venv/bin/python3",
          "args": ["/absolute/path/to/your/tradingview-chart-mcp/main.py"],
          "env": {
            "TRADINGVIEW_SESSION_ID": "YOUR_SESSION_ID_HERE",
            "TRADINGVIEW_SESSION_ID_SIGN": "YOUR_SESSION_ID_SIGN_HERE"
            // Optional: Add MCP_SCRAPER_* variables here too if needed
            // "MCP_SCRAPER_HEADLESS": "False"
          }
        }
        // ... other servers if any ...
      }
    }
  3. Replace the placeholder paths (command, args) with your actual absolute paths.

  4. Replace YOUR_SESSION_ID_HERE and YOUR_SESSION_ID_SIGN_HERE with your actual TradingView credentials.

  5. Restart Cursor.

Installing via Smithery

To install TradingView Chart Image Scraper for Claude Desktop automatically via Smithery:

bash
npx -y @smithery/cli install @ertugrul59/tradingview-chart-mcp --client claude

Configuration

Environment Variables

The following environment variables can be set to configure the scraper:

  • TRADINGVIEW_SESSION_ID: Your TradingView session ID (required)
  • TRADINGVIEW_SESSION_ID_SIGN: Your TradingView session ID signature (required)
  • MCP_SCRAPER_HEADLESS: Run browser in headless mode (default: True)
  • MCP_SCRAPER_WINDOW_WIDTH: Browser window width (default: 1400)
  • MCP_SCRAPER_WINDOW_HEIGHT: Browser window height (default: 1400)
  • MCP_SCRAPER_USE_SAVE_SHORTCUT: Use clipboard image capture instead of screenshot links (default: True)
  • MCP_SCRAPER_CHART_PAGE_ID: Custom chart page ID (optional)

Save Shortcut Feature

The MCP_SCRAPER_USE_SAVE_SHORTCUT feature allows you to capture chart images directly to the clipboard as base64 data URLs instead of getting screenshot links. This eliminates the need to download images from URLs.

Benefits:

  • Faster chart capture (no HTTP requests needed)
  • More reliable (no dependency on TradingView's CDN)
  • Works offline once the chart is loaded
  • Direct base64 data URLs for immediate use

How it works:

  • When enabled (True): Uses Shift+Ctrl+S (or Shift+Cmd+S on Mac) to capture chart image directly to clipboard
  • When disabled (False): Uses traditional Alt+S to get screenshot links, then converts to image URLs

Configuration:

bash
# Enable clipboard image capture (DEFAULT)
MCP_SCRAPER_USE_SAVE_SHORTCUT=True

# Disable and use traditional screenshot links
MCP_SCRAPER_USE_SAVE_SHORTCUT=False

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "ertugrul59-tradingview-chart-mcp": {
      "command": "",
      "args": []
    }
  }
}

Use MCP 服务器 - TradingView 图表图片抓取工具 MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once MCP 服务器 - TradingView 图表图片抓取工具 is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add MCP 服务器 - TradingView 图表图片抓取工具 as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the MCP 服务器 - TradingView 图表图片抓取工具 MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "ertugrul59-tradingview-chart-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "tradingview-chart-mcp"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the MCP 服务器 - TradingView 图表图片抓取工具 MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the MCP 服务器 - TradingView 图表图片抓取工具 MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use MCP 服务器 - TradingView 图表图片抓取工具 to help me with this task?
MCP 服务器 - TradingView 图表图片抓取工具
Sure. I read it.
Here is what I found using MCP 服务器 - TradingView 图表图片抓取工具.

Frequently asked questions

What is the MCP 服务器 - TradingView 图表图片抓取工具 MCP server used for?

MCP 服务器 - TradingView 图表图片抓取工具 is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use MCP 服务器 - TradingView 图表图片抓取工具 MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use MCP 服务器 - TradingView 图表图片抓取工具 with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use MCP 服务器 - TradingView 图表图片抓取工具 MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With MCP 服务器 - TradingView 图表图片抓取工具 connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect MCP 服务器 - TradingView 图表图片抓取工具 MCP to TypingMind?

MCP 服务器 - TradingView 图表图片抓取工具 runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does MCP 服务器 - TradingView 图表图片抓取工具 MCP provide in TypingMind?

MCP 服务器 - TradingView 图表图片抓取工具 exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use MCP 服务器 - TradingView 图表图片抓取工具 MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If MCP 服务器 - TradingView 图表图片抓取工具 requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇