Skip to content
Back to search

tradingview-mcp

AI-assisted TradingView chart analysis — connect Claude Code to your TradingView Desktop for personal workflow automation

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/tradesdontlie--tradingview-mcp/badge.svg)](/listings/tradesdontlie--tradingview-mcp)

HTML

<a href="/listings/tradesdontlie--tradingview-mcp"><img src="/api/listings/tradesdontlie--tradingview-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.

Paste this into Claude Code and it will handle the rest:

> Install the TradingView MCP server. Clone https://github.com/tradesdontlie/tradingview-mcp.git, run npm install, add it to my MCP config at ~/.claude/.mcp.json, and launch TradingView with the debug port. Then verify the connection with tv_health_check.

Or follow the manual steps below.

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 · 396 lines

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

  1. # TradingView MCP Bridge
  2. [![MCP Toplist](https://mcptoplist.com/badge/glama%2Ftradesdontlie%2Ftradingview-mcp.svg)](https://mcptoplist.com/server/glama%2Ftradesdontlie%2Ftradingview-mcp)
  3. Personal AI assistant for your TradingView Desktop charts. Connects Claude Code to your locally running TradingView app via Chrome DevTools Protocol for AI-assisted chart analysis, Pine Script development, and workflow automation.
  4. > [!WARNING]
  5. > **This tool is not affiliated with, endorsed by, or associated with TradingView Inc.** It interacts with your locally running TradingView Desktop application via Chrome DevTools Protocol. Review the [Disclaimer](#disclaimer) before use.
  6. > [!IMPORTANT]
  7. > **Requires a valid TradingView subscription.** This tool does not bypass or circumvent any TradingView paywall or access control. It reads from and controls the TradingView Desktop app already running on your machine.
  8. > [!NOTE]
  9. > **All data processing occurs locally on your machine.** No TradingView data is transmitted, stored, or redistributed externally by this tool.
  10. > [!CAUTION]
  11. > This tool accesses undocumented internal TradingView APIs via the Electron debug interface. These can change or break without notice in any TradingView update. Pin your TradingView Desktop version if stability matters to you.
  12. ## How It Works (and why it's safe to run)
  13. This tool does not connect to TradingView's servers, modify any TradingView files, or intercept any network traffic. It communicates exclusively with your locally running TradingView Desktop instance via Chrome DevTools Protocol (CDP) — a standard debugging interface built into all Chromium/Electron applications by Google, including VS Code, Slack, and Discord.
  14. The debug port is disabled by default and must be explicitly enabled by you using a standard Chromium flag (`--remote-debugging-port=9222`). Nothing happens without that deliberate step.
  15. ## What This Tool Does Not Do
  16. - Connect to TradingView's servers or APIs
  17. - Store, transmit, or redistribute any market data
  18. - Work without a valid TradingView subscription and installed Desktop app
  19. - Bypass any TradingView paywall or access restriction
  20. - Execute real trades (chart interaction only)
  21. - Work if TradingView changes their internal Electron structure
  22. ## Research Context
  23. This project explores an open research question: **how can LLM-based agents interact with professional trading interfaces to support human decision-making?**
  24. Specifically it investigates:
  25. - How structured tool APIs (MCP) can bridge LLMs and stateful desktop financial applications
  26. - What latency, context, and reliability constraints emerge when an agent operates on live chart data
  27. - How agents handle ambiguous financial UI state (e.g. interpreting Pine Script output, reading indicator tables)
  28. - Whether natural language is an effective interface for chart navigation and Pine Script development
  29. - The failure modes of LLM agents operating in real-time data environments
  30. This is not a trading bot. It is an interface layer that makes a trading application legible to an LLM agent, allowing researchers and developers to study human-AI collaboration in financial workflows.
  31. See [RESEARCH.md](RESEARCH.md) for open questions, findings, and related work.
  32. ## Prerequisites
  33. - **TradingView Desktop app** (paid subscription required for real-time data)
  34. - **Node.js 18+**
  35. - **Claude Code** with MCP support (for MCP tools) or any terminal (for CLI)
  36. - **macOS, Windows, or Linux**
  37. ## What It Does
  38. Gives your AI assistant eyes and hands on your own chart:
  39. - **Pine Script development** — write, inject, compile, debug, and iterate on scripts with AI assistance
  40. - **Chart navigation** — change symbols, timeframes, zoom to dates, add/remove indicators
  41. - **Visual analysis** — read your chart's indicator values, price levels, and annotations
  42. - **Draw on charts** — trend lines, horizontal lines, rectangles, text annotations
  43. - **Manage alerts** — create, list, and delete price alerts
  44. - **Replay practice** — step through historical bars, practice entries/exits
  45. - **Screenshots** — capture chart state for AI visual analysis
  46. - **Multi-pane layouts** — set up 2x2, 3x1, etc. grids with different symbols per pane
  47. - **Monitor your chart** — stream JSONL from your locally running chart for local monitoring scripts
  48. - **CLI access** — every MCP tool is also a `tv` CLI command, pipe-friendly with JSON output
  49. - **Launch TradingView** — auto-detect and launch with debug mode from any platform
  50. ## Install with Claude Code
  51. Paste this into Claude Code and it will handle the rest:
  52. > Install the TradingView MCP server. Clone https://github.com/tradesdontlie/tradingview-mcp.git, run npm install, add it to my MCP config at ~/.claude/.mcp.json, and launch TradingView with the debug port. Then verify the connection with tv_health_check.
  53. Or follow the manual steps below.
  54. ## Quick Start
  55. ### 1. Install
  56. ```bash
  57. git clone https://github.com/tradesdontlie/tradingview-mcp.git
  58. cd tradingview-mcp
  59. npm install
  60. ```
  61. ### 2. Launch TradingView with CDP
  62. TradingView Desktop must be running with Chrome DevTools Protocol enabled on port 9222.
  63. **Mac:**
  64. ```bash
  65. ./scripts/launch_tv_debug_mac.sh
  66. ```
  67. **Windows:**
  68. ```bash
  69. scripts\launch_tv_debug.bat
  70. ```
  71. **Linux:**
  72. ```bash
  73. ./scripts/launch_tv_debug_linux.sh
  74. ```
  75. **Or launch manually on any platform:**
  76. ```bash
  77. /path/to/TradingView --remote-debugging-port=9222
  78. ```
  79. **Or use the MCP tool** (auto-detects your install):
  80. > "Use tv_launch to start TradingView in debug mode"
  81. ### 3. Add to Claude Code
  82. Add to your Claude Code MCP config (`~/.claude/.mcp.json` or project `.mcp.json`):
  83. ```json
  84. {
  85. "mcpServers": {
  86. "tradingview": {
  87. "command": "node",
  88. "args": ["/path/to/tradingview-mcp/src/server.js"]
  89. }
  90. }
  91. }
  92. ```
  93. Replace `/path/to/tradingview-mcp` with your actual path.
  94. ### 4. Verify
  95. Ask Claude: *"Use tv_health_check to verify TradingView is connected"*
  96. ## CLI
  97. Every MCP tool is also accessible as a `tv` CLI command. All output is JSON for piping with `jq`.
  98. ```bash
  99. # Install globally (optional)
  100. npm link
  101. # Or run directly
  102. node src/cli/index.js <command>
  103. ```
  104. ### Quick Examples
  105. ```bash
  106. tv status # check connection
  107. tv quote # current price
  108. tv symbol AAPL # change symbol
  109. tv ohlcv --summary # price summary
  110. tv screenshot -r chart # capture chart
  111. tv pine compile # compile Pine Script
  112. tv pane layout 2x2 # 4-chart grid
  113. tv pane symbol 1 ES1! # set pane symbol
  114. tv stream quote | jq '.close' # monitor price changes
  115. ```
  116. ### All Commands
  117. ```
  118. tv status / launch / state / symbol / timeframe / type / info / search
  119. tv quote / ohlcv / values
  120. tv data lines/labels/tables/boxes/strategy/trades/equity/depth/indicator
  121. tv pine get/set/compile/analyze/check/save/new/open/list/errors/console
  122. tv draw shape/list/get/remove/clear
  123. tv alert list/create/delete
  124. tv watchlist get/add
  125. tv indicator add/remove/toggle/set/get
  126. tv layout list/switch
  127. tv pane list/layout/focus/symbol
  128. tv tab list/new/close/switch
  129. tv replay start/step/stop/status/autoplay/trade
  130. tv stream quote/bars/values/lines/labels/tables/all
  131. tv ui click/keyboard/hover/scroll/find/eval/type/panel/fullscreen/mouse
  132. tv screenshot / discover / ui-state / range / scroll
  133. ```
  134. ## Streaming
  135. The `tv stream` commands poll your locally running TradingView Desktop instance at regular intervals via Chrome DevTools Protocol on localhost.
  136. No connection is made to TradingView's servers. All data stays on your machine.
  137. > [!WARNING]
  138. > Programmatic consumption of TradingView data may conflict with their Terms of Use regardless of the data source. You are solely responsible for ensuring your usage complies.
  139. ```bash
  140. tv stream quote # price tick monitoring
  141. tv stream bars # bar-by-bar updates
  142. tv stream values # indicator value monitoring
  143. tv stream lines --filter "NY Levels" # price level monitoring
  144. tv stream tables --filter Profiler # table data monitoring
  145. tv stream all # all panes at once (multi-symbol)
  146. ```
  147. ## How Claude Knows Which Tool to Use
  148. Claude reads [`CLAUDE.md`](CLAUDE.md) automatically when working in this project. It contains a complete decision tree:
  149. | You say... | Claude uses... |
  150. |------------|---------------|
  151. | "What's on my chart?" | `chart_get_state` → `data_get_study_values` → `quote_get` |
  152. | "What levels are showing?" | `data_get_pine_lines` → `data_get_pine_labels` |
  153. | "Read the session table" | `data_get_pine_tables` with `study_filter` |
  154. | "Give me a full analysis" | `quote_get` → `data_get_study_values` → `data_get_pine_lines` → `data_get_pine_labels` → `data_get_pine_tables` → `data_get_ohlcv` (summary) → `capture_screenshot` |
  155. | "Switch to AAPL daily" | `chart_set_symbol` → `chart_set_timeframe` |
  156. | "Write a Pine Script for..." | `pine_set_source` → `pine_smart_compile` → `pine_get_errors` |
  157. | "Start replay at March 1st" | `replay_start` → `replay_step` → `replay_trade` |
  158. | "Set up a 4-chart grid" | `pane_set_layout` → `pane_set_symbol` for each pane |
  159. | "Draw a level at 24500" | `draw_shape` (horizontal_line) |
  160. | "Take a screenshot" | `capture_screenshot` |
  161. ## Tool Reference (78 MCP tools)
  162. ### Chart Reading
  163. | Tool | When to use | Output size |
  164. |------|------------|-------------|
  165. | `chart_get_state` | First call — get symbol, timeframe, all indicator names + IDs | ~500B |
  166. | `data_get_study_values` | Read current RSI, MACD, BB, EMA values from all indicators | ~500B |
  167. | `quote_get` | Get latest price, OHLC, volume | ~200B |
  168. | `data_get_ohlcv` | Get price bars. **Use `summary: true`** for compact stats | 500B (summary) / 8KB (100 bars) |
  169. ### Custom Indicator Data (Pine Drawings)
  170. Read `line.new()`, `label.new()`, `table.new()`, `box.new()` output from any visible Pine indicator.
  171. | Tool | When to use | Output size |
  172. |------|------------|-------------|
  173. | `data_get_pine_lines` | Read horizontal price levels (support/resistance, session levels) | ~1-3KB |
  174. | `data_get_pine_labels` | Read text annotations + prices ("PDH 24550", "Bias Long") | ~2-5KB |
  175. | `data_get_pine_tables` | Read data tables (session stats, analytics dashboards) | ~1-4KB |
  176. | `data_get_pine_boxes` | Read price zones / ranges as {high, low} pairs | ~1-2KB |
  177. **Always use `study_filter`** to target a specific indicator: `study_filter: "Profiler"`.
  178. ### Chart Control
  179. | Tool | What it does |
  180. |------|-------------|
  181. | `chart_set_symbol` | Change ticker (BTCUSD, AAPL, ES1!, NYMEX:CL1!) |
  182. | `chart_set_timeframe` | Change resolution (1, 5, 15, 60, D, W, M) |
  183. | `chart_set_type` | Change style (Candles, HeikinAshi, Line, Area, Renko) |
  184. | `chart_manage_indicator` | Add/remove indicators. **Use full names**: "Relative Strength Index" not "RSI" |
  185. | `chart_scroll_to_date` | Jump to a date (ISO: "2025-01-15") |
  186. | `chart_set_visible_range` | Zoom to exact range (unix timestamps) |
  187. | `symbol_info` / `symbol_search` | Symbol metadata and search |
  188. | `indicator_set_inputs` / `indicator_toggle_visibility` | Change indicator settings, show/hide |
  189. ### Multi-Pane Layouts
  190. | Tool | What it does |
  191. |------|-------------|
  192. | `pane_list` | List all panes with symbols and active state |
  193. | `pane_set_layout` | Change grid: `s`, `2h`, `2v`, `2x2`, `4`, `6`, `8` |
  194. | `pane_focus` | Focus a specific pane by index |
  195. | `pane_set_symbol` | Set symbol on any pane |
  196. ### Tab Management
  197. | Tool | What it does |
  198. |------|-------------|
  199. | `tab_list` | List open chart tabs |
  200. | `tab_new` / `tab_close` | Open/close tabs |
  201. | `tab_switch` | Switch to a tab by index |
  202. ### Pine Script Development
  203. | Tool | Step |
  204. |------|------|
  205. | `pine_set_source` | 1. Inject code into editor |
  206. | `pine_smart_compile` | 2. Compile with auto-detection + error check |
  207. | `pine_get_errors` | 3. Read compilation errors if any |
  208. | `pine_get_console` | 4. Read log.info() output |
  209. | `pine_save` | 5. Save to TradingView cloud |
  210. | `pine_get_source` | Read current script (**warning: can be 200KB+ for complex scripts**) |
  211. | `pine_new` | Create blank indicator/strategy/library |
  212. | `pine_open` / `pine_list_scripts` | Open or list saved scripts |
  213. | `pine_analyze` | Offline static analysis (no chart needed) |
  214. | `pine_check` | Server-side compile check (no chart needed) |
  215. ### Replay Mode
  216. | Tool | Step |
  217. |------|------|
  218. | `replay_start` | Enter replay at a date |
  219. | `replay_step` | Advance one bar |
  220. | `replay_autoplay` | Auto-advance (set speed in ms) |
  221. | `replay_trade` | Buy/sell/close positions |
  222. | `replay_status` | Check position, P&L, date |
  223. | `replay_stop` | Return to realtime |
  224. ### Drawing, Alerts, UI Automation
  225. | Tool | What it does |
  226. |------|-------------|
  227. | `draw_shape` | Draw horizontal_line, trend_line, rectangle, text |
  228. | `draw_list` / `draw_remove_one` / `draw_clear` | Manage drawings |
  229. | `alert_create` / `alert_list` / `alert_delete` | Manage price alerts |
  230. | `capture_screenshot` | Screenshot (regions: full, chart, strategy_tester) |
  231. | `batch_run` | Run action across multiple symbols/timeframes |
  232. | `watchlist_get` / `watchlist_add` | Read/modify watchlist |
  233. | `layout_list` / `layout_switch` | Manage saved layouts |
  234. | `ui_open_panel` / `ui_click` / `ui_evaluate` | UI automation |
  235. | `tv_launch` / `tv_health_check` / `tv_discover` | Connection management |
  236. ## Context Management
  237. Tools return compact output by default to minimize context usage. For a typical "analyze my chart" workflow, total context is ~5-10KB instead of ~80KB.
  238. | Feature | How it saves context |
  239. |---------|---------------------|
  240. | Pine lines | Returns deduplicated price levels only, not every line object |
  241. | Pine labels | Capped at 50 per study, text+price only |
  242. | Pine tables | Pre-formatted row strings, no cell metadata |
  243. | Pine boxes | Deduplicated {high, low} zones only |
  244. | OHLCV summary mode | Stats + last 5 bars instead of all bars |
  245. | Indicator inputs | Encrypted/encoded blobs auto-filtered |
  246. | `verbose: true` | Pass on any pine tool to get raw data with IDs/colors when needed |
  247. | `study_filter` | Target one indicator instead of scanning all |
  248. ## Finding TradingView on Your System
  249. Launch scripts and `tv_launch` auto-detect TradingView. If auto-detection fails:
  250. | Platform | Common Locations |
  251. |----------|-----------------|
  252. | **Mac** | `/Applications/TradingView.app/Contents/MacOS/TradingView` |
  253. | **Windows** | `%LOCALAPPDATA%\TradingView\TradingView.exe`, `%PROGRAMFILES%\WindowsApps\TradingView*\TradingView.exe` |
  254. | **Linux** | `/opt/TradingView/tradingview`, `~/.local/share/TradingView/TradingView`, `/snap/tradingview/current/tradingview` |
  255. The key flag: `--remote-debugging-port=9222`
  256. ## Testing
  257. ```bash
  258. # Requires TradingView running with --remote-debugging-port=9222
  259. npm test
  260. ```
  261. 29 tests covering: Pine Script static analysis, server-side compilation, and CLI routing.
  262. ## Architecture
  263. ```
  264. Claude Code ←→ MCP Server (stdio) ←→ CDP (port 9222) ←→ TradingView Desktop (Electron)
  265. ```
  266. - **Transport**: MCP over stdio (84 tools) + CLI (`tv` command, 30 commands with 66 subcommands)
  267. - **Connection**: Chrome DevTools Protocol on localhost:9222
  268. - **Streaming**: Poll-and-diff loop with deduplication, JSONL output to stdout
  269. - **No dependencies** beyond `@modelcontextprotocol/sdk` and `chrome-remote-interface`
  270. ## Attributions
  271. This project is not affiliated with, endorsed by, or associated with:
  272. - **TradingView Inc.** — TradingView is a trademark of TradingView Inc.
  273. - **Anthropic** — Claude and Claude Code are trademarks of Anthropic, PBC.
  274. This tool is an independent MCP server that connects to Claude Code via the standard MCP protocol. It does not contain or modify any Anthropic software.
  275. ## Disclaimer
  276. This project is provided **for personal, educational, and research purposes only**.
  277. **How this tool works:** This tool uses Chrome DevTools Protocol (CDP), the standard debugging interface built into Chromium-based applications. It does not reverse engineer any proprietary TradingView protocol, connect to TradingView's servers, or bypass any access controls. The debug port must be explicitly enabled by the user via a standard Chromium command-line flag (`--remote-debugging-port=9222`).
  278. By using this software, you acknowledge and agree that:
  279. 1. **You are solely responsible** for ensuring your use of this tool complies with [TradingView's Terms of Use](https://www.tradingview.com/policies/) and all applicable laws.
  280. 2. TradingView's Terms of Use **restrict automated data collection, scraping, and non-display usage** of their platform and data. This tool uses Chrome DevTools Protocol to programmatically interact with the TradingView Desktop app, which may conflict with those terms.
  281. 3. **You assume all risk** associated with using this tool. The authors are not responsible for any account bans, suspensions, legal actions, or other consequences resulting from its use.
  282. 4. This tool **must not be used** for, including but not limited to:
  283. - Redistributing, reselling, or commercially exploiting TradingView's market data
  284. - Circumventing TradingView's access controls or subscription restrictions
  285. - Performing automated trading or algorithmic decision-making using extracted data
  286. - Violating the intellectual property rights of Pine Script indicator authors
  287. - Connecting to TradingView's servers or infrastructure (all access is via the locally running Desktop app)
  288. 5. The streaming functionality monitors your locally running TradingView Desktop instance only. It does not connect to TradingView's servers or extract data from TradingView's infrastructure.
  289. 6. Market data accessed through this tool remains subject to exchange and data provider licensing terms. **Do not redistribute, store, or commercially exploit any data obtained through this tool.**
  290. 7. This tool accesses internal, undocumented TradingView application interfaces that may change or break at any time without notice.
  291. **Use at your own risk.** If you are unsure whether your intended use complies with TradingView's terms, do not use this tool.
  292. ## License
  293. MIT — see [LICENSE](LICENSE) for details.
  294. The MIT license applies to the source code of this project only. It does not grant any rights to TradingView's software, data, trademarks, or intellectual property.

Ratings and comments

Sign in to rate this skill.

Sign in

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