Skip to content
Back to search

tradingview-chart-mcp

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

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/ertugrul59--tradingview-chart-mcp/badge.svg)](/listings/ertugrul59--tradingview-chart-mcp)

HTML

<a href="/listings/ertugrul59--tradingview-chart-mcp"><img src="/api/listings/ertugrul59--tradingview-chart-mcp/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

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.

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 382 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # MCP Server - TradingView Chart Image Scraper
  2. <a href="https://mseep.ai/app/ertugrul59-tradingview-chart-mcp"><img src="https://mseep.net/pr/ertugrul59-tradingview-chart-mcp-badge.png" alt="MseeP.ai Security Assessment" width="200"></a>
  3. **🚀 Now with Browser Pooling Optimization for 70-80% Better Concurrent Performance!**
  4. This MCP server provides tools to fetch TradingView chart images based on ticker and interval with advanced browser pooling for maximum concurrent performance.
  5. ![Demo — AI analyzing a BTCUSDT daily chart via MCP](https://github.com/user-attachments/assets/d9f09bd8-6a4d-4acd-a8aa-4c3eadcea2b3)
  6. ## 🔥 Performance Optimizations
  7. ### Browser Pooling Technology
  8. - **Production Version**: Uses `main_optimized.py` with browser pooling for maximum concurrent performance
  9. - **Performance Improvement**: 70-80% faster for concurrent requests
  10. - **Concurrent Handling**: Supports up to 4 simultaneous requests with pre-initialized browser instances
  11. - **Expected Performance**:
  12. - 1 request: ~6-8s (baseline)
  13. - 2 concurrent: ~3-4s each (60-70% faster)
  14. - 3 concurrent: ~2.5-3.5s each (70-80% faster)
  15. ### Version Comparison
  16. - **`main_optimized.py`** (Production): Browser pooling, concurrent optimization, performance tracking
  17. - **`main.py`** (Legacy): Simple single-browser approach, kept for debugging/fallback
  18. ## Features
  19. - **🚀 Optimized Chart Image Tool:** Fetches direct chart images with browser pooling for maximum concurrent performance
  20. - **📊 Performance Statistics:** Built-in performance monitoring and statistics
  21. - **🔄 Browser Pool Management:** Pre-initialized browser instances for zero-overhead concurrent requests
  22. - **🎯 Natural Language Prompts:** Easy chart requests with interval mapping
  23. - **⚙️ Environment Configuration:** Fully configurable via environment variables
  24. - **🔐 TradingView Authentication:** Secure session-based authentication
  25. - **💾 Clipboard Capture:** Direct base64 image capture for faster performance
  26. ## Tools
  27. ### `get_tradingview_chart_image`
  28. **Description:** Fetches the direct image URL for a TradingView chart snapshot with optimized concurrent performance.
  29. **Performance:** This optimized version achieves 70-80% better performance for concurrent requests using browser pooling technology.
  30. **Arguments:**
  31. - `ticker` (str): The TradingView ticker symbol (e.g., "BYBIT:BTCUSDT.P", "NASDAQ:AAPL"). **Required**.
  32. - `interval` (str): The chart time interval (e.g., '1', '5', '15', '60', '240', 'D', 'W'). **Required**.
  33. **Returns:**
  34. - (str): The direct TradingView snapshot image URL (e.g., `data:image/png;base64,...` or `https://s3.tradingview.com/snapshots/...`).
  35. **Raises:**
  36. - `Error` (MCP type): If the scraper encounters an error. Error codes:
  37. - `400`: Input error (invalid ticker/interval format)
  38. - `503`: Scraper error (failure during the scraping process)
  39. - `500`: Unexpected internal server error
  40. ### `get_performance_stats`
  41. **Description:** Get performance statistics for the optimized TradingView MCP server.
  42. **Returns:**
  43. - Detailed metrics about request performance, improvement over baseline, and browser pool status
  44. **Example Output:**
  45. ```
  46. 🚀 OPTIMIZED TRADINGVIEW MCP SERVER PERFORMANCE STATS
  47. • Total Requests: 12
  48. • Average Time: 3.30s
  49. • Performance Improvement: 70.8%
  50. • Browsers in Pool: 4
  51. • Max Concurrent: 4
  52. ```
  53. ## Prompts
  54. - `Get the {interval} chart for {ticker}`
  55. - Maps common timeframe names (e.g., "1 minute", "5 minute", "1 hour", "daily") to TradingView codes
  56. - `Show me the daily TradingView chart for {ticker}`
  57. - Specifically requests the daily ('D') chart
  58. - `Fetch TradingView chart image for {ticker} on the {interval} timeframe`
  59. - Comprehensive prompt with timeframe mapping
  60. ## Setup
  61. 1. **Create Virtual Environment:**
  62. ```bash
  63. # Navigate to the project directory
  64. cd tradingview-chart-mcp
  65. # Create the venv (use python3 if python is not linked)
  66. python3 -m venv .venv
  67. ```
  68. 2. **Activate Virtual Environment:**
  69. - **macOS/Linux:**
  70. ```bash
  71. source .venv/bin/activate
  72. ```
  73. - **Windows (Git Bash/WSL):**
  74. ```bash
  75. source .venv/Scripts/activate
  76. ```
  77. - **Windows (Command Prompt):**
  78. ```bash
  79. .venv\\Scripts\\activate.bat
  80. ```
  81. - **Windows (PowerShell):**
  82. ```bash
  83. .venv\\Scripts\\Activate.ps1
  84. ```
  85. _(Note: You might need to adjust PowerShell execution policy: `Set-ExecutionPolicy RemoteSigned -Scope CurrentUser`)_
  86. Your terminal prompt should now indicate you are in the `(.venv)`.
  87. 3. **Install Dependencies (inside venv):**
  88. ```bash
  89. pip install -r requirements.txt
  90. ```
  91. 4. **Configure Environment (for Local Testing):**
  92. - Copy `.env.example` to `.env`.
  93. - 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.
  94. - This `.env` file is used when running the server directly (e.g., `python main.py`) for local testing.
  95. - Adjust optional scraper settings (`MCP_SCRAPER_HEADLESS`, etc.) in `.env` if needed for local runs.
  96. 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.
  97. ## Running the Server
  98. ### Production (Optimized)
  99. ```bash
  100. python main_optimized.py
  101. ```
  102. ### Legacy (Simple)
  103. ```bash
  104. python main.py
  105. ```
  106. ### Command Line Options
  107. ```bash
  108. # HTTP transport with custom port
  109. python main_optimized.py --transport streamable-http --port 8003
  110. # Enable authentication (default for TradingView)
  111. python main_optimized.py --auth
  112. # Adjust concurrency
  113. python main_optimized.py --max-concurrent 6
  114. # Disable browser pooling (fallback to traditional)
  115. python main_optimized.py --disable-pooling
  116. ```
  117. ## 🧪 Performance Testing
  118. ### Agent-Style Testing
  119. Test the server using the same approach as the production agent:
  120. ```bash
  121. cd tests/
  122. # Sequential performance test
  123. python test_mcp_agent_style.py --runs 5 --ticker BYBIT:BTCUSDT.P --interval 240
  124. # Concurrent performance test
  125. python test_mcp_agent_style.py --concurrent 3 --ticker BYBIT:BTCUSDT.P --interval 240
  126. # Test different symbols and timeframes
  127. python test_mcp_agent_style.py --concurrent 4 --ticker NASDAQ:AAPL --interval 15
  128. python test_mcp_agent_style.py --concurrent 2 --ticker BYBIT:ETHUSDT.P --interval D
  129. ```
  130. ### Expected Results
  131. - **Sequential**: ~6-8s per request (baseline)
  132. - **Concurrent (3x)**: ~2.5-3.5s per request (70-80% improvement)
  133. - **Success Rate**: 100% reliability under load
  134. - **Throughput**: Up to 4 concurrent requests efficiently handled
  135. ## 🔧 Technical Details
  136. ### Browser Pooling Architecture
  137. - **Pre-initialized Browsers**: 4 browser instances ready for immediate use
  138. - **Thread-Safe Pool**: Concurrent access with proper locking
  139. - **Async Semaphore**: Optimal request limiting
  140. - **Performance Tracking**: Real-time statistics and monitoring
  141. - **Graceful Cleanup**: Proper browser lifecycle management
  142. ### Save Shortcut Feature
  143. The `MCP_SCRAPER_USE_SAVE_SHORTCUT` feature allows you to capture chart images directly to the clipboard as base64 data URLs:
  144. **Benefits:**
  145. - **Faster Performance**: No HTTP requests needed
  146. - **More Reliable**: No dependency on TradingView's CDN
  147. - **Offline Capability**: Works once chart is loaded
  148. - **Direct Integration**: Base64 data URLs for immediate use
  149. **Configuration:**
  150. ```bash
  151. # Enable clipboard image capture (DEFAULT)
  152. MCP_SCRAPER_USE_SAVE_SHORTCUT=True
  153. # Disable and use traditional screenshot links
  154. MCP_SCRAPER_USE_SAVE_SHORTCUT=False
  155. ```
  156. ## Usage Examples
  157. **Available Tools:**
  158. - `get_tradingview_chart_image(ticker: str, interval: str)`: Optimized chart fetching with browser pooling
  159. **Example Prompts:**
  160. - "Get the 15 minute chart for NASDAQ:AAPL"
  161. - "Show me the daily chart for BYBIT:BTCUSDT.P"
  162. - "Fetch TradingView chart image for COINBASE:ETHUSD on the 60 timeframe"
  163. ## Deactivating the Virtual Environment
  164. When finished:
  165. ```bash
  166. deactivate
  167. ```
  168. ## 🔄 Fallback Options
  169. If you encounter issues with the optimized version:
  170. 1. **Disable Browser Pooling:**
  171. ```bash
  172. python main_optimized.py --disable-pooling
  173. ```
  174. 2. **Use Legacy Version:**
  175. ```bash
  176. python main.py
  177. ```
  178. 3. **Debug Mode:**
  179. ```bash
  180. python main_optimized.py --log-level DEBUG
  181. ```
  182. ## 📊 Performance Monitoring
  183. The optimized server includes built-in performance monitoring:
  184. - Request success rates
  185. - Average response times
  186. - Performance improvement metrics
  187. - Browser pool utilization
  188. - Concurrent request handling statistics
  189. Access these metrics via the `get_performance_stats` tool or through the server logs.
  190. ## 🔌 Using with MCP Clients (Claude Desktop / Cursor)
  191. This server supports two ways of providing configuration:
  192. 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.
  193. 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.**
  194. ### Claude Desktop
  195. 1. Open your Claude Desktop configuration file:
  196. - **Windows:** `%APPDATA%\\Claude\\claude_desktop_config.json`
  197. - **macOS:** `~/Library/Application\ Support/Claude/claude_desktop_config.json`
  198. 2. Add or merge the following within the `mcpServers` object. Provide your credentials in the `env` block:
  199. ```json
  200. {
  201. "mcpServers": {
  202. "tradingview-chart-mcp": {
  203. "command": "/absolute/path/to/your/tradingview-chart-mcp/.venv/bin/python3",
  204. "args": ["/absolute/path/to/your/tradingview-chart-mcp/main.py"],
  205. "env": {
  206. "TRADINGVIEW_SESSION_ID": "YOUR_SESSION_ID_HERE",
  207. "TRADINGVIEW_SESSION_ID_SIGN": "YOUR_SESSION_ID_SIGN_HERE"
  208. // Optional: Add MCP_SCRAPER_* variables here too if needed
  209. // "MCP_SCRAPER_HEADLESS": "False"
  210. }
  211. }
  212. // ... other servers if any ...
  213. }
  214. }
  215. ```
  216. 3. Replace the placeholder paths (`command`, `args`) with your actual absolute paths.
  217. 4. Replace `YOUR_SESSION_ID_HERE` and `YOUR_SESSION_ID_SIGN_HERE` with your actual TradingView credentials.
  218. 5. Restart Claude Desktop.
  219. ### Cursor
  220. 1. Go to: `Settings -> Cursor Settings -> MCP -> Edit User MCP Config (~/.cursor/mcp.json)`.
  221. 2. Add or merge the following within the `mcpServers` object. Provide your credentials in the `env` block:
  222. ```json
  223. {
  224. "mcpServers": {
  225. "tradingview-chart-mcp": {
  226. "command": "/absolute/path/to/your/tradingview-chart-mcp/.venv/bin/python3",
  227. "args": ["/absolute/path/to/your/tradingview-chart-mcp/main.py"],
  228. "env": {
  229. "TRADINGVIEW_SESSION_ID": "YOUR_SESSION_ID_HERE",
  230. "TRADINGVIEW_SESSION_ID_SIGN": "YOUR_SESSION_ID_SIGN_HERE"
  231. // Optional: Add MCP_SCRAPER_* variables here too if needed
  232. // "MCP_SCRAPER_HEADLESS": "False"
  233. }
  234. }
  235. // ... other servers if any ...
  236. }
  237. }
  238. ```
  239. 3. Replace the placeholder paths (`command`, `args`) with your actual absolute paths.
  240. 4. Replace `YOUR_SESSION_ID_HERE` and `YOUR_SESSION_ID_SIGN_HERE` with your actual TradingView credentials.
  241. 5. Restart Cursor.
  242. ### Installing via Smithery
  243. To install TradingView Chart Image Scraper for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@ertugrul59/tradingview-chart-mcp):
  244. ```bash
  245. npx -y @smithery/cli install @ertugrul59/tradingview-chart-mcp --client claude
  246. ```
  247. ## Configuration
  248. ### Environment Variables
  249. The following environment variables can be set to configure the scraper:
  250. - `TRADINGVIEW_SESSION_ID`: Your TradingView session ID (required)
  251. - `TRADINGVIEW_SESSION_ID_SIGN`: Your TradingView session ID signature (required)
  252. - `MCP_SCRAPER_HEADLESS`: Run browser in headless mode (default: `True`)
  253. - `MCP_SCRAPER_WINDOW_WIDTH`: Browser window width (default: `1400`)
  254. - `MCP_SCRAPER_WINDOW_HEIGHT`: Browser window height (default: `1400`)
  255. - `MCP_SCRAPER_USE_SAVE_SHORTCUT`: Use clipboard image capture instead of screenshot links (default: `True`)
  256. - `MCP_SCRAPER_CHART_PAGE_ID`: Custom chart page ID (optional)
  257. ### Save Shortcut Feature
  258. 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.
  259. **Benefits:**
  260. - Faster chart capture (no HTTP requests needed)
  261. - More reliable (no dependency on TradingView's CDN)
  262. - Works offline once the chart is loaded
  263. - Direct base64 data URLs for immediate use
  264. **How it works:**
  265. - When enabled (`True`): Uses `Shift+Ctrl+S` (or `Shift+Cmd+S` on Mac) to capture chart image directly to clipboard
  266. - When disabled (`False`): Uses traditional `Alt+S` to get screenshot links, then converts to image URLs
  267. **Configuration:**
  268. ```bash
  269. # Enable clipboard image capture (DEFAULT)
  270. MCP_SCRAPER_USE_SAVE_SHORTCUT=True
  271. # Disable and use traditional screenshot links
  272. MCP_SCRAPER_USE_SAVE_SHORTCUT=False
  273. ```

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.